i am making a zombie shooter but when i try to make it so that the zombie wonders around when it can’t see the player i keep getting this error: “SetDestination” can only be called on an active agent that has been placed on a NavMesh. UnityEngine.AI.NavMeshAgent:SetDestination(Vector3) EnemyController:Wander() (at Assets/scripts/Enemy/EnemyController.cs:69) EnemyController:Update() (at Assets/scripts/Enemy/EnemyController.cs:33)
using UnityEngine;
public class ShootingFPS : MonoBehaviour
{
public Rigidbody bullet;//the bullet it self
public Transform spawner;//the point that the bullet spawns
public float bulletSpeed = 7000.0f;//the speed of the bullet
public static int mag = 30;
public static int ammo = 100;
float reloadTime = 1.5f;//the amount of time it takes to reload
public static bool reloading = false;
void Update ()
{
if (Input.GetMouseButtonDown(0) && mag > 0 && !reloading)
{
mag = mag - 1;//removes a bullet
Rigidbody bulletInstance = Instantiate(bullet, spawner.position, spawner.rotation) as Rigidbody;//spawns the bullet
bulletInstance.AddForce(spawner.forward * bulletSpeed);//added the force to the bullet
}
if (Input.GetKeyDown("r"))
{
if (!reloading)
{
this.GetComponent<Animator>().Play("reloadAnimatoin", -1, 0.0f);
reloading = true;
}
}
if (reloading)
{
if (reloadTime > 0)
{
reloadTime -= Time.deltaTime;
}
else if(ammo > 0)
{
mag -= 30;
ammo += mag;
mag = 30;
reloadTime = 1.5f;
reloading = false;
}
}
}
}