Hi everyone!
I’m trying to move objects of an array. First I have created an instance of objects and work fine, but when i want to move that objects, don’t work for anything.
This is my code:
public float x, y, z;
public GameObject[] Vehiculos;
public float spawnTime;
public Transform[] spawnPoints;
void Start () {
InvokeRepeating ("SpawnController", spawnTime, spawnTime);
}
void Update(){
//THIS IS THE MOVEMENT AND DOESN'T WORK
foreach(GameObject vehiculos in Vehiculos ){
vehiculos.transform.position += new Vector3(x,y,z * Time.deltaTime);
}
}
void SpawnController () {
int spawnPointIndex = Random.Range (0, spawnPoints.Length);
Instantiate (Vehiculos [Random.Range (0,Vehiculos.Length)], spawnPoints [spawnPointIndex].position, spawnPoints [spawnPointIndex].rotation);
}
}