Skip to content
Snippets Groups Projects
Commit 963ca6c9 authored by Aji Andhika Falah's avatar Aji Andhika Falah
Browse files

fix: pet move

parent 66644801
Branches
Tags
No related merge requests found
......@@ -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){
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment