I am just tooling around with the idea of a 2D side scrolling fighting game and wanted to run through my understanding of how to implement some basic AI. Just to try and get something working I am making everything very simple and basic.
I was thinking of creating the enemy object, loading them into the scene, and using an invisible line or rect which is anchored to the enemy and will be used to detect the player through collision. If this invisible rect collides with the player object then the enemy’s AI goes to work and does something simply like begins moving towards the player and once the enemy and player objects are within certain distance, perhaps with a small random offset thrown in, the enemy begins to swing his sword and try to attack the player.
Does this sound about right? What type of event listener would I use to continually run in the background to check for the collisions? Is this event listener model impact the performance at all?
Thanks!