Applying Torque in Local Space on a Physics-driven Pawn

I have a physics driven Pawn and I’m currently trying to add turning using ‘Add Torque’ and ‘Set Angular Velocity’. But it seems that these functions are world-space aligned, which is the opposite of what I want: I need this to be aligned to the mesh itself. Right now, Add Torque and any other rotation stuff in physics always works in world space, which is the opposite of what I need.

I asked the same thing here in the forum: Applying local angular velocity in a Physics-driven Actor? - Blueprint - Unreal Engine Forums

Hi Xaymar,

Here’s the solution that I found for this issue

This will add body-space aligned torque to your object

in cpp (From Actor Component C++ )

AActor *cubeActor = GetOwner();
FQuat myActorQuat = cubeActor->GetActorQuat();

TArray<UStaticMeshComponent*> Components;
cubeActor->GetComponents<UStaticMeshComponent>(Components);

	UStaticMeshComponent* StaticMeshComponent = Components[0];
	UStaticMesh* StaticMesh = StaticMeshComponent->StaticMesh;		
	GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Green, StaticMesh->GetName());

	StaticMeshComponent->AddTorque(myActorQuat.RotateVector(FVector(100.0f, 0.0f, 0.0f)), NAME_None, true);

if you use Blueprints try this out

Thank you, I went with your approach since it was easier than the blueprint only approach given on reddit. I might stay in C++ for the entire project now, since even simple things are horribly complicated in blueprint :frowning:

Another potential solution:

I realized I had “use controller pitch / yaw / roll” set to “true” in the details section of my physics-driven pawn. Unchecking those options finally let my pawn rotate freely using AddTorque.

(This was after trying converting the coordinate space on my torque vectors between world and local without any luck.)

115234-rotationcontrols.png

I have given a blueprint example here that might help you.

blueprint torque in local space

I have given a blueprint example here that might help you.

blueprint torque in local space

thank you very much for your help.

Thx Man your a GOD !