AI aiming system and gun shooting system?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nothing

So I want to make a AI aiming system and a gun system. I know how to record the player position. But the AI has guns so I want them to look at the player position to aim and shoot at them as well as follow them, how do I do that? I also want to make a gun shooting system how do I do that? Any good resources to help?

:bust_in_silhouette: Reply From: njamster

But the AI has guns so I want them to look at the player position

If you know the player position in global coordinates (and you say you do!), then you can use the look_at-function for that. Check out the documentation.

I also want to make a gun shooting system how do I do that?

There are a couple of plugins for that like this and this. If you want to implement a hit-scan weapon (i.e. a weapon that doesn’t actually fire a projectile) I’d recommend this.

shoot at them as well as follow them, how do I do that?

Take a look at this tutorial on homing missiles. You might find his series on implementing a tank battle game helpful as well, especially parts 3, 4 and 5.