Hey guys,
I’m trying to figure out how to tell when my vehicle does a complete 360 degrees flip. What I need to do is when the player jumps the bike, is store the current rotation, and as the bike rotates backwards or forward, I need to keep track of the rotation and detect when it gets back to the starting rotation stored when the player first started the jump.
I am not quite sure what to use to store the starting rotation. Should I use rigidbody.rotation or trabsform.eulerAngles or maybe transform.up…then I imagine keeping track of the rotation would be something similar to:
// Starting rotation
Vector3 startRotation = Vector3.Zero;
if( bikeJustLeftGround == true )
{
startRotation = transform.eulerAngles;
bikeJustLeftGround = false;
}
// rotation of bike compared to starting rotation
float currentRotation = Vector3.Dot( transform.up, startRotation );
// And then...
if( currentRotation == startRotation.z )
{
Debug.Log("DID A FLIP!!!");
}
I can’t really get the above code to behave the way I need it to behave. Rotations confuse me and I need some help on this one for sure haha
Thanks for your time guys!
Stephane