FPS aim is slightly off center - using ScreenPointToRay

I am making an fps game but my shots always end up slightly below and to the right of where they are supposed to hit (whatever is in the center of the screen.) I’ve used the ScreenPointToRay function to aim the gun at whatever point is currently displayed in the center of the screen. Problem is, when I actually fire the gun the projectile ends up the slightest bit off of where it should be. See here:

That is where the shot hits the wall (I’ve tested enough to know it’s not just me moving the reticle after firing.)

I’ve tried everything I can think of – I used a debug raycast to make sure the shot spawner on the end of the gun is rotated to face the target point; I’ve double checked that the raycast points toward the center – the point at which the gun should be aiming is definitely correct. Could it be possible the bullet object itself is offset from its origin somehow? It doesn’t look like it in the inspector but I really don’t know. Please help, I’m running low on ideas!

First off, why are you spawning the bullet spawn point from the actual gun? I think that is probably the cause of your problem, since gun isn’t centered on the camera’s center (transform wise, that is)

You don’t need to spawn the bullet at the gun’s location, especially in the case of a raycast weapon.

Haha, it was something stupid I missed. Knew it had to be something like this. My script was referencing the wrong object’s rotation – I had it attached to the gun object so it was referencing the gun’s rotation not the BulletSpawn’s rotation. Fixed, working fine now. Thanks for the help :slight_smile: