|
OK I've made some changes to my Alien Zombie AI script but I still can't seem to get it to function the way it sould. Right now my Alien Zombies will follow me arround like lost puppies if I get within their attack range. And when I get out of range instead of returning to their patrol routine or even going back to just plain "Idle" they kind of run on the spot doing their "RunAttack" animation?? It's cufuddling me buggy trying to figure out why they are doing that. Also I can't figure out how to get my Alien Zombie to inflict damage to my FPS player using his "Attack" animation when he is right in front of him or right up close if you like?? Here is my code so far: Sorry for posting this same question only asked differently but they seem to get lost after a while and get no more responses.
(comments are locked)
|
|
The animation can fool you -- for example, your code may be correctly not moving for a while, but the runAttack animation you started 6 seconds ago is still playing, so you think the code is trying to run. Maybe leave animation off, so you can focus on the movement and turning. Once the code works, there are usually very obvious places to set animation. For example, whenever the code sets direction to 0, also play "idle." For checking the move code, these are two old programming tricks, Unity style: o Add things like o Show some vars in the inspector: Make Eventually, you'll get a result that isn't what you expected, which leads to the problem. Thanks Pat for the awesome advice. But looking at my code can you spot any what might be obvious errors to someone far more code savy than I? I've been checking the Unity Animation script reference but I can't seem to get much headway from that. I'm such a "noob" ;)
Mar 22 '11 at 05:27 PM
Michael 12
Do the animation later, after the motion is done. Focus on why it won't return to the waypoint after attacking. If you have zero animation, it will be much easier to see if it is stopped, or just moving very slowly (for example.) I didn't spot any obvious problems.
Mar 23 '11 at 09:08 PM
Owen Reynolds
I'm not sure what's going on inside of this thing. I've noticed that sometimes when I'm out of range they will wander back to their waypoint and sometimes they just sort of "Run on the Spot" at the last place where I sudenly bacame out of range. Plus, and this is the REALLY big pain in the ass, is I have STILL NOT been able to figure out haw to make these guys actually attack my player and inflict damage. It's getting to the pount where I'm just going to say "Frak It!" and just give them weapons and make a gun fire animation and just do it that way which is TOTALLY NOT what I want! :(
Mar 25 '11 at 02:33 PM
Michael 12
Test until you see a pattern -- maybe they are OK if they lose you out of attack range, but get stuck going from attack range to out-of-sight. That will narrow down the problem. Highlight the enemy and watch what the variables are. For attack, break it down. Do 1 point of damage every frame you are in range. Then think how to wait in between damage ticks (another coroutine? A
Mar 25 '11 at 04:19 PM
Owen Reynolds
How does that work with his "Attack" animation though. Heck I don't really understand how this script call the other animations into play. That FPS tutorial does not get into HOW that AI script works they just say attach this tou your robot and then do this and that and the other things and Whallah! Your robot works. There is an AI animation script and I guess they somehow talk to each other but where and how I don't understand. Right now this is a MAJOR stumbling block for me been searching all over hells 1/2 acre trying to find answers too.
Mar 25 '11 at 09:06 PM
Michael 12
(comments are locked)
|
|
Try setting rotation speed a little bit higher, if they spin around you in circles. I hope this answers your question! ;)
(comments are locked)
|

This is barely an answer, but I would check out what SpeedModifier is doing with a Debug.Log. That's mainly because I don't really understand or trust "dot". If you totally know what that's doing, disregard. Also, "while (true) {" sticks out as something I wouldn't write. Have several boolean variables declared at the top and check them;
I think you need to have distinct modes for your enemy and maybe now you don't. That is, either it's patrolling, or it's chasing the player, or it's attacking, but make sure it's never trying to do more than one thing at a time. Right now it may be running more than one of those functions at the same time which causes the 'lost puppy' behavior.
Is this just an edit of the FPS tutorial robot script?
To make the attack animation do damage I could write a little something that would work for the robot of that tutorial. I would attach a ball collider to this hand that did damage to things inside when it was "fired"