|
Hi! I'm writing a simple enemy AI for a game I'm making, and as of now it should just have two different attacks which would be picked randomly(even tho its just one or the other, but hey...) here's how it should be working: I made a "dice" that will only generate a number when the player is in range, then stop. If the player is in range the enemy will start attacking based on what number was thrown and turn the dice back on afterwards. The dice will generate a new number and the next attack should follow. It does this pretty nicely some times, however sometimes it simply keeps throwing numbers making the enemy use multiple attacks at the time. I can't seem to find out why tho, does anybody know where I went wrong? Here's the script:
(comments are locked)
|
|
I think that the problem relies on the absence of a lock, that will "block" the Update call when the action have already took place. In other words, I think that the Update procedure is a bit long to "stay" in a single frame; that is, you could have multiple calls to the Attack() function in a single frame, and the result is an enemy that attacks many times, even if his "turn" would be finished. I would modify the script in the following way: Declaring a boolean function at the beginning: Then, modify the Update() function this way: Hope that it works. Let me know... Hi, I'm not sure, but that is what I was trying to do with the canRoll variable, but I guess this would work better, I'll try it out when I get home!:D
Dec 16 '11 at 08:39 AM
SomeRandomGuy
D: finally got to testing this out and it still seems to be doing some weird things. At first they did seem to be lining up correctly, however after a while they still got strangled up, making the particle emitters timing all wrong and not playing the sword animation completely every now and then. I'm amazed at how hard it is to do this, all I really need to do is set some sort of small interval between attacks... Anyways, thanks for trying, I'll just have to learn a bit more about how to make these things before I try this again 8D
Dec 19 '11 at 07:36 PM
SomeRandomGuy
(comments are locked)
|
