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.