diff --git a/Assets/Scripts/Pets/PetMovePassive.cs b/Assets/Scripts/Pets/PetMovePassive.cs index 0f8a46559f2f35adf7e1f713e84c9ed957ca3670..66e0044e2ab70231fcd68ad3b2f61545d8d0a396 100644 --- a/Assets/Scripts/Pets/PetMovePassive.cs +++ b/Assets/Scripts/Pets/PetMovePassive.cs @@ -6,6 +6,7 @@ public class PetMovePassive : MonoBehaviour { Transform player; UnityEngine.AI.NavMeshAgent nav; + bool move; private void Awake () @@ -13,13 +14,14 @@ public class PetMovePassive : MonoBehaviour player = GameObject.FindGameObjectWithTag ("Player").transform; nav = GetComponent <UnityEngine.AI.NavMeshAgent> (); nav.enabled = true; + move = true; } void OnTriggerEnter (Collider other) { if(other.gameObject == player) { - nav.enabled = false; + move = false; } } @@ -27,7 +29,7 @@ public class PetMovePassive : MonoBehaviour { if(other.gameObject == player) { - nav.enabled = true; + move = true; } } @@ -35,10 +37,14 @@ public class PetMovePassive : MonoBehaviour { if (!GameManager.isPause) { - if (nav.enabled == true) + if (move) { nav.SetDestination (player.position); } + else + { + nav.SetDestination (transform.position); + } } if(GameManager.isPause){