Search Unity

  1. Going to #UniteBerlin? Bring a buddy & get 25% off the 2nd ticket! More info here.
    Dismiss Notice
  2. Famed game designer and creator of The Sims, SimCIty, and Spore is looking for a 3D artist to join their team. Join the challenge.
    Dismiss Notice
  3. Unity 2017.4 has arrived! Read about it here.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. We've opened a new World Building sub-forum to faciltate all your world building discussions! Drop in and ask any ProBuilder, ProGrids, or PolyBrush questions.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

How to start Infinite Runner game Development.

Discussion in 'Getting Started' started by Meta-Studios, Apr 13, 2018 at 4:43 PM.

  1. Meta-Studios

    Meta-Studios

    Joined:
    Apr 30, 2014
    Posts:
    4
    I've been developing games for past four months just to get a good understanding on how Unity works, still a noob though. I want to try creating a Endless runner type game similar to Subway Surfers (how cliche!) for myself, just for practice. My question is what's the best way to set it up? The game has 10 levels, lets just call it sections, that spawn one after the other (in random order) each containing obstacles and other stuff, that are either pooled or manually placed. Do I create each section as new Levels and then load new levels with triggers or should I create a Gameobject that contain all the objects for the particular level?

    If I go with Separate levels for each sections, The game freezes a bit before a new level is loaded and the whole setup way is way complicated for me at this point.

    If I go separate Gameobject for each sections; some section are, lets say, 100 world units and some are just 50 and some even less. How to make each gameobject to spawn at the end (I can use boxcollider to get the collider size) of the section?

    Sorry I've asked a lot questions here, but i've been having sleepless nights trying to figure this.

    Thank you in Advance.
     
  2. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    3,499
    As far as I know, subway surfers levels are built on-the-fly in a straight line. The player stays at (0,0,0) and the level gets moved backward, and the levels are deformed into curves by vertex shaders according to the world z position. I made a runner for fun this way some time ago, so I know it works.

    So you just need to determine the rules that the level is built with, and create only as much as the player can see.
     
    Meta-Studios and angrypenguin like this.
  3. THoeppner

    THoeppner

    Joined:
    Oct 10, 2012
    Posts:
    202
  4. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    6,131
    I think the best way to go would be each section is a scene and the UI/player is it's own scene or scenes then you load in the next scene asynchronously ready to be used and delete/hide-recycle the last scene (this would be memory/performance dependent so test on target hardware).

    Using scenes would get around the clunkyness of nested prefabs (e.g. you have streetlight prefabs along a road prefab and want to change some of them).

    You would have to ensure the scene have a single root transform so you could move them easily as I think they would load by default at position 0,0,0?
     
    Last edited: Apr 14, 2018 at 3:56 PM
    Meta-Studios likes this.
  5. Sailendu

    Sailendu

    Joined:
    Jul 23, 2009
    Posts:
    107
  6. Meta-Studios

    Meta-Studios

    Joined:
    Apr 30, 2014
    Posts:
    4
    Yes the default position is at 0,0,0. I did not know about "asynchronous" scene loading. I tried before without it, every time a scene loads, it kinda freezes before it loads the new level.
     
  7. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,401
    We developed Top Gear: Race the Stig, a 3-lane infinite runner similar to Subway Surfers.

    All the sections (chunks we called them) are in one scene. Each chunk is a hierarchy of game objects. The chunks are pooled and there are multiple instances of each. The player remained at x=0 z=0 and the chunks were pulled from the pool, moved from beyond the far clip plane towards the player (Z axis) and then returned to the pool once behind the camera. Chunks were moved in the X axis as the player changed lanes. The player could move in the Y axis (jumping, etc).
     
    Meta-Studios likes this.
  8. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    6,131
    Last edited: Apr 16, 2018 at 5:48 PM
    Meta-Studios likes this.
  9. Meta-Studios

    Meta-Studios

    Joined:
    Apr 30, 2014
    Posts:
    4
    Thank you. So each "Chunks" contains all the obstacles and stuff in them? and are they placed manually or randomly pooled? Are all the chunks are same size (Z axis)?
    How did you place next chunk at the end of current chunk? This is something I've been working on for a while, but couldn't figure out.

    BTW Race the Stig looks awesome!
     
    Last edited: Apr 17, 2018 at 9:03 AM
  10. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,401
    Thanks.

    I just opened the project for the first time in a couple of years to remind myself how it works - it doesn't even run now :-(

    The chunks are variable sized (length). They act as placeholders really. See image below. The squares represent where the scenery props will go (5 left, and 5 right in this example). The scenery props will be picked from a pool at random. The black object are obstacle props - some static, some dynamic. They're not supposed to be black btw, just some sort of bug due to a newer Unity version. The position of the dynamic ones is driven off the chunk's position, e.g. as a chunk moves towards the player at (0,0) a car will move towards the player at a different speed (it's position relative to the chunk is changing). The obstacles are also picked randomly from a pool, but the type is predefined, e.g. it's always a truck, but the appearance of it will change. The yellow boxes are where collectable nuts (like coins) are placed.

    The chunks themselves are randomly picked and spawned. Yes it's all done on the Z axis. If you know the last chunk's position and length, then you know where the next chunk needs to be positioned.

    Chunk.PNG

    Scenery Props. Note that the actual road is part of the left hand props. The left and right props will be picked at random so they won't necessarily pair up like show here.

    Scenery Props.PNG

    Obstacle Props. Various static and dynamic objects that go on the road.

    Obstacle Props.PNG
     
    Meta-Studios likes this.
  11. Sailendu

    Sailendu

    Joined:
    Jul 23, 2009
    Posts:
    107
    Thanks for posting this info here, I like the idea of keeping the road attached to the left so that the pairing will not be same everytime. I just downloaded the game from the App Store, nice game. I like how the curve changes from left to right sometimes and not just curved towards the left like other similar games. Do you have any plans for updating the game for iPhone X?
     
  12. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,401
    I doubt it will be ever updated again.
     
  13. Meta-Studios

    Meta-Studios

    Joined:
    Apr 30, 2014
    Posts:
    4
    Thank you very much for posting. These are very useful information. Any plans to release this In Unity Asset Store?
     
  14. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,401
    No.