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"

Getting Direction based on Input

Hi,

I need help with calculating the YAW to rotate my character to based on which keys are currently pressed.

Background:

I have a character (Orient rotation to movement) that does a roll animation when pressing Left Shift.

In the code for the LeftShit action Pressed, I need to check which directional keys are pressed at the time of Left Shift being pressed.

I know how to check if a key is pressed, but I don't know what to do after that. How can I get the Yaw that I need to turn my character to before playing the rolling animation?

Here are some screenshots that help to explain what I'm after:

http://prntscr.com/m0n9t7

http://prntscr.com/m0n9t7

http://prntscr.com/m0nakf

If somethings not clear, I can post a video or something to better try and explain.

Thanks

Product Version: UE 4.21
Tags:
more ▼

asked Dec 28 '18 at 07:39 PM in C++ Programming

avatar image

Exrotz
1 1

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

You can get the Yaw value like this.

Forward and Right are my axis input names.

alt text

0.png (45.7 kB)
more ▼

answered Dec 28 '18 at 08:28 PM

avatar image

Evigmae
1.7k 8 3 8

avatar image Exrotz Dec 28 '18 at 08:55 PM

Thanks for the reply.

This works as long as the camera is directly behind the character.

If I rotate my camera to in front of the camera, the yaw is the opposite of what it should be so I roll the wrong way.

avatar image Evigmae Dec 28 '18 at 11:26 PM

just add them to the control rotation.

alt text

If you're using a custom camera and not one derived from the controller you can replace GetControlRotation with Camera->GetWorldRotation

0.png (97.5 kB)
(comments are locked)
10|2000 characters needed characters left
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