Some problems I have encountered for endless runner

FastlaneSuccessFastlaneSuccess Member Posts: 46
edited April 2015 in Working with GS (Mac)

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

  • UtopianGamesUtopianGames Member Posts: 5,692

    Have you tried a simple collide so when they overlap they collide with each other pushing them apart?

  • mhedgesmhedges Raised on VCS Member Posts: 634
    edited April 2015

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

  • FastlaneSuccessFastlaneSuccess Member Posts: 46
    edited April 2015

    @mhedges said:
    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.

    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

  • FastlaneSuccessFastlaneSuccess Member Posts: 46

    @DeepBlueApps said:
    Have you tried a simple collide so when they overlap they collide with each other pushing them apart?

    I just put it in and yes it works for the most part, but sometimes there is one tree that slightly overlaps the other

  • mhedgesmhedges Raised on VCS Member Posts: 634

    @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:

    1. Have the visual guides repositioned and use them as triggers for stopping a random spawn where the guide is overlapped/collided by the tree, or
    2. Create variables to handle the trees' x position, and if that "position is occupied", spawn elsewhere.
  • FastlaneSuccessFastlaneSuccess Member Posts: 46

    @mhedges said:
    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:

    1. Have the visual guides repositioned and use them as triggers for stopping a random spawn where the guide is overlapped/collided by the tree, or
    2. Create variables to handle the trees' x position, and if that "position is occupied", spawn elsewhere.

    Thanks so much, this method is much simpler than the one I learned.

  • FastlaneSuccessFastlaneSuccess Member Posts: 46
    edited April 2015

    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.

  • mhedgesmhedges Raised on VCS Member Posts: 634

    Weird. On the ground, Movable should be unclicked.

  • FastlaneSuccessFastlaneSuccess Member Posts: 46

    @mhedges said:
    Weird. On the ground, Movable should be unclicked.

    First thing I tried, but then it couldn't move across the screen

Sign In or Register to comment.