thehankinator Posted March 5, 2016 Share Posted March 5, 2016 (edited) http://steamcommunity.com/sharedfiles/filedetails/?id=638782739 This is a modified version of MonsterAI.lua that adds a * FOV check when searching for the player (in degrees) * A simple system for controlling where and how your monster patrols the level. The script should work like the stock script if you do not set the Path property. This script does not handle walking animation because the Crawler doesn't have a walk animation out of box. Feedback welcome, I can think of a couple things that could be added to make this better but I am going to see what people think first. Make monster move to pivots around the map 1) Add a master pivot, give it a name like "CrawlerPath1" without quotes and put it off to the side out of the way 2) Add a pivot to your map that is in the position that you want to be your first point the monster will visit, name it "1" without quotes. 3) Make the pivot a child of "CrawlerPath1" 4) Repeat steps 2 and 3 however many times you want to but increment the number you use for the pivot name. In my map I placed 5 pivots, it looks like this: My CrawlerPath1 looks like this(note how order does not matter, the name defines the order): 5) Attach TH_MonsterAI.lua to your monster 6) Drag your CrawlerPath1 to the "Path" script property 7) Next you can set the behavior of the monster when it reaches the end of your path. Loop: At the end, the monster will go back to the first pivot, in map image I made above the monster would go to 1, 2, 3, 4, 5, then back to 1, forever. Reverse: At the end, the monster will go backward through the path in my example, the monster would go to 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, etc, forever. This one is nice if you want the monster patrolling a path. Stop: The monster would stop at the last point. 1, 2, 3, 4, 5. Actions at pivots That will make the monster move, but you can also add actions at each point. For each nav point you can attach the script TH_NavPointAction.lua. This will let you make the monster do actions at a pivot before moving on. The properties of this script are: Animation: This is a name of an animation you want the monster to do Action: "Delay" will make the monster do the animation set by the Animation property for any amount of time. "Do Animation X times" will have the monster do the animation set by the Animation property X times before moving on. ActionArg: When Action is set to "Delay", this is the amount of time to wait in milliseconds. When Action is set to "Do Animation X times" this is the number of times you want the monster to do the animation. AnimationSpeed: This is the speed which the animation is executed. Pivots now can have two functions: function Script:Arrive(entity) --do something when the monster arrives at this pivot end function Script:Depart(entity) --do something when the monster leaves this pivot end Edited March 31, 2016 by thehankinator 1 6 Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted March 12, 2016 Share Posted March 12, 2016 This is great stuff, works like a charm. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.