I am following the C++ FPS tutorial on the wiki (which is great btw) and there’s a part that I don’t quite get yet. A little bit more explanation would be greatly appreciated. Here it is :
// Inside AFPSCharacter::OnFire() FVector CameraLoc; FRotator CameraRot; GetActorEyesViewPoint(CameraLoc, CameraRot); // MuzzleOffset is in camera space, so transform it to world space before offsetting from the camera to find the final muzzle position FVector const MuzzleLocation = CameraLoc + FTransform(CameraRot).TransformVector(MuzzleOffset);
I am not sure how the MuzzleOffset world space transform works.
So if I understand correctly (and correct me if I’m wrong) GetActorEyesViewPoint return the location and rotation of the camera in world space. Then we use the camera rotation get the MuzzleOffset in world space, but how is this working? What about the camera location? Shouldn’t we do something like :
FVector const MuzzleLocation = CameraLoc + FTransform(CameraRot, CameraLoc).TransformVector(MuzzleOffset);