|
Here is the code I made for the enemy's attack. This function is called by another script (in C#) using SendMessage("Attack");
I tried using yield WaitForSeconds, but it only lags the first attack, then the next few are consecutive. What should I do?
(comments are locked)
|
|
I guess the problem is that you are calling Attack in rapid succession. So the effect you'd see is that the first call gets delayed and all others get called immediately after the first one. What you need to do is using Attack as a Coroutine with a while loop inside. So you could transform your code into something like this (this should only give you an idea, it will not work as is):
Be aware that you have to call this routine only ONCE to start attacking. It will then continue to attack the target until it's out of range. So probably you'll also need a check if target died. I tried using this method with my current logic, but I end up hitting hit like 4 times after the lag.
Nov 03 '10 at 06:06 PM
SirVictory
Make sure you're calling Attack() only once to start attacking. Maybe you can post your current logic?
Nov 03 '10 at 10:15 PM
StephanK
(comments are locked)
|
|
An alternate solution would be to 'deactivate' function 'Attack()' by setting a state in the beginning and end. Such as:
If I'm not mistaken, attacking would only be set to false only after attacklag seconds has passed.
(comments are locked)
|
