I am developing a game in which I want infinity road, So I created 40 instances of the road which I want to repeat again and again.
I am writing the following code to change the position of road that is not visible in the camera now and can be repeated
roadPaths[currentRoad].transform.Translate(Vector3(0,0,startPositionValue));
But I am getting the following log
In the above log you can see when the startPositionValue is 42, currentRoad position becomes 43. Same issue is with other values as well.
A help will be highly appreciated.
Translate is a relative move of the GameObject in three-dimensional space. It literally translates it from the current position by a relative value to a new position that is an offset from the original.
Explicitly setting the Position vector of the GameObject's Transform will set it to an absolute position within the world.