Hey I’m making a game where you get points for doing 360’s and 180’s and such.
I’m trying to calculate how many turns the vehicle does when a wheel colider is no longer grounded.
I have no clue on using quaternion math so can anyone off some suggestions?
I’ve already got a basic algorithm working but it has flaws like if the vehicle somehow changes direction, it wouldn’t know. I’m looking for an elegent way of doing this.
function DoTricks() {
if( StartRot.x == 0 ) {
StartRot.x = (int)transform.localEulerAngles.x;
StartRot.y = (int)transform.localEulerAngles.y;
StartRot.z = (int)transform.localEulerAngles.z;
}
var CurRot : Vector3;
CurRot.x = (int)transform.localEulerAngles.x;
CurRot.y = (int)transform.localEulerAngles.y;
CurRot.z = (int)transform.localEulerAngles.z;
if( (int) CurRot.x > (int) LastRot.x )
RotDegress.x++;
else if( (int) CurRot.x < (int) LastRot.x )
RotDegress.x--;
if( (int) CurRot.y > (int) LastRot.y )
RotDegress.y++;
else if( (int) CurRot.y < (int) LastRot.y )
RotDegress.y--;
if( (int) CurRot.z > (int) LastRot.z )
RotDegress.z++;
else if( (int) CurRot.z < (int) LastRot.z )
RotDegress.z--;
Rotations.x = RotDegress.x / 360;
Rotations.y = RotDegress.y / 360;
Rotations.z = RotDegress.z / 360;
LastRot.x = (int)transform.localEulerAngles.x;
LastRot.y = (int)transform.localEulerAngles.y;
LastRot.z = (int)transform.localEulerAngles.z;
}
It’s mess and at the moment and horribly inacurate.
Can anyone offer a better way?