Hi guys, I'm trying to combine quaternions so that two rotations I make are combined.
Every frame I'm rotating a game object in it's Y axis (Rotation A):
transform.rotation = Quaternion.AngleAxis ( actualAngle-(90f) , Vector3.up ) ;
And when a key is pressed, I want to rotate the character on his Z axis while preserving the previous rotation :
transform.rotation = Quaternion.AngleAxis ( 90f, -transform.forward )
However, I'm assuming that Rotation A is overwriting the second rotation, as the character does flip on his Z axis, but only for a frame.
I understand you can combine quaternions by multiplying them, but if do this to Rotation A:
transform.rotation = Quaternion.AngleAxis ( actualAngle-(90f) , Vector3.up ) * transform.rotation ;
The character continually rotates and spins out of control. So I'm not really sure where I'm going wrong?
Thanks for any help, really appreciated.
↧