糾纏了一段時間終於理解了基本部份的 RAIN{AI} 用法.
果然稱得上為偉大..
也沒有使用們何程式碼就完成了 Auto follow AI, 雖然有點笨, 但沒有 coding 的情況弄到這份上實在不能再強求.
just make it simple, the step you needed to setup your auto follow bot only need a few step.
- Create character name it “player” have movement controller (whatever you want)
- Select gameObject “player” using RAIN/Create Entitly, to add Entitly inside that “player”
- Fill in the config of “player” Entitly, in this case I just named it “player”
- I set it as a vistual entitly, allow the AI to spot this gameObject on radar.
Now you finish the player part, now we need NPC.
- Create another character name it “bot” only need a Animator & your custom style Mecanim controller
- for walking, you will need at least 2 parameter “speed” & “turn angle” on your Mecanim controller, name it whatever you want,
but remember to set exactly the same name in RAIN’s motor later. - Reminder : Turn angle only allow to set within 360 degree in RAIN{AI} Version: 2.1.7.2 (Dec 19, 2014)
- for walking, you will need at least 2 parameter “speed” & “turn angle” on your Mecanim controller, name it whatever you want,
- Select gameObject “bot” using RAIN/Create AI, to add AI component inside that “bot”
- First thing first, switch to sensor tab, give this object have visual sensor,
it use this as eyes to see the player later. - Switch to motor tab, add parameter the variable name of “speed” & “turn angle” in Mecanim controller.
- now “bot” can walk and see thing, but it still no BRAIN.
Switch to mind tab, create a behaviors tree for it, - Inside a behaviors tree, create a set of action for this “bot”
- Create “sensor” I name it as “Search player” and put the world coordinate into the variable name “FollowTarget”
- Create “move” action, I name it as “Move to player”, it read the coordinate from “bot” ‘s mind. “FollowTarget”
then it will use “speed” & “turn angle” different to find the path to go to the “player”, automatically
here is the result.