Rotating a vector

Hi, I need to rotate a vector to do a shotgun instant hits system. I did this to rotate each hit horizontally:

GetWorld()->LineTraceSingle(GunHitResult, CameraWorldPosition, ((CameraForwardVector * 50000) + CameraWorldPosition).RotateAngleAxis(5.f, FVector(0.f, 0.f, 1.f)), ECC_Visibility, TraceParams);

but the problem is that if I change the X or Y axis instead of Z, to rotate a vector of a hit vertically, it goes up if I’m watching a side of the map, and it goes down if I’m watching the other side.

What can I do to rotate the vector of a hit vertically?

I am asking about the formula: You want to turn only the directional axis ?
So you should write :
CameraWorldPosition + (CameraForwardVector).RotateAngleAxis(5.f, FVector(0.f, 0.f, 1.f)) * 50000

(By the way, 50000 is very huge to a trace check)

The code of LineTraceSingle that I wrote is working, but it’s working only horizontally. If instead of the Z of the FVector, I change the X or Y, it doesn’t work. I created a topic on the forum too: Rotating a vector - C++ - Unreal Engine Forums

Ok. I speedly read the post.

If you have an error according to the world direction, you have a compute problem. A mess between world and local coordinate. Obviously RotateAngleAxis operate in world coordinate.

Try this:

Keep CameraForwardVector and convert this to rotator
FRotator Rot = CameraForwardVector.Rotation();

Add some pitch (vertical angle)
Rot.Pitch += 5.f;

Convert again in vector
FVector Dir = Rot.Vector();

then you could make your trace between CamLoc and CamLoc + Dir *50000

An other way is to get the side vector of your camera. You can get it with FVector(0.f, 0.f, 1.f) ^ FrontDir and make the RotateAngleAxis with it.

If I use the local position, as you said, it works. Thanks!