/// <summary> /// Checks if the car has traveled all the way and whether it can be removed /// </summary> private void CheckRemovingCar() { if (Vector3.Distance(transform.position, CurrentPath.GetControlPoint(CurrentPath.ControlPointCount - 1)) <= 0.05f) { Destroy(gameObject); } }
/// <summary> /// Sets road, initial position and start/stop time for car /// </summary> private void Start() { Road = GameObject.FindWithTag(RoadTag).GetComponent <Road>(); CurrentPath = Road.commonPath; transform.position = CurrentPath.GetControlPoint(0); //stop time 2f SetStartAndStopTime(moveSpeed / 10f, moveSpeed / 3f); }