// Update is called once per frame void Update() { Vector3 Direction = target.position - transform.position; //Calculate the direction from the animal to the target float distance = Vector3.Distance(transform.position, target.position); //Calculate the distance.. animal.Move(distance > stopDistance ? Direction : Vector3.zero); //Move the Animal if we are not on the Stop Distance Radius }
void OnDisable() { if (mCharacterMove != null) { mCharacterMove.Move(Vector3.zero); //When the Input is Disable make sure the character/animal is not moving. } OnInputDisabled.Invoke(); }
protected override void OnDisable() { if (mCharacterMove != null) { mCharacterMove.Move(Vector3.zero); //When the Input is Disable make sure the character/animal is not moving. } base.OnDisable(); }