How to make shooting ai


I want to make ai that goes around and shoots when a player comes in within a certain range.

how can i do that?


Hello Kang,
this is not the exact solution but can help you :


I’m sorry but I want to make a pixel 2d game that I see from the side.


Check the distance between the player and the ai object, and then fire at the player if the distance is within a set number of pixels.


Hi, is this what you want? I made this for a game jam. The orange enemy shoots the player if it comes close. Is this the mechanic you want, if yes I will send a screenshot of the code
This is for computer only