Answer the question
In order to leave comments, you need to log in
How to play animation from another object?
There is an Enemy on whose arm is a collider capsule. I need an animation for taking damage. When this collider comes into contact with the player's collider, his life is taken away. I also have a script where animations are played. How can I pass the animation play value from other code?
Collider contact code:
private void OnTriggerEnter(Collider collider)
{
GameObject dam = GameObject.FindWithTag("Player");
Health dhealth = dam.GetComponent<Health>();
dhealth.health -= damage;
}
public Animator anim;
void Start()
{
anim = GetComponent<Animator>();
}
private void OnTriggerEnter(Collider collider)
{
GameObject dam = GameObject.FindWithTag("Player");
Health dhealth = dam.GetComponent<Health>();
dhealth.health -= damage;
anim.SetTrigger("Damage");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question