Godot Version
Godot 4.3 dev (manually compiled)
Question
(The question has evolved a bit to: how to keep a rigid body somewhat upright while other forces are acting on it.)
I have a weird situation. I want a fish (rigidbody3d) to swim towards a target. This involves turning left/right (around fish Y) and turning up and down (around the X).
Here’s a snippet of the code:
var T : Vector3
#Fish left/right
if true:
T = basis.y
T = tspeed * T
apply_torque_impulse(T)
#Fish up/down
if true:
T = basis.x
T = -tspeed * T
apply_torque_impulse(T)
When one or the other if
s happen, the fish behaves as expected, but when both are true the fish rolls on its side and goes a bit mad.
It reminds me of a gimbal-lock kind of problem.
I have an MRP on my Gtlab: Files · torque_issue · Donn Ingle —Dbat / fishy · GitLab