Hello guys im trying to create my first game 2D but i face some troubles…
I have made 3 prefabs of 1)small ground 2)medium ground 3)big ground
i have set my player to move to the right with some speed and the purpose of the game is to jump at these ground and try to make the best time without to fall out of them… like a jetpack…
now i want my smallground to instantiate it and as the player moves i want more grounds to generate automatically in random range… so far i wrote this code… but the problem with this code is that it generates only 1 small ground at random range and not lot of them …
my code:
#pragma strict
var smallG: Transform;
function Start () {
var position: Vector3 = Vector3(Random.Range(-10.0,10.0),0,Random.Range(-10.0,
``10.0);
Instantiate(smallG, position, Quaternion.identity);
}
function Update () {
}
what i have to add so to create gorunds all the time?
and second question i made the idea for this code from the scripting reference… but i dont know why i put the code in the start method and not to the update method?