Problem: I want to switch the coordinate system when I call a function. In editor you can use the shortcut Ctrl+` to do this. I want to do the same thing using C++ or blueprints
Why do I need this: I am working on an inspect functionality where I can rotate the object. I use the movement keys(WASD/Arrow Keys) to move the actor. The issue I am facing is that while pressing the W/S key the rotation is vertical in the first case
but it is horizontal in the second case. I want it to be the same type of rotation in both the cases. I found that cycling transform coordinate system fixes it in editor.
Why this happens: From what I am able to observe the reason this happens is because in the second case Roll is the “Up Direction”
whereas in the first case Pitch is the “Up Direction”
After switching/cycling transform coordinate system
Pitch is always the “Up Direction”. This was the only solution I could think of. If there is any alternative method to accomplish this, that would be helpful as well
Code I am using:
if (Controller != nullptr)
{
const FVector2D MoveValue = Value.Get<FVector2D>();
if (MoveActor)
{
if (MoveValue.X != 0.0f)
{
auto ObjectRotation = FRotator(0, MoveValue.X, 0);
MoveActor->AddActorLocalRotation(ObjectRotation * -1);
}
if (MoveValue.Y != 0.0f)
{
auto ObjectRotation = FRotator(MoveValue.Y, 0, 0);
MoveActor->AddActorLocalRotation(ObjectRotation * -1);
}
}
}
}