# Create sprite component

**URL:** <https://forums.unrealengine.com/t/create-sprite-component/317283>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [May 3, 2015, 7:45am UTC](https://forums.unrealengine.com/t/create-sprite-component/317283 "2015-05-03T07:45:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_41948240](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41948240](https://forums.unrealengine.com/u/anonymous_user_41948240)\
**Post date:** [May 3, 2015, 7:45am UTC](https://forums.unrealengine.com/t/create-sprite-component/317283/1 "2015-05-03T07:45:44Z")

</div>

I thought of doing something similar to that:  
.h:

```
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Sprites)
		TSubobjectPtr<class UPaperSpriteComponent> BodySprite;

```

.cpp:

```
struct FConstructorStatics {
    	ConstructorHelpers::FObjectFinderOptional<UPaperSprite> BodyAsset;
    	FConstructorStatics() : BodyAsset(TEXT("/Game/Sprites/Character/Ship_Body.Ship_Body")) {}
} ConstructorStatics;
BodySprite = PCIP.CreateDefaultSubobject<UPaperSpriteCmponent>(this, TEXT("PlaneSprite0"));
// something like BodySprite->SetStaticMesh(ConstructorStatics1.PlaneMesh.Get());
RootComponent = BodySprite;

```

---

<div class="post-metadata">

**Author:** ![Azarus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Azarus](https://forums.unrealengine.com/u/Azarus)\
**Post date:** [May 3, 2015, 1:26pm UTC](https://forums.unrealengine.com/t/create-sprite-component/317283/2 "2015-05-03T13:26:59Z")

</div>

And whats the problem?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41948240](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41948240](https://forums.unrealengine.com/u/anonymous_user_41948240)\
**Post date:** [May 3, 2015, 1:43pm UTC](https://forums.unrealengine.com/t/create-sprite-component/317283/3 "2015-05-03T13:43:31Z")

</div>

The problem is that i have no idea how to actually do this. The code above was just an idea. But I don’t know what variable to use for the sprite and how to initialize it so I could place it as an actual actor in my level.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8e2766aa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8e2766aa](https://forums.unrealengine.com/u/anonymous_user_8e2766aa)\
**Post date:** [May 6, 2015, 8:32am UTC](https://forums.unrealengine.com/t/create-sprite-component/317283/4 "2015-05-06T08:32:56Z")

</div>

Hello,

You can create a custom class, derived from Paper Sprite Component or Paper Sprite Actor from the editor just like any other class. However, please keep in mind that these classes come from Paper2D module, which may not be included to your project by default. To include it, please do the following:

1. Go to Build.cs file of your project (YourProjectName\Source\ YourProjectName\ YourProjectName.Build.cs).

2. In the file, find PublicDependencyModuleNames.AddRange command and add Paper2D to the list of included modules:

3. Rebuild your project.

Now you can use the classes.

If you like to learn more about using sprites in Unreal Engine 4, please go here:

> **[Paper 2D Sprites](https://docs.unrealengine.com/5.1/en-US/paper-2d-sprites-in-unreal-engine/)**
>
> Description of Sprites in Unreal Engine and how to create them.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

Hope this helped! Cheers!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41948240](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41948240](https://forums.unrealengine.com/u/anonymous_user_41948240)\
**Post date:** [May 6, 2015, 5:10pm UTC](https://forums.unrealengine.com/t/create-sprite-component/317283/5 "2015-05-06T17:10:43Z")

</div>

That wasn’t quite what I was hoping for. Couldn’t I just attach the sprite like a mesh or an audio source to my class (derived from APawn)? I mean it works in blueprints where I can simply drag a sprite into the components view.
