So I’m trying to rotate a bone that has a weapon attached to it, so the weapon is using the same rotation as the camera.
To test this I’m using a static mesh attached to a scene component that is attached to the player’s skeletal mesh. Because the weapon in the player’s hand isn’t always going to align with the bone it’s attached to, I have to find the rotation delta between the static mesh and the camera, then add that to the rotation of the scene component. That should give me the world rotation I need, then I just transform that rotation to the mesh’s space and apply it to the scene component (this is because applying world rotation on bones seems to give me weird results). This all seems to work, except that when the camera’s pitch starts to approach 75, the static mesh begins to wobble/jitter and the rotation delta pitch starts jumping between 7 and -7. Heres the code:
FRotator CurrentConeRotation = TestRotationCone->GetComponentRotation();
FRotator ConeRotationDelta = FirstPersonCameraComponent->GetComponentRotation() - CurrentConeRotation;
TestRotationDelta = ConeRotationDelta;
FQuat DesiredRelativeRotation = Mesh_Body->GetComponentTransform().InverseTransformRotation((TestRotationSceneComponent->GetComponentRotation() + ConeRotationDelta).Quaternion());
TestRotationSceneComponent->SetRelativeRotation(DesiredRelativeRotation);
Can’t seem to figure out why this is happening, and any help is greatly appreciated.