// Update is called once per frame void Update() { if (!shouldPan) { return; } if (onTrack) { var targetLocation = nextStop.transform.position; var nextLocation = Vector3.Lerp(Camera.main.transform.position, targetLocation, 0.01f); Camera.main.transform.position = nextLocation; if (AlmostEquals(targetLocation, Camera.main.transform.position)) { index++; if (index > track.Length) { onTrack = false; AliceMovement.EnableMovement(); return; } if (index < track.Length) { nextStop = track[index]; } else { nextStop = track[0]; } } } }
// Use this for initialization void Start() { if (hasStarted) { shouldPan = false; return; } AliceMovement.DisableMovement(); if (track.Length > 1) { nextStop = track [1]; index = 1; onTrack = true; } else { AliceMovement.EnableMovement(); onTrack = false; } hasStarted = true; }