AI Aiming/ shooting locations on player

I setup some AI enemies to shoot at me and I noticed they were aiming at the root location of my detected player character. so the closer I get the more there weapons look like they are aiming at my feet.
And this got me thinking what is the best practice to make the enemies feel like they are properly aiming at you, EG: torso and head areas.
How is this normally done in games, And what are some good ideas.

It is always a hack when it looks right.
The most hits (when shooting with random offsets) the AI will get when shooting at the torso but the animation possibly shouldn’t reflect this. Perhaps it should always look at your camera.

In reality your eyes and your vision are in the same place but in game this might be different.

The same problem iften happen in multiplayer games. So for example Battlefield 4 had an issue with that for a long time. The 1st person camera and 3rd person weapons where in different places and so enemies could shoot at you even when you thought they couldn’t.

Or a current example. In “Hunt Showdown” the camera is below your 3rd person head and so it may happen that you are shot while standing at a window and thinking you are save because your enemy sees your head.

The problem is fairly complicated and not easily solvable.

I use the Eye Height of the enemy character as the starting point of the trace end, but you could use the location of a bone.

1 Like

One trick is to create a head and body collision (sphere, capsule, etc) and have the AI weapon aim for that via line trace from weapon to trigger.
That way even if the aiming animation doesn’t look right, it will still hit the player.

Let me know if that works.

That’s exactly what I said, but you don’t need to create anything, you can use eye height or the position of a bone directly