For some reason, even though I set transform.position, my cars/trucks/logs keep instantiating in the center of the lane. The transform.position and transform.rotation inputs don’t seem to be absorbing the position and rotation of the car prefab. Could you tell me what I’m doing wrong?
public class ObstacleSpawner : MonoBehaviour {
public GameObject Obstacle;
public float SpawnInterval = 4;
public float WaitTime = 0;
public float DestroyTime = 12;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Time.time > WaitTime)
{
Spawn();
WaitTime += SpawnInterval;
SpawnInterval = Random.Range(1, 6);
}
}
void Spawn ()
{
var newObstacle = Instantiate(Obstacle, transform.position, transform.rotation, transform);
Destroy(newObstacle, DestroyTime);
}
}