I’m trying to rotate an actor based on the mouse position. Physics are enabled on the actor with X, Y and Z Rotation locked in the physics category.
The problem is that I can’t rotate it whether it is via code of using the rotation tool in the editor. Removing the rotation and using the editor tool to rotate the actor does not work.
Completely disabling physics works however, I want physics on the actor.
With the rotation lock and physics enabled, I can rotate it only by directly modifying the transform rotation value. However, this works only in the editor not in code.
In code when I rotate the actor the rotation does not change instead, for some reason, the location changes. It seems that physics it the problem, but I need physics enabled.
Here’s a code snippet
// function called when the player moves the mouse.
void AMoonPlayer::RotateActor(float value)
{
//sMesh(Static Mesh) = UStaticMeshComponent
//I attempted to unlock the Y rot to try to fix the issue(it didn't work)
sMesh->BodyInstance.bLockYRotation = false;
//act(Actor) = USceneComponent
act->AddRelativeRotation(FRotator(0, value * sensitivity, 0), false, (FHitResult*)nullptr, ETeleportType::TeleportPhysics);
sMesh->BodyInstance.bLockYRotation = true;
}