// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); moveScript = player.gameObject.GetComponent <MovementController>(); splineScript = splineScript.GetComponent <SplineController>(); if (WaypointList.Count > 2) //just to prevent the thing from giving null ref error if the list is too small { lastWayPoint = WaypointList.Count - 1; } }