Infinite Runner : How to do a random and infinite road

Hello everyone !
I’m new on Unity and scripting so I need some help with the project I want to do.
I want to do an infinite runner like “Minion Rush” or “Temple Run” but I don’t know how to generate a random and endless road. I’ve search some tutorial but there are not many, and they didn’t explain how to do it step by step. Can somebody help me ?

http://lmgtfy.com/?q=unity infinite runner

first result
http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/infinite-runner

… and many many more after that.

If you’re new and don’t understand the technicalities of whats in that tutorial you may need to watch the other tutorials in the learn>beginner section (Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn)

Thank you for your reply but I have seen much of this results :smile:. Furthermore, my game is in full 3D. I have roads which curve, and roads which turns into two different directions. This is why I ask some help. Some people in the forum who ask help give some piece of script, not full script and this is why I don’t understand.
But thank you for your fast reply :slight_smile:

ok. Look at your first post, paraphrasing it reads;

I’m new, “I want to clone game x”, I’ve looked but I can’t find anything. Help me.

Very open ended, light on details, hard to answer and it gives the impression nothing has been done so far. So you’re pointed at the basics. We see these every day from people who have downloaded unity, can’t figure it out and hit the scripting forum expecting someone else to make the code for them, when they should hit the learning sections to learn some of the basics.

If this isn’t the case and you have built something and you need help with something a bit more specific, give us the details of where you are stuck, examples of how you are achieving things already and the community will help.

If you’re struggling with the curved paths you might want to check out this thread, fair few ideas in there:

1 Like

You want to clone temple run? sure, But I don’t understand why you can’t find any resources to help you with that? there are tons of temple run clones around these forums.

A quick search lead me to this: GitHub - kenmaz/TempleRun-Unity: TempleRun clone with Unity
thats the entire source code to a clone. STUDY IT! :slight_smile:

Here’s what I did for one I’m working on (there’s a link to the Work In Progress thread in my signature). First I made a 3D model for each segment. Then, I placed copies of each in the scene, well below the player (the player moves at a constant height in my game). An empty GameObject in the scene has a LevelManager script that controls level generation, inside of which there’s a method to generate the initial track. It’s written below in pseudocode instead of the actual code I used, mainly so it doesn’t require any particular syntax.

I also have an invisible collider in the scene, set to isTrigger. When the player passes through this, it informs the LevelManager, which then updates the track. The track updating method works similarly to below.

Define a public list of GameObjects, templates - this holds the pieces.
Define a private list of GameObjects, currentPieces - this is the current track
Define a private list of GameObjects, possiblePieces - this is any piece that is not currently in currentPieces.
Define a public TrackUpdater, updater - I have this as a separate script.

// the method begins here
Set possiblePieces to equal templates;
Set the first two pieces to be straight segments - just so the player has a bit of room to prepare
Add these pieces to both currentPieces, and remove them from possiblePieces
FOR LOOP with 8 increments:
    Select a random piece from possiblePieces
    Put it at the end of the track
    Add it to currentPieces, and remove from possiblePieces
END FOR
Move updater to the midpoint of the track.

Hope this is helpful.

Thank you Philip, this is what l’m looking for =) an explanation about how it works
I have two script but it was full of term that i didn’t know and without descriptions, I was lost.
I prefer understand exactly what I code rather than copy and past.
In this way, I understand how it works It’s a bitter clear =) Thank you for explaining me, I will try it now =)