Hi,
I have a problem with counting front flips. The problem here is when the hero makes a back flip it still counts and I don’t want it.
Here’s a video of it:
Script:
using UnityEngine;
using System.Collections;
public class Flip : MonoBehaviour {
public float flips = 0;
public float maxFlip = 12;
public float deltaRotation = 0;
public float currentRotation = 0;
public float WindupRotation = 0;
void Update () {
deltaRotation = (currentRotation - transform.eulerAngles.z);
currentRotation = transform.eulerAngles.z;
if (deltaRotation <= -300)
deltaRotation += 360;
if (deltaRotation < 0)
deltaRotation = 0;
WindupRotation += (deltaRotation);
flips = WindupRotation / 360;
if (flips >= maxFlip) {
flips = maxFlip;
}
}
}
Is there a way to prevent it? Thanks for your help.