Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 JYatesAccordion), my character is already constantly running to the right, I just don't want the same level every time. :)

Product Version: UE 4.8
more ▼

asked Jan 07 '16 at 03:03 PM in Using UE4

avatar image

35 6 13 18

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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!

more ▼

answered Jan 07 '16 at 08:34 PM

avatar image Denathorn Jan 28 '16 at 11:01 PM

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?

avatar image Matthew J Feb 01 '16 at 07:17 PM

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.

avatar image Denathorn Feb 01 '16 at 07:24 PM

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

avatar image Denathorn Feb 01 '16 at 07:37 PM

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.

avatar image Matthew J Feb 01 '16 at 07:49 PM

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.

avatar image Denathorn Feb 01 '16 at 07:53 PM

Alright, let me give that a shot...

avatar image Denathorn Feb 01 '16 at 07:56 PM

Is this what you mean?alt text

screenshot (10).png (339.9 kB)
avatar image Matthew J Feb 01 '16 at 07:58 PM

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.

avatar image Denathorn Feb 01 '16 at 07:59 PM

Ah - thank you!

avatar image Denathorn Feb 01 '16 at 08:01 PM

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

avatar image Denathorn Feb 01 '16 at 08:03 PM

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

avatar image Denathorn Feb 01 '16 at 08:05 PM

Herealt text's what I did.

screenshot (12).png (341.1 kB)
avatar image Matthew J Feb 01 '16 at 08:07 PM

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?

avatar image Denathorn Feb 01 '16 at 08:10 PM

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

screenshot (13).png (782.8 kB)
avatar image Matthew J Feb 01 '16 at 08:17 PM

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?

avatar image Denathorn Feb 01 '16 at 08:18 PM

Sure one second.

avatar image Denathorn Feb 01 '16 at 08:22 PM

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.

avatar image Matthew J Feb 01 '16 at 08:32 PM

You may want to try making the death volume a blueprint of its own instead of having it underneath all of these other components in this blueprint. It could be the hierarchy that is causing the problem. You would also either want to set the collision type to BlockAllDynamic or change your event to OnComponentBeginOverlap instead of OnComponentHit.

avatar image Denathorn Feb 01 '16 at 08:35 PM

Alright, I'll try those. I'm not sure how to add the separate blueprint to the other one, because it's randomly generated. Wouldn't I have to do that in the viewport of the original one?

avatar image Denathorn Feb 01 '16 at 08:50 PM

Well after some experimenting I finally got it to work! Thank you for your help!

avatar image Denathorn Feb 01 '16 at 07:58 PM

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!

avatar image Denathorn Feb 03 '16 at 08:40 PM

Hey, so one last thing - How can I make a record system that keeps track of your high score of coins collected? Just following the randomly generated tutorial you earlier recommended.

avatar image Matthew J Feb 03 '16 at 09:06 PM

You can find out how to do that through this tutorial. This particular set up is talking about storing lap times and best lap records but could be appropriated to a score system as well. You could also use it to track a "Longest time" which could be nice for an endless runner.


avatar image Denathorn Feb 03 '16 at 11:53 PM

Thanks. I watched the entire video you sent, however I found it hard to follow, because I obviously didn't watch the previous 8. Would you have any ways in a more simple format to have a record/high score system for pickups? Following the previous tutorial? I've got what you recommended for the pickup.

avatar image Matthew J Feb 09 '16 at 06:31 PM

This set up is about as simple as it can get. All it requires is to create a variable, add to that variable whenever picking up a pickup, if the total reaches an amount over the high score, then overwrite it whenever you add more score. You can then save it as he does in the 10th video and also output it via UMG as he does with the lap times.

avatar image Denathorn Feb 09 '16 at 11:30 PM

Thank you, I've actually tried this, and I didn't seem to succeed in doing that in a different format... Sorry if this get's too complicated for you, but would you mind maybe just taking a few screen shots of a blueprint that you can make with the 2d sidescroller? If not, that's fine, I'll just have to find something else.

avatar image Denathorn Feb 09 '16 at 11:40 PM

Here's what I've got. I also varied it a bit, so that's might be why... (It's a long story about why I named certain things what they are, so you might not want to ask :) ) How would you suggest to make this work?alt text

avatar image Matthew J Feb 10 '16 at 01:47 PM

I can't really see much in the second screenshot, but it doesn't seem like TotalBodiesMangled is being set anywhere. It needs to be incremented every time an enemy is defeated (at least that is what the name suggests.)

As for your Create Save Game Object node, I can see that nothing is actually being done there. Please be sure to watch the 10th video in that Time Attack series as it explains how to use Save Game Objects in Blueprints.

avatar image Denathorn Feb 10 '16 at 02:06 PM

Sure, I'll see what I can do.

avatar image Denathorn Feb 10 '16 at 02:08 PM

Where would you suggest to set the "total bodies mangled" node?

avatar image Matthew J Feb 10 '16 at 02:10 PM

Whenever your score should be increasing. If it is when an enemy is defeated, you should be able to set it in the same line of logic where the enemy is killed or destroyed.

avatar image Denathorn Feb 10 '16 at 02:15 PM

It doesn't seem to want to show up under the blueprint where it's destroyed... It's all right, I have to go now, so I'll be back around 5:00... Thanks for the help so far!

avatar image Denathorn Feb 10 '16 at 02:13 PM

As I'm watching, I see that he has a lot of things in the previous videos (save game check), are those necessary?

avatar image Matthew J Feb 10 '16 at 02:16 PM

It is just a custom function that you can create. It was empty at the beginning of the video so it shouldn't be an issue as long as you follow along. If you do find anything missing however, watching the entire tutorial wouldn't be a bad use of your time as it teaches a lot of various things that would be useful for any game designer to know.

avatar image Denathorn Feb 10 '16 at 11:20 PM

I appreciate the recommendation, but I'm running out of time for this to be done, I have a VERY strict deadline. Would it just be possible for you to compile something simple with the information with what I've provided?

avatar image Denathorn Feb 10 '16 at 11:21 PM

All I need is for it to keep track of the most "mangled bodies" in one run, and display that on screen, and on death screen/widget.

Thanks for your help!

avatar image Matthew J Feb 12 '16 at 02:50 PM

While we do strive to provide as much assistance as we can, we do not have the resources to create assets or projects for individual users. When it comes to cases like this, it is best to take the time to watch the tutorials as it will help you learn how to put these mechanics together for this instance for future projects.

avatar image Denathorn Feb 12 '16 at 05:49 PM

Alright, well thanks for the help anyway.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question