Arcade flight: roll reset and smooth movements

Hi all!

I’m trying to make an arcade flight shooting game (basically a clone of TerminalVelocity/Fury3/Hellbender if any of you know these games!).





So, I’ve got two questions:

  • Pitch, yaw and roll of the ShipPhysicsControl (my spaceship) are directly controlled by the keyboard’s arrows: they modify the ship’s PhysicsRotation. However, the movement’s animation is linear - how can I make it smoother? I’m not very good at math - I know I need to apply an exponential function somewhere, but don’t know where :confused:


  • Since it’s not a realistic flight simulator, roll should be reset to 0 over time… but resetting the Z value to 0 doesn’t work if X and Y rotations are different from 0. If I slightly pitch the spaceship up or down, even if shipControl.getPhysicsRotation().getZ() is equal to 0, the ship isn’t aligned to the horizon… am I missing something?



    Thanks anyway! :slight_smile:

you shouldn’t be explicitly setting the physics rotation really, you won’t get accurate results from this, as you basically beam yourself to that rotation, you should use control.applyTorque (Vector3f axis)

Also, even though a quaternion has X, Y, and Z… these DO NOT mean anything useful outside of the quaternion. They could have just as easily been called q, r, s. Quaternions are magic and you can’t do anything useful really with the raw components.



Some people seem to think a quaternion’s Z means rotation about some axis but it’s not true.

@wezrule said:
you shouldn't be explicitly setting the physics rotation really, you won't get accurate results from this, as you basically beam yourself to that rotation, you should use control.applyTorque (Vector3f axis)


Thanks, I tried it...
however, when using a simple applyTorque(new Vector3f(1,0,0)) as yaw control, the ship doesn't behave correctly... since the movement doesn't respect previous orientation :S

@pspeed said:
Also, even though a quaternion has X, Y, and Z... these DO NOT mean anything useful outside of the quaternion. They could have just as easily been called q, r, s. Quaternions are magic and you can't do anything useful really with the raw components.

Some people seem to think a quaternion's Z means rotation about some axis but it's not true.


ah, I understand now! So I should search the Z orientation somewhere else...

applyTorque (Vector3f axis), rotates around an axis, its not a force in a direction. For yaw (y), you would use (0, 1, 0)

@victorfleur said:
ah, I understand now! So I should search the Z orientation somewhere else...


http://hub.jmonkeyengine.org/javadoc/com/jme3/math/Quaternion.html#toAngles(float[])

But as I recall, Terminal Velocity had full 6 degrees of freedom... if you are going with that approach then sometimes turning a quaternion into euler angles will not necessarily make sense with respect to "fastest way to level a ship".

You know, I sort of remember there being a similar thread on this last week.

Thank you all.


@pspeed said:
http://hub.jmonkeyengine.org/javadoc/com/jme3/math/Quaternion.html#toAngles(float[])

But as I recall, Terminal Velocity had full 6 degrees of freedom... if you are going with that approach then sometimes turning a quaternion into euler angles will not necessarily make sense with respect to "fastest way to level a ship".

You know, I sort of remember there being a similar thread on this last week.


oh, yeah - I'm sure someone else already solved these problems (but forum's search works only with titles :/ )
Anyway, I found the right way to convert the quaternion, and now it's leveling correctly.
(Terminal Velocity let you fly in every direction, but you couldn't keep the ship rotated around z axis as it always returned to 0 or 180°)

I’m always a little surprised how many people miss this: