x

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"

Rotate TPS weapon towards crosshair

Hi good people of the UE4-community. What I want to do is aim my weapon towards the crosshair (center of screen) but I'm not sure how to best solve it. I've tried lots of different things without getting a good result. Preferably the whole upper body would rotate so that the trace from the weapon aligns with the trace from the camera. But just rotating the weapon and hands or arms would be good enough I suppose.

alt text

Product Version: UE 4.22
Tags:
rotate-weapon.jpg (162.0 kB)
more ▼

asked Apr 04 '19 at 08:41 AM in Blueprint Scripting

avatar image

nissekaka
11 1 4 6

avatar image nissekaka Apr 09 '19 at 12:07 PM

Okay, I'm still fighting this thing. I managed to get the weapon to aim correctly, however, I don't have any hand/torso IK setup. https://prnt.sc/n9jshp I'm doing a trace from the character's eye towards the crosshair location but starting it a certain distance from the actual eye, this location represented by the debug sphere. I modify the pistol bone to this location, and then rotate the whole mesh towards the crosshair location. Not pretty! Even worse is that if I try to use IK for the hands to correctly hold the pistol, since the pistol bone is a child to the right hand, the pistol also moves as shown in this picture: https://prnt.sc/n9jtw5 I just can't seem to find any information on this online. The only reference I have is this video: https://www.youtube.com/watch?v=QJZNIy7Dh6o

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

1 answer: sort voted first

UPDATE: This is how I'm currently doing this. It is by no means perfect but yields the result I'm after. https://prnt.sc/n9pd71 - Here I'm getting the center of where my camera is looking. https://prnt.sc/n9pe5q - I couldn't think of another way of getting a location between the character's eye and where I want him to aim than by doing this. https://prnt.sc/n9peh3 - I set the location for the right hand bone. Since I want to have the pistol_IK bone positioned at this location, I move my hand bone relative to the pistol_IK bone. https://prnt.sc/n9pemx - Here I get the rotation to the crosshair location for the weapon. https://prnt.sc/n9pf07 - And finally the AnimBP where I move my hand_r, rotate the hand_r (adding pitch so the rotation moves with my AimOffset) and move my hand_l along with my hand_r and also look at where I'm aiming with the head.

When trying to solve this I'm mostly just doing it intuitively by trial and error without really knowing what I'm actually doing, so I don't understand everything perfectly. So I'm probably doing it way harder for myself than I need to. I'm sad to see there are no tutorials or no one talking about this out there, what I can find. I'm going to try to make it work better but this is what I have for now.

Result: https://giphy.com/gifs/ResIHq0UTlqwwVdaYA/html5

more ▼

answered Apr 09 '19 at 06:34 PM

avatar image

nissekaka
11 1 4 6

(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