playMaker

Author Topic: Pitch, roll, yaw via torque without gimbal lock?  (Read 2044 times)

Mulbin

  • Junior Playmaker
  • **
  • Posts: 90
Pitch, roll, yaw via torque without gimbal lock?
« on: June 21, 2016, 07:47:55 AM »
Hi, I'm working on a space game where the spacecraft is rotated using torque (please don't suggest rotation instead, not the fix I'm after).

The problem is (I think) gimbal lock. And the biggest issue is the torque dampening system I've built.  The Idea is that when the controls are released the thrusters apply torque in the opposite direction to slow the rotation.

First I get the rotation velocity in a certain direction, then I apply torge in the opposite direction... but sometimes instead of slowing it down it speeds it up as if the rotation direction has "flipped" due to gimbal lock.

I've heard about Quaternions... but have no idea what they are!  Can anyone talk me through how I would solve this in playmaker? 


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pitch, roll, yaw via torque without gimbal lock?
« Reply #1 on: June 22, 2016, 02:50:39 AM »
Hi,

How do you compute the "opposite" direction?

A thruster applies a force not a torque, so maybe you are getting confused here. if a thruster stops applying a force, you should maybe instead increase the drag and angular drag.

 when you detect that the user stopped rotating, increase the angularDrag and ease it back to the regular value over half a second or something. Have you tried this?


Bye,

 Jean

Mulbin

  • Junior Playmaker
  • **
  • Posts: 90
Re: Pitch, roll, yaw via torque without gimbal lock?
« Reply #2 on: June 25, 2016, 04:15:50 PM »
I'm using the add torque function (not a native feature, its from Ecosystem).  To add rotation in one direction I used a positive number on the desired axis, to add torque in the opposite direction I use a negative number on the same axis.  Sometimes though, it adds the torque in completely the wrong axis so I'm assuming this is gimbal lock.

It's a realistic physics sim so adding drag is a bit hacky and will likely interfere with my other systems.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pitch, roll, yaw via torque without gimbal lock?
« Reply #3 on: June 27, 2016, 02:20:20 AM »
Hi,

 It depends how you compute the direction, can you extract your logic into a small scene?  Else can you explain in details how you compute the negative direction.

Maybe you should debug this direction in the first place to make sure the value is correct.

Your erratic rotation could be because you add too much torque or it collides or interfere with something else.

Bye,

 Jean