AddTorqueを使ってロール軸を水平にしたい

上記トピックにある方法を使ってPawnの制御をしているのですが、ピッチを傾けた状態でヨーをかけるとPawnが横倒しになってしまいます。なのでロール軸を水平にする機能を付け加えたいのですが、ベクタの計算に不慣れでやり方が分かりません。
物理の挙動を損ないたくないのでSetRotationのように無理矢理回転を修正したり、回転にロックをかけるのではなく、AddTorqueを使ってロールを修正したいです。どうすれば可能でしょうか。

Torque works with the right vector for pitch (but it all depends on the setup, ofc). You could use forward and up vectors to achieve other rotations - do note there is a difference between adding world torque and local space torque. There are (inverse) transform nodes to help out here or we can unrotate a vector, too.

Also, adding torque on all 3 axis simultaneously would be very difficult for the player to control. Depending on what the end goal is, consider implementing it in a such a way that they can use 2 axis at a time only.

It gets even more difficult if you want an algorytm that can arrest angular momentum and / or produce enough counter-torque to achieve a specific rotation for a spinning body. Example of what I’m talking about:

And then you may need to look into a nested PID controller.

1 Like

Thanks for answering my question.

I tried tilted the getted Pawn’s direction to the Z axis by 90 degrees and tried to match the Right vector.
Unfortunaly, this method’s barely worked. A misalignment occurred and Pawn’s unable to accurately track camera orientation.

Any suggestions for improvement?