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

**URL:** <https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384>\
**Category:** Asset Creation\
**Tags:** sprites, random, unreal-engine, level, generated, question\
**Created:** [January 7, 2016, 3:03pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384 "2016-01-07T15:03:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [January 7, 2016, 3:03pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/1 "2016-01-07T15:03:42Z")

</div>

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. 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [January 7, 2016, 8:34pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/2 "2016-01-07T20:34:26Z")

</div>

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.

> **[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...

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [January 28, 2016, 11:01pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/3 "2016-01-28T23:01:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [February 1, 2016, 7:17pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/4 "2016-02-01T19:17:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 7:24pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/5 "2016-02-01T19:24:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 7:37pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/6 "2016-02-01T19:37:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [February 1, 2016, 7:49pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/7 "2016-02-01T19:49:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 7:53pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/8 "2016-02-01T19:53:51Z")

</div>

Alright, let me give that a shot…

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 7:56pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/9 "2016-02-01T19:56:17Z")

</div>

Is this what you mean?

 ![76875-screenshot+(10).png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/6/1/4616fd0893811fd9d940d0b50d9b0e56ee4e3960.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 7:58pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/10 "2016-02-01T19:58:05Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [February 1, 2016, 7:58pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/11 "2016-02-01T19:58:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 7:59pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/12 "2016-02-01T19:59:49Z")

</div>

Ah - thank you!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 8:01pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/13 "2016-02-01T20:01:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 8:03pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/14 "2016-02-01T20:03:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 8:05pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/15 "2016-02-01T20:05:46Z")

</div>

Here

 ![76879-screenshot+(12).png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/a/6/ea62b2323fce1f99fa8c1b32be5811610f43b30d.png)

's what I did.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [February 1, 2016, 8:07pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/16 "2016-02-01T20:07:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 8:10pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/17 "2016-02-01T20:10:03Z")

</div>

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

 ![76880-screenshot+(13).jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/c/3/dc389361dd7c2ed2386f9b5328ed58f8e22deb2c.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [February 1, 2016, 8:17pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/18 "2016-02-01T20:17:25Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 8:18pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/19 "2016-02-01T20:18:39Z")

</div>

Sure one second.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1086f6781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1086f6781](https://forums.unrealengine.com/u/anonymous_user_1086f6781)\
**Post date:** [February 1, 2016, 8:22pm UTC](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384/20 "2016-02-01T20:22:24Z")

</div>

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.

[Next page](https://forums.unrealengine.com/t/can-i-make-2d-sprites-random-generate-in-a-level/343384.md?page=2)
