c# - AI Health Decrement -
i developing game in unity, need enemy attack , objects health decrease. attack sequence is: -
1) play attack animation 2) decrease health 3) repeat until dead
edited: sorry should have shown code, here is:
// check if ai in attack range if (transform.position == targetpostion) { // if target has more 0 health if (targethealthscript.health > 0) { // play animation , decrement health animation.play("bite"); targethealthscript.decrementhealth(10.0f); } }
the script written in c#
currently have working extent however, health decrement function keeps getting called repeatedly, need way slow down. have tried use coroutines yield statement without success.
if has suggestions grateful
thanks
try using update function if know how long animation take , use time.deltatimeenter link description here figure out how time has passed.
then decrease health based on them.
Comments
Post a Comment