Some problems I have encountered for endless runner
FastlaneSuccess
Member Posts: 46
I made my ground platform go from right to left endlessly. Took a while.
So I wanted to do the same for my trees, clouds and other things.
1) How do I prevent a newly spawned tree overlapping itself or another tree?
2) How do I stop the tree spawning multiple times?
For example: On Spawn Actor I did --> random (400, 600)
Comments
Have you tried a simple collide so when they overlap they collide with each other pushing them apart?
@FastlaneSuccess,
Why don't you try something like this for spawning the trees separately. If your trees are, say, 40 pixels wide, then spawn them at x = (random(0,4)*40)+400, y = whatever the floor is. Increase the 400 or the 40 if you want some space between the trees, but that will sometimes result in a value over 600; something to keep in mind.
For the "spawn multiple times" problem, create some boolean like TreeSpawned, then a rule that if TreeSpawned = false, then spawn the tree, otherwise do nothing. That will be one lonely tree, unless you interlace the above with a timer or another rule allowing more than one spawn until TreeSpawned = true.
My Blog / App Store / Google Play
Ok, I went by JC's video for endless runner:
I already made the Boolean Spawned.
Rule
- Attribute self.Position.X less than or equal to 617
-Attribute self-spawned is false
-Change Attribute: self.spawned to true
- Spawn Actor
(-->) (random(0,4)*40)+400)
Spawned Boolean is unchecked.
I have one tree that is starting on the screen. After that one gets destroyed, no trees are spawned anymore
I just put it in and yes it works for the most part, but sometimes there is one tree that slightly overlaps the other
@FastlaneSuccess ,
Here's a very simple tree spawner.
https://mediafire.com/?197trmeg9odz463
It has a Spawn Handler and a Tree, plus some visual guides 40 pixels wide. Every x seconds, a tree spawns at a random position between 400 and 600. Based on the existing tree speed and timer value, there should be no overlap.
If you want to change the game (speed up, slow down, other feature), then I suggest something like the following. You could either:
My Blog / App Store / Google Play
Thanks so much, this method is much simpler than the one I learned.
I got another question.
When my player jumps on the platforms, the endless ground drop down a bit. This causes my player to get stuck since he collides with the ground.
Weird. On the ground, Movable should be unclicked.
My Blog / App Store / Google Play
First thing I tried, but then it couldn't move across the screen