/// <summary> /// Sets the destination if it was not already set. /// </summary> /// <param name="dest">Destination for the object.</param> public void SetDestination(Vector3 dest) { if (destination == null) { destination = new DestinationWrapper(); } destination.destination = dest; }
// Update is called once per frame void Update() { if (destination != null && !moveFinished) { if (transform.localPosition != destination.destination) { moveFinished = false; transform.localPosition = Vector3.MoveTowards(transform.localPosition, destination.destination, MoveToDestination.speed * Time.deltaTime); } else { moveFinished = true; destination = null; } } }