Quantcast
Channel: Questions in topic: "die"
Viewing all articles
Browse latest Browse all 115

How do I stop the enemy ai from following the player after it dies on unity3d properly in C#

$
0
0
When I shoot the enemy ai the animation plays . But the problem is that the enemy ai follow the player after it dies . Here is the move and attack script : using UnityEngine; using System.Collections; public class Enemyai : MonoBehaviour { public Transform player; static Animator anim; public NavMeshAgent nav; void Start () { anim = GetComponent (); } void Update () { if (Vector3.Distance(player.position, this.transform.position) < 13) { Vector3 direction = player.position - this.transform.position; direction.y = 0; this.transform.rotation = Quaternion.Slerp (this.transform.rotation,Quaternion.LookRotation(direction), 0.1f); anim.SetBool("isIdle",false); if(direction.magnitude > 2.6 ) { nav = GetComponent (); nav.SetDestination (player.position); anim.SetBool("isMoving",true); anim.SetBool("isAttack",false); } else { anim.SetBool("isAttack",true); anim.SetBool("isMoving",false); } } else { anim.SetBool("isIdle",true); anim.SetBool("isMoving",false); anim.SetBool("isAttack",false); } } }

Viewing all articles
Browse latest Browse all 115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>