|
Hi all. I currently have a script where an enemy will follow me around. I'd like to change it a little so that he attacks me when he gets close and also he wont start to follow me untill i'm so close and if I get too far away he'll quit following. Here's the script I have so far
thanks for the help!
(comments are locked)
|
|
Try this. It's untested, but basically I have made a few additions to your code which (along with the comments) should be fairly self-explanatory. Basically I'm using three different numeric "threshold" variables against which the current distance to the target is checked. These are used to switch between the 'chasing' and 'not chasing' state. Also, within the chasing state code, there's now an attack clause which checks the time to make sure it only occurs once every certain time period (defined in the initial variables).
If you can't get it to work, or have any other questions, ask as a comment below! works great! Now I have to learn scripting health and random spawning lol. Thanks for the help!
Nov 08 '10 at 06:23 PM
cidmodder
for some reason now it pauses and makes me have to go through every frame individually. any idea why?
Nov 15 '10 at 10:21 PM
cidmodder
This sounds unrelated to the code above. Have you added a Debug.Break() anywhere in your scripts?
Nov 16 '10 at 09:25 AM
duck ♦♦
I found the problem. I had acidentaly clicked error on pause hahah
Nov 16 '10 at 04:08 PM
cidmodder
I have been trying several things with the attack function but no matter what I do its not takeing away my health. the most recent attempt was target.SendMessage( "ApplyDamage", 10); but still my heatlh isnt going down. any suggestions?
Nov 17 '10 at 06:40 PM
cidmodder
(comments are locked)
|
|
@cidermodder This link might help you with the health bar part. It's a 3 part written tutorial. I hope it helps. @cidermodder Check the link, it is worth the chekc.It is worth a tutorial.
Dec 27 '12 at 09:15 AM
skilful2000
(comments are locked)
|
