Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to make character Aim and shoot at HUD reticle


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!

Product Version: UE 4.19
more ▼

asked Mar 16 '19 at 12:04 AM in Using UE4

avatar image

0 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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 is a good tutorial that explains how to do that (more specificly, go to "Shooting Bullets" chapter).

Shoot From Gun Barrel

Shoot From Gun's 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!


more ▼

answered Mar 16 '19 at 02:09 AM

avatar image

179 3 9 7

avatar image Hattimus Mar 17 '19 at 11:07 PM

Heya, thank 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)?

avatar image Elou44 Mar 19 '19 at 02:09 AM

Hey Hattimus! Please, see my updated answer.

avatar image Hattimus Mar 19 '19 at 11:23 AM

Thank 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.

Thank you for all your help and patience :)

avatar image Elou44 Mar 19 '19 at 10:33 PM

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 : https://youtu.be/DauWu4AkXak. The two CharacterMovement’s variables that are relevant to this are ‘Use Pawn Control Rotation’ and ‘Orient Rotation To Movement’.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question