Make Enemy chase Player
I'm making an rpg game and I need to know how to create an enemy that will chase the player if their distance is close, I Think I know how to check the distance, but how do I make enemy actually move towards the player?
I'm making an rpg game and I need to know how to create an enemy that will chase the player if their distance is close, I Think I know how to check the distance, but how do I make enemy actually move towards the player?
There are lots! You can take my code from my Utility Functions Library V2.2 with a full example that has this mechanic you are looking for! :)
NOTE: You might have to take some of the functions or just use my entire library to have some of the features!
Thank you so much! I did see the function approach(current, target, steps), but I'm a little confused with how it works, and even more with what type of variables can I put there. Can I write it like this: approach(this, player, 2)? ("this", because I made an Enemy class and used this function inside)(player is an object)(2 as in the speed of the enemy, so like x or y increases by 2).