getting and re-applying object rotation

Started by dutch_delight, April 04, 2012, 11:26:44 PM

Previous topic - Next topic

dutch_delight

Hi all,

I'm struggling with saving my game state. basically when the player quits my game, I want to save the health, position and rotation of the player.
Everything works fine apart from the rotation part.

To rotate my player in the world, I use either a joystick or screen tilt input and apply it like this:
player.rotateY(rotation_value);

I thought that I could just take the value like this:
save_rotation_data_Y = player.getRotationMatrix().getYAxis().x

then when the game restarts, all objects are re-initialized (player rotation is back to default)
and then I reload the rotation data and apply it like this:
player.rotateY(save_rotation_data_Y);

But the rotation is not what it should be. The data saves and loads correctly (fuel, missiles, translation all are fine) but I dont think I'm looking in the right place for the rotation.
I've tried every axis and even tried saving out the rotation matrix but I know even less about that so I must be doing it wrong.


Any help would be very much appreciated.




EgonOlsen

Just save and restore the rotation matrix instead.