Create obstacles procedurally

  • I'm trying to make an infinite runner like Canabalt.

    I know how to make a paralax effect for the background, but have no idea about how to create the random obstacles and ground.

    What would be the best way to do it?

    I have a little idea, maybe the player doesn't move and it only jumps, but the platform and obstacles create the sense of movement and I'll have to do some calculations to create holes that the player can jump, but I dont know how.

  • First create several different types of platforms you want the player to land on while running.

    next, using the system (every 1 second or something) to spawn new objects.

    Set their X position to just beyond the .x of the layout of the screen so that they will start off screen.

    Next use a system every tick event to move the platforms back in -X towards the player at whatever interval you want (probably a variable that will increase over time to speed up the buildings.

    Then lock the player's jump so that its only up and down and they can't move left and right.

    to separate the platforms so that they get created at a variable distance, set that original random timer you used to spawn the platforms to a setting like random(5) seconds. This way, some will be further apart and some will be closer together. Make sure the maximum distance apart isn't too big for the player to jump though. Also you will probably need to add another variable to that as the speed increases because the gap the player crosses will get bigger and bigger as the speed of the platforms come towards them.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Wow that's fantastic! :D

    I just bought the standard version of Construct 2 to be able to publish to IOS/Android and use families.

    But using dt i've found a new problem:

    The objects appear at minimal diferent distances and I can't use Wrap behaviour because it interferes with other things i'm planning to do.

    What do you recommend to avoid those gaps

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)