Download

Adding sprite components via Blueprint

Hello,

I’m trying to re-create the blueprint in this tutorial only using Sprites instead of Static Mesh.

Instead of using Add Static Mesh, I tried using Add PaperSpriteComponent but that only takes a variable type called PaperSpriteActor and I can’t use Set Sprite.

fc0e2e965b7937c938c80c68b3f2f19b0dc15215.jpeg

I can’t connect PaperSpriteComponent var to the “Add PaperSpriteComponent” box on the top right, but the title makes me think it should take them.

Am I doing something wrong? Is this a bug? Help!

I think that is design to do this purposefully.
You just wire things wrong.
Wire like this screenshot should work for you.
c1a344216923267437241d45ad01181292c9a000.png

よろしく!

Hello PenguinTD,

Thank you for your reply!

1 sprite shows up, but it doesn’t add more sprites between root and end point. :frowning:

I guess Add Sprite isn’t meant to draw more sprites the way add static mesh will render new meshes.

ありがとうございます!

Hi haruna,

Add PaperSpriteComponent can be used in exactly the same way as an Add StaticMeshComponent node. The example from Penguin only adds one sprite, you’d need to use it in a for loop or otherwise call it multiple times if you want to make multiple components.

To edit the component template that an Add Component node uses, select the ‘Add Component’ node in the graph, and edit the properties in the Details panel in the bottom left. This is where you set the kind of sprite or mesh or etc… to spawn. You can always change it later using Add Sprite like Penguin demonstrated too.

Note: You can also drag-drop a sprite asset or mesh or whatever from the content browser directly into the Blueprint graph, which will create an Add Component node already pointing to the asset you want to spawn.

Cheers,
Michael Noland

Hello and thank you for your reply, Mr. Noland!

I got the blueprint adding sprites but unfortunately, when I move the end point back towards the root, instead of eliminating the sprites it just adds more and more. Went from not adding enough sprites to way too many! :rolleyes:

Is it an attachment issue? Do I need to remove sprites every time the end point moves?

I did something like this a while ago, but in geo. ie. to spawn child actors in between start/end point. works fine but I manually setup how many of them I want.
I wonder what you would have if you actually hits simulate/play? If it works fine, then it might just be a bug you found for construction script for paper sprite component.
Because any changes you made in editor should trigger construction script, in this case it should reconstruct the BP so all the dynamically generated component should be destroyed before new ones gets generated.

Hello all! I m trying to make a 2D terrain made of destructible sprites with this procedural scripts. Its work to generate the sprites in the right location but when I try to destroy one brick the engine consider all the bricks as just one and all then take damage and explode… there is a work around for this?

Thank u Guys!

MG

@mgondim , it’s better to use GroupedSpriteComponent , you can check my “Destructible Tiles 2D” example it may help you !

Hey @Mhousse1247 thank u for your answers… this is so cool that u are give away your code. I appreciate. But What I m looking to accomplish is load like 1000 terrain sprites procedurally for make bigger terrains and make this for a lot of levels so I don’t intend to make this one by one and group the sprites… I even don’t know if is possible to load “instanced sprite” like we can do with “static meshes”…

Btw, I just visit your site! Its amazing, gratz and thank!

You can use AddInstance to add any sprite you want ( it’s not like with meshes where you have only on mesh asset)
Also if you use 1000 * AddSpriteComponent , you will have 1000 draw calls in your scene and it’s not optimal at all , but with GroupedSpriteComponent sprites sharing the same texture will be batched in one draw call

I was looking for this “one” magic draw call… With groupedSpriteComponent I should mount one by one?
How is possible to make a huge 2d terrain with sprites with no draw calls problem? There is not a workaround for this? The only way to have a destructible “2d tilemap” is using sprites?
There is a way to load a lot of sprites and after this try to merge then by bpscript on the runtime?

Sorry for my english and stupid questions…

@MGONDIM