So I really am struggling since 2 days already and I cant find a perfect solution for this. So basically whenever I watch a tutorial its only about 1 topic like for example: How to make enemy chase player but when I combine it with other stuffs like Make the Enemy attack the Player then it’s messing up the code and make it useless.
so basically what I want is a tutorial on this advance thing where the enemy is patrolling then when in a collision check of a certain distance then the enemy will follow the Player and then when they collided, The Enemy will attack the Player and that’ll reduce the Player’s health and add force to it.
then go back to Patrolling after the Enemy is not in the collision of that Player
I’ve achieved this using a Finite State Machine. Although mine is a top down game, the concepts can be applied to platformers.
Each enemy has a set of states it can be in, like walking, turning, spotted player, chasing, checking, returning to walk etc. It looks like this (action is the state the enemy is in):