- Home /
Check animator animation finished?
I am a new Unity user an sorry for noob question. i am trying to make a game when i clikc to button a hero will perform a skill. i am using animator system and have 19 skills tagged "Skills".i need to make when any skill animaton finished set bool false. and when normalizedtime of animation is 0.5f create a damage effect or damagetext.
using UnityEngine;
using System.Collections;
public class Hero : MonoBehaviour {
public bool fighting;
public Animator anim;
public AnimatorStateInfo animState;
void Start () {
anim = GetComponent<Animator> ();
}
void Update () {
Debug.Log (animState.normalizedTime);
animState = anim.GetCurrentAnimatorStateInfo (0);
if (fighting) {
if(animState.IsTag("Skill"))
if(animState.normalizedTime>=0.99f) fighting=false;
}
if(Input.GetKey(KeyCode.Q))skill1();
if(Input.GetKey(KeyCode.W))skill2();
}
public void skill1(){
if(!fighting){
anim.SetTrigger ("1");
fighting = true;}
}
public void skill2(){
if(!fighting){
anim.SetTrigger ("2");
fighting = true;}
}
}
sorry for bad english. (dilimi konuşan varmı:)
Comment
Your answer
Follow this Question
Related Questions
Length of Animation from Animator 0 Answers
2D Animation does not start 1 Answer
My player won't jump? 1 Answer
Animation stops rotation 0 Answers
Animate character sitting in a chair 1 Answer