Such a strange little error going on currently.
If I uncomment the line - Debug.Log (player.animation [“myCubeAnim”].length); - I get the value 1
However if I hide that and debug the normalised time of my animation I get a value like 0.976 , it actually differs which is strange.
I’m thinking it may have something to do with my ontriggerenter function?
On occasion it will hit 1 and debug my line, but it’s a very small chance of that happening.
My animation is exactly a second long, wrapped to once.
Any ideas?
using UnityEngine;
using System.Collections;
public class playAnim : MonoBehaviour {
public GameObject player;
void OnTriggerEnter(Collider collider) {
if (collider.gameObject.name == "myTrigger") {
player.animation.Play("myCubeAnim");
}
}
void Update() {
Debug.Log (player.animation ["myCubeAnim"].normalizedTime);
//Debug.Log (player.animation ["myCubeAnim"].length);
if ((player.animation ["myCubeAnim"].normalizedTime) >= 1) {
Debug.Log ("Hit");
}
}
}