Separating backflips and frontflips counter

Hi,

To count backflips or frontflips I use flips = rigidbody2D.rotation / 360;

Example :

Hold right button and player rotates 1080°. Which equals to 3 frontflips (1080/360=3).
But then when I hold Left and do 1 full rotation backwards, I get " flips = 2 " (it does 3 - 1 = 2).

I’d like to seperate backflips and frontflips so that they work independently and display something like :

3 full rotations left = 3 backflips
then 1 full rotation right = 1 frontflip and not 3 - 1 = 2 frontflips like it does now.

How can I do that ? Thanks for reading

Store the rotation when the player presses the rotate Left and rotate Right (ONLY on ON) and calculate the min and max for a rotation (min = rotation-360; max = rotation+360. This will give you the angles that need to be achieved (do % 360 * 360 if this always has to be a complete rotation around 0°). If the rotation passes min and max degrees add a rotation to the counter and recalculate the next min and max position.

Maybe after a front flip you can add one to the front flip counter and then substract the rotation by 360, and after a back flip add one to counter and add 360 to the rotation.

Like

`

int front, back;

void update()

{

if(rotation > 360)

{

	front++;

	rotation -= 360;

}

if(rotation < -360)

{

	back++;

	rotation += 360;

}

}
`