Hello ,
So , I have been having this problem for a while now , I have made a First Person character that moves and rotates using SetActorLocation(); and SetActorRotation();.
However , when I tried to lock the physics rotation on the Z axis , Mouse look for the Z axis rotation stopped working. What’s weird is that I locked rotation on all axis , yet the rotation on the Y axis for mouse look still works , but not the rotation on Z…
I tried unlocking only the Z axis and increasing Angular damping to a high value , which fixed the problem in most parts , but , when I go inside of a corner , the character auto-rotates left or right , which is very annoying.
Snippet of the code :
//Mouse Y Rotation
FRotator newRotation = GetActorRotation() + FRotator(0, MouseX * 180 * MouseSensitivity*deltaTime, 0);
SetActorRotation(newRotation);
//Mouse Z Rotation
newRotation = PlayerCamera->GetRelativeTransform().GetRotation().Rotator() + FRotator(MouseY * 180 * MouseSensitivity*deltaTime, 0, 0);
newRotation.Pitch = FMath::ClampAngle(newRotation.Pitch, PitchMin, PitchMax);
newRotation.Roll = LeanAngle*leanFactor;
PlayerCamera->SetRelativeRotation(newRotation);
Anyone else has faced this sort of problem and can help?
Thanks