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().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
![alt text][1]
![alt text][2]
I've tried switching agents to my other enemies agents, i've changed the speed, i've even rebuilt the enemy from scratch
[1]: /storage/temp/166082-screenshot-11.png
[2]: /storage/temp/166083-screenshot-12.png
↧