I have a question about the Spaces Invaders AI:
If you see below in the images of the game, the invaders at the time of shooting, shoot the closest to the player in the form of a grid
That is to say: they will always start shooting the first line, but if I kill any of the first line, the one behind is the one who will start firing.
I made a script that solves it, but I'm not sure if it's at all, the best solution:
public void bulletAI()
{
invaderList = new List<GameObject> GameObject.FindGameObjectsWithTag("Shooter"));
var lastId = invaderList.FirstOrDefault(o =>
o.transform.position.x >= player.transform.position.x);
Instantiate(invaderProjectile,
lastId.transform.position,
lastId.transform.rotation);
}
Has anyone encountered something like that? Any feedback is welcome!
PS: Sorry to put it in English, I did not realize it was Stack Overflow Spanish haha. Hugs from Argentina!