Hi, I’m working on a top-down shooter need help with the AI it works to a point. All spawn at different points but all the AI go to the same point of the wall to destroy try to get to you.
all the AI mess up go a lil crazy
Header("Defens")]
public Transform wall;
[Header("Gneral")]
public Transform player;
public float rotSpeed;
public float speed;
private GameManger gManger;
private ZombieHealth zombieHealth;
// Use this for initialization
void Start () {
gManger = GameManger.instance;
player = GameObject.FindGameObjectWithTag("Player").transform;
wall = GameObject.FindGameObjectWithTag("Wall").transform;
zombieHealth = GetComponent<ZombieHealth>();
}
// Update is called once per frame
void Update() {
if (gManger.gameOver == true || zombieHealth.zombieDie == true || gManger.pauseGame == true)
return;
transform.position += transform.forward * speed * Time.deltaTime;
if (wall != null)
{
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(wall.position - transform.position), rotSpeed * Time.deltaTime);
}
else
{
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(player.position - transform.position), rotSpeed * Time.deltaTime);
}
}
}
Thank you