- Home /
Calling an attack function.
This is killing me.
In my update section I have various functions. The the player is in the vicinity, move towards him. When close enough, attack him.
When the attack happens I want a registered hit of health from the player. So if the player has 20 power, it gets -5.
Then the key is I want to wait 3-4 seconds and take another 5 health away.
I'm using javascript and I've been exploring coroutines using the yield statement. But it isn't working as I want.
Right when the enemy attacks all my power drops and I die. I know this is because the update is called every frame, so it's an instant decrease of 5 health over and over.
How can I fix this?
There is something I'm not getting. I understand why it's happening but am having trouble fixing this.
Please walk me through any ideas with hand holding. I'm a noob.
Why does it take sooooooo long for an ad$$anonymous$$ to approve comments?
Your answer
Follow this Question
Related Questions
#ifdef UNITY_IPHONE equivalent for JavaScript 2 Answers
Reverse animation at the point it stopped playing 1 Answer
Is there a performance difference between Unity's Javascript and C#? 6 Answers
Referencing A Class From A Different Script ( Javascript ) 0 Answers
Need tips for optimizing main func that loops through thousands of particles 0 Answers