Detecting the tilt of a DynamicPhysicsNode

Hello,



This is probably a lot simpler than I thought but: how do you detect the tilt in one direction of a DynamicPhysicsNode? I have a bicycle and want to detect in both how much it tilts to its left or right (local x-axis) and in what direction - i.e. different signs. However, if I'm Euler angles, getLocalRotation().toAngles(…)[2] will return different signs depending on the node's rotation around the other axis… Any ideas? :slight_smile:


  • joh

Did you try what I suggested in that other thread? (E.g. transform local left vector to world coordinates and measure y component)

irrisor said:

Did you try what I suggested in that other thread? (E.g. transform local left vector to world coordinates and measure y component)


I'm not sure I follow here ... transform the local left vector as in the translation vector and multiply it with the local/world rotation?

Like this:

float tilt = yourPhysicsNode.getWorldRotation().multLocal( new Vector3f( 1, 0, 0 ) ).y;



(where you should not create a new vector each frame, but remember it, of course)

irrisor said:

Like this:

float tilt = yourPhysicsNode.getWorldRotation().multLocal( new Vector3f( 1, 0, 0 ) ).y;


(where you should not create a new vector each frame, but remember it, of course)


Thanks! It seems to work :D