I thought I have solved my problem to count a front flip but unfortunately that wasn’t because I can’t decrease it.
Here is the url from my last question about this: Problem with counting front flips - Questions & Answers - Unity Discussions
I want only count with +1 if the hero makes a full rotation from 360 - 0 and then decrease the count to 0 when the hero collides with a boost.
using UnityEngine;
using System.Collections;
public class Flip : MonoBehaviour {
public float flips = 0;
public float fliptest;
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 < -180f)
deltaRotation += 360f;
if (deltaRotation > 180f)
deltaRotation -= 360f;
if (deltaRotation < 0)
deltaRotation = 0;
WindupRotation += (deltaRotation);
flips = WindupRotation / 360;
//tried also this
if(flips >= fliptest)
{
fliptest++;
}
//
if (flips >= maxFlip) {
flips = maxFlip;
}
}
void OnTriggerEnter2D(Collider2D coll){
if (coll.gameObject.tag == "Boost") {
fliptest = 0;
}
}
}
I hope you guys can help me. Thanks a lot.