Search Unity

how to get loop a level in endless runner game

Discussion in 'Scripting' started by Drowned_horse, Jun 22, 2020.

  1. Drowned_horse

    Drowned_horse

    Joined:
    Jun 22, 2020
    Posts:
    2
    im building an endless skiing game and ive designed a level that i want to loop over and over again. my understanding is we can do this by getting both the initial position of the player, and its final position
    (or last platforms tag/name?) when it has reached the last platform, and teleport the player back to the beginning of the platforms. But i do not know how ill be able to get these values and implement them.
    i am a complete newbie to game development and programming as a whole, so if someone provides some code and/or suggests a better way to to this ill be really thankful.
     
  2. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    you just need to check the transform.position
     
  3. johne5

    johne5

    Joined:
    Dec 4, 2011
    Posts:
    1,133
    Hi Drawned_horse,
    What I've done in the past is.
    I created 4 sections of the level. I added a collider set the Trigger = true. and then the when the player hits the trigger it moves that section to the end of the level.

    So you need a few things.
    2 or more sections (prefabs) the more you have the more variations in the level the player will have to adjust too.
    Each section needs to have a collider set to trigger. I picture the collider being set past the section. you don't want the player to see the land disappear under his feet.
    You need a script to move the section when the trigger is hit.
    https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html