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"

FTrasform::TransformVector vs FRotator::RotateVector

Hi, I'm trying to understand the fps tutorial code and recently I'm struggling to understand transforms, vectors and rotators.

At one point of the tutorial I arrive that I have a GunOffset, an offset to the point where to fire my projectile.

I want to fire in front of me so I can start taking the world location of the attached camera or of the eyes of my character:

 //fps tutorial
 FRotator CameraRotation;
 FVector CameraLocation;
 GetActorEyesViewPoint(CameraLocation, CameraRotation);
 FRotator SpawnRotation = CameraRotation;
 FVector SpawnLocation = CameraLocation + FTransform(CameraRotation).TransformVector(GunOffset);

 //fps template
 FRotator CameraRotation;
 FVector CameraLocation = GetActorLocation();
 FRotator SpawnRotation = GetControlRotation();
 FVector SpawnLocation = CameraLocation + SpawnRotation.RotateVector(GunOffset);

I don't understand what is the difference doing one way or the other. The vector SpawnLocation is found adding CameraLocation (world) + GunOffset (once world).

FTransform::TransformVector and FRotator::RotateVector seem doing the same thing taking the vector GunOffset and making him world, but meanwhile the FRotator::RotateVector is clear to me (It rotates the vector GunOffset according to the rotator SpawnRotation), the other one isn't.

Product Version: Not Selected
more ▼

asked Mar 10 '15 at 03:16 PM in C++ Programming

avatar image

3 2 2 5

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

1 answer: sort voted first

An FRotationMatrix is just an FTransform where you only change the rotation components. When you RotateVector you are transforming the Vector about a RotationMatrix. An FTransform with only the Rotation set is the same thing as a FRotationMatrix, so anyway, they're all the same, RotateVector is just a nice wrapper I suppose.

more ▼

answered Mar 10 '15 at 09:51 PM

avatar image

477 34 18 47

(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