- Home /
Animator into OnCollisionEnter
i am new in unity.i have a fps shooter and monster enemy controled by an AnimatorController and set colliders like image .a script attach to colliders EnemeyHealth.i want when a bullet tag inter the collider dead enemy and play animation by Animator into OnCollisionEnter().plaese help me .this is my code
using UnityEngine; using System.Collections; public class EnemyHealth : MonoBehaviour { public int Health_Enemy=5; public int damage=1; private int wait_time=2; public Animator bossanim; void Start() { bossanim = GetComponent (); } // Use this for initialization void OnCollisionEnter(Collision rocket) { DecreasingHealth (); } void DecreasingHealth () { Health_Enemy = Health_Enemy - damage; } void Update() { / if (Health_Enemy <0 ) { bossanim.SetBool ("Die", true); print ("Dead Enemy"); } } }
Your answer
![](https://koobas.hobune.stream/wayback/20220612111232im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Adding new code to built client 0 Answers
ERROR BCE0043 i need help pls 1 Answer
Editor calling a constructor for no apparent reason 1 Answer