Third Person Shooter Aiming Problem

I’m currently creating a third person shooter, and I’ve noticed a problem that comes up with third person shooters, and I’m wondering how other TPS games deal with it. And that is, in a TPS your crosshair is off to the side, meaning that your not aiming from the center of your character. In a first person shooter, your crosshair is directly in the middle of where you’re shooting from, meaning your bullets will go perfectly straight and always hit. However in a TPS, because where your aiming from and where your bullets come from are not the same, there comes the problem of your bullets just missing at certain distances and angles.

I’ve created a graphic to show what I mean:

Now, in my game I’m using the CFrame of the camera to tell where my projectiles should be going, but what you’ll notice is that even when my mouse is directly aimed at an enemy, in some cases it will completely miss.


The main reason for this is because the projectiles start at the position of the players head, and fly towards the LookVector of the players camera, which can end up in the projectiles just barely missing even when perfectly aimed.

Now, you might think that instead of using the CFrame of the camera, I could use Hit property of the player’s mouse, which does work, but when an enemy is very close the projectiles will end up flying off in an unintended angle which looks very weird.

So does anyone know how I could fix this to work so that the projectiles will always hit at any distance, without flying off?

And my game does use projectiles, not hitscan.

1 Like

you need a check when the mouse hit is close to the projectile spawn point. like use a dot product

forwardDirection=(spawnPoint - playerPoint).Unit
shootDirection=(mouseHitPoint - spawnPoint).Unit

if dot(forwardDirection, shootDirection) < threashold then
  shoot(forwardDirection)
else
  shoot(shootDirection)
end

it basically mean you want to shoot at the mouse hit location if it is within a reasonable angle, otherwise just shoot straight

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.