Top Down AI for Enemies
















































Top Down AI for Enemies
This is an example of how to do enemies that somewhat follow and try to seek the player.
It works like this:
each enemy shoots sensors towards the player.
if a sensor hits a wall, it gets deleted.
if a sensor exceeds a set amount of time, it gets deleted.
if a sensor hits the player, a position gets marked as a target for the enemy that emitted that sensor.
enemies will move to their target positions.
enemies will roam randomly when the player hasn't been detected.
enemies have a fov: sensors are emitted only if they are inside the range of this fov.
if the player gets too close to enemies, they will detect the player, regardless of their fov.
if the enemy can't find the player, it will get deactivated after a set amount of frames or after it reaches its target position.
This example also features:
a bunch of helper functions;
animation system;
y sorting system;
outlined sprites;
outlined text printing;
floating text messages system.
If this was helpful or interesting for you, please give my itch.io page a visit: https:profpatonildo.itch.io or consider buying me a coffee: https:ko-fi.comprofpatonildo70266