Getting actor rotation around a specific axis?

The angle between 2 vectors does not depend on the reference frame and does not depend on the scale or length of the vectors so you are making a mistake when you modify the X components. The fact that it returns a angle close to world YZ plane angle is pure coincidence. To get the local angle (the angle in myActor) you must get the velocity vector in myActor’s coordinate system.

Try this: (I have not tested it but it should work after you fix all punctuation errors)

FVector v1 = StaticMeshComp->GetPhysicsLinearVelocity(); //Get the velocity
FTransform LocalTransform = myActor.GetTransform(); //Get the actor transform
v1 = LocalTransform.TransformVector(v1); //v1 is now in local coordinates
v1.X = 0;	//Project it in YZ plane
FQuat VelocityQuat = FQuat::FindBetweenVectors(v1, FVector::RightVector); //Find the quaternion between the velocity(in local coordinates) and the RightVector = (0.0, 1.0, 0.0)
//From this point on you can get the Angle if you need it with
float Angle = VelocityQuat.GetAngle;

Be careful what transformations you do to the vectors as this will define what angle you get.

2 Likes