Keeping an object facing a specific direction using forces
Posted: Fri Jun 10, 2016 9:33 am
Time to ask a general physics coding question in the forum for the specific physics engine in use even though a mathematical forum might make more sense... were a quality one to exist :/
So I have an object floating in the air.
This object can be knocked about by any number of exterior factors.
This object has one goal in its existence: To keep it's top oriented upward. Meaning, if it were EG a flat platform, that platform would remain facing the correct upwards direction.
However it has a limit: It must apply a restricted amount of force to accomplish this goal. Meaning it applies forces to slowly rotate itself back to its goal orientation (as opposed to teleporting instantly or anything).
It also doesn't care about it's yaw angle (The rotation about the up/down axis).
How would I go about calculating and applying the necessary force? I have a nice little SingleEntityConstraint sub-class that can successfully spin it out of control in a variety of entertaining ways, but none of them seem to spin it towards the goal direction (instead, they spin carefully AWAY from the goal direction at all times (and then spin the opposite direction away from the goal if I negate it, of course).
As a final note, "Up" is an arbitrary direction and may change, even actively moving during the simulation.
Thanks in advance for any hints!
So I have an object floating in the air.
This object can be knocked about by any number of exterior factors.
This object has one goal in its existence: To keep it's top oriented upward. Meaning, if it were EG a flat platform, that platform would remain facing the correct upwards direction.
However it has a limit: It must apply a restricted amount of force to accomplish this goal. Meaning it applies forces to slowly rotate itself back to its goal orientation (as opposed to teleporting instantly or anything).
It also doesn't care about it's yaw angle (The rotation about the up/down axis).
How would I go about calculating and applying the necessary force? I have a nice little SingleEntityConstraint sub-class that can successfully spin it out of control in a variety of entertaining ways, but none of them seem to spin it towards the goal direction (instead, they spin carefully AWAY from the goal direction at all times (and then spin the opposite direction away from the goal if I negate it, of course).
As a final note, "Up" is an arbitrary direction and may change, even actively moving during the simulation.
Thanks in advance for any hints!