Ok, so I am making an endless runner, and I am trying to make it so when the “player” object collides with a “marker” object it will spawn the next section of road (which contains another marker). All the road sections behind the player are deleted as they pass. My problem is that when the player collides with the marker, the next section of the road does not appear. I can’t figure out what I did wrong.
Here’s the Code:
using UnityEngine;
using System.Collections;
public class MarkerCollisionCheck : MonoBehaviour {
public GameObject objectToSpawn = null;
public GameObject spawnPoint = null;
public bool spawning = false;
void OnTriggerEnter(Collider other)
{
if(other.tag == "Player" && spawning == false)
{
spawning = true;
Instantiate(objectToSpawn, spawnPoint.transform.position, Quaternion.identity);
spawning = false;
}
}
}
Just in case I am misunderstanding, “Instantiate” spawns the object correct?
Notice that the “spawnPoint” is another object. If you need more information, just ask.
Thank You,
expat1999