I am trying to make the nav mesh obstacle work and I gotten this error Enemyai.cs(31,19): error CS1061: Type UnityEngine.NavMeshObstacle' does not contain a definition for
SetDestination’ and no extension method `SetDestination’ of type
The set destination is for to follow the player
Here is my script :
using UnityEngine;
using System.Collections;
public class Enemyai : MonoBehaviour {
public Transform Player;
Animator anim;
public NavMeshObstacle nav;
void Start ()
{
anim = GetComponent<Animator> ();
}
public void Stop(){
anim.SetBool("isMove", 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)
{
nav = GetComponent <NavMeshObstacle> ();
nav.SetDestination (Player.position);
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 > 2 )
{
this.transform.Translate(0,0,0.15f);
anim.SetBool("isMove",true);
anim.SetBool("isAttacking",false);
}
else
{
anim.SetBool("isAttacking",true);
anim.SetBool("isMove",false);
}
}
else
{
anim.SetBool("isIdling",true);
anim.SetBool("isMove",false);
anim.SetBool("isAttacking",false);
}
}
}