How to make character Aim and shoot at HUD reticle

Hello,

So, Currently I’m trying to get my character to aim and fire at my HUD reticle/center of the screen. I am using AimOffset which is making it difficult as whenever I turn my upper body the gun and arms unalign with the center of the screen. I know an easy fix would be to disable Yaw rotation for aimOffset but that’s not what I want. I want the OffSet to work but also be in sync with the turn rate for the camera. (I have both 1st and first person camera).

How can I get my gun to constantly be aligned with the reticle so that when I fire, the bullets hit the center of screen (Or around it) and continue going on a straight path from there?

Please help!

##Shoot From Camera Center

If I understand you correctly, you need to use the forward vector of your camera in order to do your fire logics (LineTrace etc…).

[Here][1] is a good tutorial that explains how to do that (more specificly, go to “Shooting Bullets” chapter).

##Shoot From Gun Barrel

Hopefully with my (at best vague) drawing, you can understand the main issue with this technique. Namely, that if your gun is not lined up with the camera’s center and camera’s forward vector (which is, I assume your case), it will only be able to point to the center of the screen for one unique distance (d). So, basically, you will only hit your target if it is at a distance d from the camera. You can mitigate this problem by dynamically calculating d at each frame. For that, you would need to do a LineTrace with the forward vector of the camera and get the distance of the first blocking hit.

So, all in all, I would advice to follow the first method that is much more straight forward and has been proven to work pretty decently.

Hope it helps!

Cheers.

Heya, you for the help, however Forward vectoring hasn’t worked for me (at least from the way it’s shown in the tutorial). The tutorial shows a different approach to creating an fps than the route i’ve taken. Currently my bullets fire from the weapon’s muzzle/end of barrel and fire in a straight line based off where the gun is pointing at the time, the issue is, the animation isn’t always pointing towards to the center of the screen/HUD. Is there a way to use Forward Vectoring to fix this (based on my current BP)?

Hey Hattimus! Please, see my updated answer.

you again! I’ve just realized that I forgot to mention that the game is both Third and First person so having the weapon bound to the camera would cause some issues when in third person.

As I mentioned before, I’m using Aim-offset where the upper body rotates before the lower-body…this is causing the biggest problem when it comes to aligning up the weapon with the POV. Would there be a way to fix it so that the weapon snaps to wherever the reticle is pointing when aiming is enabled (right click) but when it’s not aiming the body is free to rotate.

A good example of what I’m looking for is “Star Wars Battlefront 2 (2005)” where the player can rotate the upper body when not firing but as soon as firing is enabled, the body and weapon snap facing where the reticle is.

you for all your help and patience :slight_smile:

I’m not entirely sure I understood correctly but If you want the character’s rotation to be controlled by the camera when you aim (which is usually a wanted feature in TPS games) then you can have a look at this tutorial : TPS Build Part 2 - Character_BP Aiming - YouTube. The two CharacterMovement’s variables that are relevant to this are ‘Use Pawn Control Rotation’ and ‘Orient Rotation To Movement’.