Waypoints using a Switch...

I got script that chooses a new way-point when its triggered. It currently works but the clones that are spawning instantiate with another clones way-point and not the default way-point 0. How can I make each clone not effect each other?

private var waypoint = 0;

function OnTriggerEnter (other : Collider) {
	if (other.CompareTag("WayPointCube")){
		spot = Random.Range(0,2);
		Debug.Log("Hit");
		switch(spot){
			case 1:
				waypoint = 2;
			break;
			
			case 2:
				waypoint = 1;
			break;
			
			case 0:
				waypoint = 0;
			break;
			}
		}

Try setting the line “private var waypoint = 0;” inside the Awake function of the script attached to the clone prefab.

Quite certainly, what happens is that somehow all instances are ‘sharing’ the waypoint structure.

Since I guess you’re using a script that’s attached to a gameobject in the scene, and you somehow use that gameobject for all your instances… well, since there’s -one- instance, there can be only -one- waypoints list!

The answer to your question is: create a “prefab out of the waypoints” and pass it as a “parameter” to your gameobjects after creation.