Simple AI

Started by
0 comments, last by mpipe 15 years, 6 months ago
I am making a 2D action style RPG and I want the enemies to attack the player, not just run around in random movements. I can wrote something to get them to run randomly. My question is how would I make them appear to see the player and then chase after him? Kind of like Zelda: A Link to the Past.
Advertisement
The AI has a few states: standing, attacking, chasing, returning.

When the unit is standing, every so often, have it check for a nearby target. If it has one, it goes into chasing mode. If the target is out of the unit's range, it moves towards it. When the target is in range, the mode switches to attacking and the unit fires its weapon or attacks. If the target goes out of range, the unit goes back into chasing mode. If the unit strays too far from it's original location, it goes into returning mode, where it moves towards its original guard spot. Once it reaches that spot, it returns to standing mode.

This topic is closed to new replies.

Advertisement