private void WaypointReached() { currentWaypointIndex++; if (currentWaypointIndex == track.WayPoints.Count - 1) { OnReachedFinalWaypoint?.Invoke(this, null); this.enabled = false; return; } previousWayPoint = track.WayPoints[currentWaypointIndex]; nextWayPoint = track.WayPoints[currentWaypointIndex + 1]; // Begin rotating towards the next waypoint targetRotation = Quaternion.LookRotation(new Vector3(nextWayPoint.position.x - playerCenter.position.x, 0, nextWayPoint.position.z - playerCenter.position.z)); initialRotation = playerCenter.rotation; }
private void ReachedFinalWaypoint() { step = -1; OnReachedFinalWaypoint?.Invoke(); }