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"

Problem when converting a rotation to vector C++


Inside: Tick (float DeltaTime)

to get the rotation of my character I just use:

FRotator MyCharacteRotator = GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorRotation();

to prove that all this well I use a log on screen:

GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("Player Rotator: %s"), *MyCharacteRotator.ToString()));

when I move my character correctly my vector is updated

alt text

I want to turn the rotation into a vector to get the coordinates x, y and z. but I can not find the correct way. since I use:

FVector NewRotationVector = MyCharacteRotator.Vector();

I do not know if it is the correct form or if I am doing something wrong because it only returns the value of 1 when the rotation is made. and should return values ​​like 0, 90, -90, -180

I'm waiting for an answer, thanks.

Product Version: UE 4.19
captura.png (21.3 kB)
more ▼

asked Apr 18 '19 at 07:57 PM in C++ Programming

avatar image

93 2 8 9

avatar image Lardo Deepdelver Apr 20 '19 at 10:06 AM

if you just want to get the forward direction of your character, then there is no need to go over the rotation just use



avatar image danielf94 Apr 22 '19 at 03:15 PM

Thanks for the information

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

1 answer: sort voted first

The vector and rotation are 2 separate things. Vectors are 3D coordinates like you said (X,Y,Z). Rotations are in degrees 0-90 for pitch, 0-180 for roll and yaw. You are asking to take a rotation and make a vector using the FRotator::Vector() function seen here:


This returns a unit vector pointing in the direction of rotation. That is why it is always 1. I think maybe you want FRotator::Euler() which you can see here:


more ▼

answered Apr 19 '19 at 03:38 AM

avatar image

Nebula Games Inc
5.4k 28 9 15

avatar image danielf94 Apr 22 '19 at 03:15 PM

thank you

(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