- Home /
Question by
RebelliousFerret · Aug 23, 2020 at 02:39 AM ·
enemynavmeshnavmeshagent
NavMeshAgent not working, working for some agents
I have an enemy spawner, spawns enemy prefabs. All those enemy prefabs have the same enemy movement scripts, different agents. The small, fast enemy does now move however. The script is
public class enemymovement : MonoBehaviour
{
public Rigidbody rb;
public Transform player;
public NavMeshAgent agent;
public GameObject deathSound;
public bool canDie;
GameObject scoreObject;
private void OnCollisionEnter(Collision CollisionInfo)
{
if (CollisionInfo.collider.tag == "Enemy" && canDie == true)
{
StartCoroutine(Death());
}
}
private void Update()
{
agent.SetDestination(player.position);
}
private void Start()
{
scoreObject = GameObject.Find("ScoreText");
player = GameObject.Find("Player").transform;
canDie = false;
StartCoroutine(startDie());
}
IEnumerator Death()
{
scoreObject.GetComponent<Score>().ScoreUp();
Instantiate(deathSound, transform.position, Quaternion.identity);
yield return new WaitForSeconds(0.1f);
Destroy(gameObject);
}
IEnumerator startDie()
{
yield return new WaitForSeconds(2f);
canDie = true;
}
}
My NavMeshAgent and prefab's look like this
I've tried switching agents to my other enemies agents, i've changed the speed, i've even rebuilt the enemy from scratch
screenshot-11.png
(29.9 kB)
screenshot-12.png
(67.9 kB)
Comment
Your answer
Follow this Question
Related Questions
Horde of NavMeshAgents - stops to recalculate path. 4 Answers
Tank not moving towards player 1 Answer
NavMesh giving jerky like motion 0 Answers
NavMesh agent bug 0 Answers
Enemy follow Camera 0 Answers