// Update is called once per frame void Update() { if (!didIt) { if (Vector3.Distance(myTransform.position, target.position) < range) { didIt = true; Debug.Log("Switching car modes"); controller = car.GetComponent<UnityStandardAssets.Vehicles.Car.CarController>(); GetComponent<AudioSource>().PlayOneShot(Leviosa); controller.switchMode(); } } }