![]() So the previously generated object will never move again. When you call the method the next time you lose the reference to the original object because you are creating another one that replaces the value held in trackObject. When this method is called you instantiate a new prefab (new instance of your object) and tell the object to move via (-Vector3.forward * ltaTime * trackSpeed) Here is what happens:Įvery update you make a call to: private void GenerateInfiniteTrack() The value of which track to move is overwritten every update(). Your track is not moving because the call to move it occurs only once at instantiation and never again. Return Instantiate(trackPieces) as GameObject ![]() (-Vector3.forward * ltaTime * trackSpeed) Could anyone tell me if I am doing it right please? How do I generate an infinite/endless track? Thanks in advance public GameObject trackPieces For some reason, the tracks instantiated at runtime are being generated at the same position and don't seem to move towards the player. I have created a script which aims at instantiating the prefab at runtime and moving the track towards the player (instead of moving the player). I currently have a cube as a player and another cube (prefab) as the track. I am new to unity and I am creating my first ever endless runner game.
0 Comments
Leave a Reply. |