hello
i have an array that is called spawnpoints in my player object. it is 27 long
but now. how do i make the code that when i press the Q button it goes trough all the 27 objects. so it first goes to spawnpoint1 position and then to spawnpoint2 etc.
///on press q
for(int i; i < spawnPoints.Length; i++){
///this will run thru each spawnPoint
Position = spawnPoint[i].position;
}
You could set a flag to remember which was the last one used.
Something like:
int lastPosition = 0;
and then on keyDown “Q”:
currentSpawnPoint = spawnpoints[q % spawnpoints.Count];
q++;
These are just guidelines, not actual working code
i have this right now but it says unkown variable i
and the error Position does not exist in the current context
if(Input.GetKey(KeyCode.R))
{
for(int i; i < spawnpoints.Length; i++){
///this will run thru each spawnPoint
Position = spawnpoints[i].position;
}
}