{"id":1265,"date":"2015-01-07T17:47:31","date_gmt":"2015-01-07T17:47:31","guid":{"rendered":"http:\/\/www.clonefactor.com\/wordpress\/?p=1265"},"modified":"2015-01-07T17:48:08","modified_gmt":"2015-01-07T17:48:08","slug":"rainai-and-mecanim","status":"publish","type":"post","link":"https:\/\/www.clonefactor.com\/wordpress\/program\/unity3d\/1265\/","title":{"rendered":"RAIN{AI} and Mecanim"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>\u7cfe\u7e8f\u4e86\u4e00\u6bb5\u6642\u9593\u7d42\u65bc\u7406\u89e3\u4e86\u57fa\u672c\u90e8\u4efd\u7684 RAIN{AI} \u7528\u6cd5.<\/p>\n<p>\u679c\u7136\u7a31\u5f97\u4e0a\u70ba\u5049\u5927..<\/p>\n<p><a href=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/01\/RainTest.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"162\" class=\"alignnone size-medium wp-image-1266\" src=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/01\/RainTest-300x162.jpg\" alt=\"RainTest\" srcset=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/01\/RainTest-300x162.jpg 300w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/01\/RainTest-1024x554.jpg 1024w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/01\/RainTest.jpg 1919w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u4e5f\u6c92\u6709\u4f7f\u7528\u5011\u4f55\u7a0b\u5f0f\u78bc\u5c31\u5b8c\u6210\u4e86 Auto follow AI, \u96d6\u7136\u6709\u9ede\u7b28, \u4f46\u6c92\u6709 coding \u7684\u60c5\u6cc1\u5f04\u5230\u9019\u4efd\u4e0a\u5be6\u5728\u4e0d\u80fd\u518d\u5f37\u6c42.<\/p>\n<p>just make it simple, the step you needed to setup your auto follow bot only need a few step.<\/p>\n<ol>\n<li>Create character name it &#8220;player&#8221; have movement controller (whatever you want)<\/li>\n<li>Select gameObject &#8220;player&#8221; using RAIN\/Create Entitly, to add Entitly inside that &#8220;player&#8221;\n<ol>\n<li>Fill in the config of &#8220;player&#8221; Entitly, in this case I just\u00a0named it &#8220;player&#8221;<\/li>\n<li>I set it as a vistual entitly, allow the AI to spot this gameObject\u00a0on radar.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>Now you finish the player part, now we need NPC.<\/p>\n<ol>\n<li>Create another character name it &#8220;bot&#8221; only need a Animator &amp; your custom style Mecanim controller\n<ol>\n<li>for walking, you will need at least 2 parameter &#8220;speed&#8221; &amp; &#8220;turn angle&#8221; on your Mecanim controller, name it whatever you want,<br \/>\nbut remember to set exactly\u00a0the same name in RAIN&#8217;s motor later.<\/li>\n<li>Reminder : Turn angle only allow to set within 360 degree in RAIN{AI}\u00a0Version: 2.1.7.2 (Dec 19, 2014)<\/li>\n<\/ol>\n<\/li>\n<li>Select gameObject &#8220;bot&#8221; using RAIN\/Create AI, to add AI\u00a0component inside that &#8220;bot&#8221;<\/li>\n<li>First thing first, switch to sensor tab, give this object have visual sensor,<br \/>\nit use this as eyes to see the player later.<\/li>\n<li>Switch to motor tab, add parameter the variable name of\u00a0&#8220;speed&#8221; &amp; &#8220;turn angle&#8221; in Mecanim controller.<\/li>\n<li>now &#8220;bot&#8221; can walk and see thing, but it still no BRAIN.<br \/>\nSwitch to mind tab, create a behaviors tree for it,<\/li>\n<li>Inside a behaviors tree, create a set of action for this &#8220;bot&#8221;\n<ol>\n<li>Create &#8220;sensor&#8221; I name it as &#8220;Search player&#8221; and put the world coordinate into the variable name &#8220;FollowTarget&#8221;<\/li>\n<li>Create &#8220;move&#8221; action, I name it as &#8220;Move to player&#8221;, it read the coordinate from &#8220;bot&#8221; &#8216;s mind.\u00a0&#8220;FollowTarget&#8221;<br \/>\nthen it will use &#8220;speed&#8221; &amp; &#8220;turn angle&#8221; different to find the path to go to the &#8220;player&#8221;,\u00a0automatically<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>here is the result.<\/p>\n<unitydog width=\"\"\"\" height=\"\"\"\" src=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/01\/RAIN_Test.unity3d.zip\"><\/unitydog>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u7cfe\u7e8f\u4e86\u4e00\u6bb5\u6642\u9593\u7d42\u65bc\u7406\u89e3\u4e86\u57fa\u672c\u90e8\u4efd\u7684 RAIN{AI} \u7528\u6cd5. \u679c\u7136\u7a31\u5f97\u4e0a\u70ba\u5049\u5927.. &#038; &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[61,16,17,62,43],"class_list":["post-1265","post","type-post","status-publish","format-standard","hentry","category-unity3d","tag-ai","tag-c-2","tag-camera","tag-coordinate","tag-unity3d-2"],"_links":{"self":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1265"}],"version-history":[{"count":0,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1265\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}