[SOLVED] Make enemy chase player


I am making a simple fps game, and would like to know how to make my enemy chase the player. I have my player shooting bullets, and some other scripts i have used have made it so that the bullet doesnt collide with the enemy. I would appreciate the help.

Hi @almish_subuk!

Maybe my Basic enemy AI example project can help you.



how would i add this into my game?

also i wont reply for like 10 minutes, have to go do somehting quickly

Add the enemy.js script to your enemy entity and assign the necessary attributes. Please check the setup of the enemy entity first.

Do i need to add animations, and a bullet? cuz for now i just want the enemy to follow around and eventually collide with the player. same thing with the hud. Is it needed?

No, you don’t need to add it.

I added the script, and 2 things are happenening:

  1. im getting an error that says that my version of ammo isnt working with something
  2. My bullets dont destroy the enemy when hit, instead the neemy goes spinning.
    Also, how will collision work? can i just keep my simple collision? or will collision need to be changed? (eg change how the bullet collides with the neemy) edit: nvm the collision is fine, but the enemy ai still isnt working. ignore point #2


Can you try to remove the Ammo folder and add it again with the button you will see in the editor?

If something else of the enemy is not working, please compare your setup with the setup of the example.

thanks, will update you

Thank you so much!!! you are an amazing person for helping me with this. everything is working well, and thanks for being patient with me. One last question: How would i make the enemy not stop chasing the player. I looked at the script and when its in combat range, the enemy just doesnt move towards the player. I was wondering if there was some kind of attribute i needed to modify so that the enemy’s wouldnt stop moving towards the player?

Thank you very much. :pray:

You can try to set the combat range to zero.

it is working. thank you so much, setting it to 0 fixed the problem. also, a note that could help you in the future is that while your enemy ai seems very intimidating, it actually is very easy to use. thanks for everything! bye!

1 Like