- Home /
hi!does any know how to make an endless track
my head is burning now ... please help me out :'( .. how do we create endless road. what i am doing is, i have created three objects which are path1, path2, path3 prefabs, what i want is just to repeat the paths randomly to make the endless randomly generated path. when my game start it randomly pick the path and third person start running on it,... i tried it OnTriggerEnter function to instantiate the prefab path
#pragma strict
var prefabs: Transform;
function OnTriggerEnter(){
Instantiate (prefabs);
}
it create the prefeb but its not like never ending and we create the position by ourself. kindly help plz .. Thanx
Answer by 09millarda · Jan 09, 2014 at 06:41 PM
On the start of the layout I would create a road of maybe 3 or 4 straight paths (depending on how long your road pieces are) and then calculate how long it takes for the person to run one of the roads and then create a function that creates a random number between 0 and 2. Depending on what number has been chosen, a road segment is created at the correct position. Instead of timing how long it would take to run a road segment you could put an invisible cube that detects collision and calls a function that does what I wrote above. To save RAM, you can delete the road segments that hit a gameobject behind the running player.
actually i created three path which are positioned one after another, all are prefabs and invisible in the editor. when person collide with its coolider it generate another path,then when i move to second it create 3rd. i can destroy the last 2 objects as well . but when person move to 3rd path what i want is to repeat the cycle..like this.... link text
is there any proper tutorial or can you code your solution. i am not a good coder. second logic which i thought is to save your prefabs in an array and then instantiate(prefab.random.range)... it instantiate random prefab but on there positioned location, what i want is to instantiate in auto positioned. one end second start , second end then either one or third start ...:/ ... :( ..
it is easier to just move the paths... no need to create them and destroy them, like temple run
actually i want to repeat the the path so the last path have to be deleted .... because its endless and continuous... as we have in the subway surfer ... i have managed that :) .... my path creates and one ends second start ... but now i am on the next problem ;( ... my third person doesn't collide with any obstacle rather it moves through it ... :/ ... what i want when it collide with the obstacle, obstacle should drag it backward and it should fall down from the path or stop the game... :/ any idea ? i have applied box collider on the obstacle
while inside collider or their bounds collide, change surfer speed, reduce it or make it stop, fall or bump, as you wish, just throw some code
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Simple Tile Map 0 Answers
Generate a continuos platform for endless runner 3 Answers
Muzzleflash help 0 Answers