- Home /
Question by
rayith · Aug 21, 2021 at 08:13 PM ·
animationanimator controllerdamage
animation play the first time and then does not play again
2 animations I have set hit and death (the hit reacts once and never again, death doesn't play
hit - react to ray cast, loss health ,enemy animation as hit
death - react to ray cast, health = 0, enemy animation collapses, holds 5 secs, object destroyed
any suggestion
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.Animations;
public class Target : MonoBehaviour
{
public Animator controller;
public float health = 50f;
public GameObject Doll;
public void TakeDamage (float amount)
{
health -= amount;
controller.SetBool("hit", true);
if (health <= 0f)
{
controller.SetBool("death", true);
Die();
}
}
void Die()
{
Doll.SetActive(false);
}
}
aniamation.png
(35.9 kB)
Comment
After hit you return to idle? Also maybe better use trigger for hit.
Your answer
Follow this Question
Related Questions
Animate an Object by letting it play out in when I press play? 0 Answers
Animator Override Controller Layer Issue 1 Answer
Character starts halfway into ground out of play mode. 0 Answers
How to have one animator controller make multiple objects move? 0 Answers
Change Idle/Walk player animation permanently on trigger colliders 1 Answer