How do I stop colliders from going against each other / The enemy ai and player wont stop going against each other
I have a collider attach to the player and it's not trigger . I have a nav mesh agent attach to the enemy ai . When the player enter the enemy ai radius the colliders go against each and its hard for the player to get away from the enemy ai when it near . I did some test I found out the is only the nav mesh agent causing this problem . I am really stuck on this problem . How do I get around this ?
Comment
I don't use nav mesh . This is what I have now :
using UnityEngine;
using System.Collections;
public class Enemyai : $$anonymous$$onoBehaviour {
public Transform Player;
Animator anim;
void Start ()
{
anim = GetComponent<Animator> ();
}
public void Stop(){
anim.SetBool("is$$anonymous$$ove", false);
anim.SetBool("isAttacking", false);
anim.SetBool("isIdling", true);
this.enabled = false;
//Or if you want to destroy the AI script completely
//Destroy(this)
}
void Update ()
{
float speed = 0.9f;
if (Vector3.Distance(Player.position, this.transform.position) < 10000f)
{
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("isIdling",false);
if(direction.magnitude > 1 )
{
this.transform.Translate(0,0,0.15f);
anim.SetBool("is$$anonymous$$ove",true);
anim.SetBool("isAttacking",false);
}
else
{
anim.SetBool("isAttacking",true);
anim.SetBool("is$$anonymous$$ove",false);
}
}
else
{
anim.SetBool("isIdling",true);
anim.SetBool("is$$anonymous$$ove",false);
anim.SetBool("isAttacking",false);
}
}
}