Hey guys , so i have an issue with endless runner , so i have a prefab of map which is instantiated when player touches the trigger.
So the thing is , i don’t know how to make it spawn correctly , i tried taking position of first instantiated prefab and add it’s length, but , map itself moves , so it changes it’s x position every second , also i have “gas pedal” button (when pressed ,map’s speed movement increases), and because of that i have a gap between instantiated maps
Usually gap’s size differ ( because of speed) , here’s my code:
distance = Instantiated.transform.position.x ;
void OnTriggerEnter(Collider other)
{
if (other.tag == “Player”)
Instantiated = Instantiate(swapped, new Vector3(distance + 90, 0, 0), Quaternion.identity) as GameObject;
}
Any type of help would be really appreciated!