(This all may seem obvious to anyone having worked on this before but this is my first time encountering it and it took me a little bit to work through the issues.)
The premise is pretty straightforward: With a third person shooter, how can I ensure that projectiles coming from the character will have the expected trajectory when the actual aiming is done with a crosshair?
I have a crosshair drawn in the middle of my HUD, in the center of the screen. It indicates the center of the camera for the character. My camera is above and behind my character (to the right) so that I can see the character clearly.
https://i.imgur.com/6eeo04Y.png (Crude MSPaint representations drawn from above to better show the issue I’m facing)
When I want to fire a projectile, I do a Line Trace by Channel from the camera’s location (center of the crosshair) to a point 5000 units away (using the camera’s “forward” vector). This gives me the location of either a colliding object or the location of the end of the trace.
I use the above location and the character’s world location in a Find Look At Rotation to find the correct rotation of the projectile and spawn it at the character’s location.
The end result is that projectiles fired from the character will hit the point where your crosshair is pointing. This is good and works well as long as you are accurate with your crosshair.
So let me describe a scenario. You’re shooting at an enemy, headshot headshot headshot because you’re a pro. But then your cat bumps your arm and your crosshair is slightly off - just to the left of the player’s head. But instead of the projectile whizzing by their ear, it ends up being several feet to the left. The reason for this is that the initial line trace went out 5000 units, way beyond the target and hit open air. The projectile is then launched towards that far-away point and the trajectory makes it miss the player by a LONG shot rather than barely missing.
In a similar scenario: You’re shooting at an enemy but you’re terrible because you just found out your cat’s on fire and it’s bothering you. You’re firing over and over at a stationary enemy but you can’t aim right and your crosshair is a good deal to the right of the player. Despite this, you are landing shots on the player every time. Since the line trace from the camera went beyond the target, the impact location ended up behind the target so the projectile is launched toward it and manages to hit the target anyway.
Effectively, what is seen here is the same as if you were to hold a gun in your right hand, hold it way out to the side and fire it where you’re looking. Don’t think about the logistics of trying to comfortably hold a gun that way - that’s not the point.
The takeaway is this: The greater the distance between the camera location and the firing location, the greater the error will be when firing. I have compensated for this a bit by adjusting the projectile’s rotation but this only works if the crosshair is pointing exactly at where you want to hit. Otherwise, it becomes a mess. As far as I know, there is no way to fix this problem keeping the current setup. There is no way to simply know what it is you meant to be aiming at and this implementation will always feel clunky. If you disagree, I would be happy to learn a new way to deal with this.
So - what else can be done? That’s what I’ve come here to ask. So far, my only idea is to reduce the distance between the camera and the player.
I have seen games where, when you are aiming, the camera is effectively “zoomed in” to be above the gun, either so you’re looking down the sights like you would in a first person shooter or close enough that it doesn’t make a difference - possibly all you’d see is a part of the character’s head/shoulder and the gun. However this method doesn’t look good for all styles of games and, depending on the gameplay, constantly zooming in and out will get jarring.
It is also possible to just try to keep the character and camera closer by default. At the moment, my projectiles are firing from the center of the character which looks weird and isn’t permanent but it’s a basic implementation. If I add a firing animation where the character holds up their weapon to their right shoulder, the distance between the camera and firing location is reduced a good amount. Likewise, I can probably squeeze the camera in a little more without TOO much negative impact. But I don’t want the camera to be so close that you can’t see your character anymore and I don’t want most of your screen to just show the back side of your character. So getting this balance will be tricky. Overall, this will reduce the error but will not fix it consistently. It will always make sense to aim to the right side of things because, if you miss with your aiming, your projectile might still hit.
Another solution would be to have a targeting system so you’re not relying on being accurate with the crosshair but this reduces some of the “skill” needed to be accurate.
I’m certain others have encountered and dealt with this scenario. I am trying to find other third person shooter games where I can test how it works there as well. Does anyone have any good examples? Suggestions? Thoughts? It kinda feels like most of the questions/discussions I post here go unanswered so I’m not truly expecting a response … but I’m still hopeful.
Thanks for reading
Edit: I did some searching (through Google instead of directly in the forums) and found a lot of people referencing “aim offset”. I found some tutorials on it and will go through tonight to see if that helps … sounds like what I need so I’m hopeful.
Edit2: Oh, this isn’t actually addressing what I’m talking about, this is just making the character face the correct direction which I will also need but it doesn’t resolve the issue I’m seeing above. On this page, the animation process is described: Creating an Aim Offset | Unreal Engine Documentation but ultimately this works because the camera is already behind the gun.











