How do I AddTorqueInDegrees until the object is pointing downwards in world space?

Goal:
I am trying to simulate gravity in a minor way, so I want to tell my plane to pitch down towards the floor. This needs to work in world space and not local I believe, because if the plane is upside down, pitching down will lift it up. It needs to be down no matter what the other axis’ are.

Limitations:
I want to do this via physics, by using something like AddTorqueInDegrees. This is because there will be other forces applied too.
I need to apply it to the Capsule Container as that is what is having other forces applied to it. It is set as the root component (under self).

I have googled this extensively, and even taken it to ChatGPT, and I’ve had no luck finding a way that works. Attached is a screenshot of what I have right now, that doesn’t work because it rotates the plane to the right locally.

My question at it’s most simplest is - In UE5, how do I set torque towards a world space rotation?

Google’s AI when I search for an answer says:
There isn’t much information about setting torque towards world space rotation in Unreal Engine 5 (UE5) right now

I am shocked there isn’t more on this? Is there something fundamental I am not understanding?

Hey there @Kenthriaa! I’d recommend using DotProduct to check how similar vectors are. You may need to adjust this, as of now any pointing within 90 degrees will trigger it unless you adjust the >= node. Let me know if this helps!

1 Like

As @SupportiveEntity says, you can use dot product and relative rotation as the measurement of distance from the target rotation.

Applying the torque can get a little tricky, but if you’d like to get advanced, I’d suggest using something like a PID controller.

Credit to Chuck Noble for his PID controller linked here:
Add Torque to physics controlled player, to return roll to zero - Programming & Scripting / Blueprint - Epic Developer Community Forums (unrealengine.com)

I haven’t used this free PID on the Unreal Marketplace, but it could be good (there are a couple of paid ones too)
PID controller in Code Plugins - UE Marketplace (unrealengine.com)

Hopefully, if UE goes to a fixed physics tick in UE5.5 and onwards (it’s in discussion) this will help physics simulations run deterministically/consistently on different speed machines.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.