Can I make 2d sprites random generate in a level?

For an endless, unique game every time you play? I already have the “platformer” blueprint (Thanks to ), my character is already constantly running to the right, I just don’t want the same level every time. :slight_smile:

Hello Denathorn,

While this tutorial is in 3D, it should give you an idea as to how you could go about randomly generating levels in any aspect. Most of this, if not all of it, can be translated to 2D.

Let me know if you have any questions, I hope this helps!

Thank you for answering, and sorry it took a while for me to respond. I have actually watched this particular tutorial many times, and I’ve tried translating into 2d sidescroller format, but haven’t quite been able to get it working, would you have any tips and steps on how to do this?

In the most simple way, you could set it up exactly as he is in the tutorial but move the camera so that it is facing from the side. You’ll also need to removing the part about turning/corners as those wouldn’t work in 2D. What kind of problems are you running into while you’re trying to translating it? I can’t just give a broad walkthrough because it would end up being as long as the tutorial series.

Nevermind! I got it working, thanks for the tutorial.

However, you could help me with something else. I need my character to die once it hits the “box” collision in one of my blueprint viewports, but I can’t seem to figure out how.

It would be best to explain what you’ve tried and what exactly isn’t working. The simplest way to do this would be to set up a OnComponentHit event in the blueprint with the box collision using that collision and then using the “Other Actor” pin to cast to your character’s class. On a successful cast, destroy the “Other Actor” and that should do what you’re looking to do.

Alright, let me give that a shot…

Is this what you mean?

So I did that, Except every time my randomly generated (Following the tutorial you recommended for that) piece of ground came on to the screen it destroyed my actor… halfway there i guess!

Connect the “As 2DSide Scroller Character” pin to the “Target” pin on “Destroy Actor” and yes, that should work. Otherwise, the blueprint itself will be destroyed when the character runs into it, instead of the character being destroyed.

Ah - thank you!

Hmm… the character seems to get destroyed whenever the ground gets on the screen… ?

Is it because the world is overlapping it, and therefor it’s getting destroyed because I have it set to “on component hit”?


's what I did.

The Destroy Actor node should be only be called when the player collides with the box. This is the reason for the cast node. If anything else collides with it, it should just fail the cast and do nothing. Are you sure the box isn’t too large and could be hitting the character from the start?

Here’s the box. Basically I want my character to fall down the hole and die.

I don’t see any reason this shouldn’t work correctly and I can’t see why the character would be destroyed immediately. Can you try moving the box away on the Y axis so that it’s impossible for anything to collide with it to make sure that the collision is the reason?

Sure one second.

Alright, a few things I noticed - It is currently set to “OverlapAllDynamic”, and also when I moved it away on the Y axis, I started dying when I ran into the “End trigger”(that’s what it’s named, so I can’t have mixed it up) (the box on top) so I have no idea, I’m really confused.