{"id":2297,"date":"2017-06-16T19:22:27","date_gmt":"2017-06-16T10:22:27","guid":{"rendered":"http:\/\/nantoka.filmm.info\/blog\/?p=2297"},"modified":"2017-06-16T19:32:22","modified_gmt":"2017-06-16T10:32:22","slug":"a%e9%96%a2%e4%bf%82%ef%bc%8c%e8%a4%87%e6%95%b0%e3%82%ad%e3%83%a3%e3%83%a9%e3%82%af%e3%82%bf%e3%82%92%e8%a4%87%e6%95%b0%e3%81%ae%e3%83%9d%e3%82%a4%e3%83%b3%e3%83%88%e3%81%ab%e5%90%91%e3%81%8b%e3%82%8f","status":"publish","type":"post","link":"https:\/\/nantoka.filmm.info\/blog\/?p=2297","title":{"rendered":"A*\u95a2\u4fc2\uff0c\u8907\u6570\u30ad\u30e3\u30e9\u30af\u30bf\u3092\u8907\u6570\u306e\u30dd\u30a4\u30f3\u30c8\u306b\u5411\u304b\u308f\u305b\u308b"},"content":{"rendered":"<p>\u4f5c\u6210\u4e2d<\/p>\n<pre class=\"lang:default decode:true \" title=\"myscript.cs\">using UnityEngine;\r\nusing System.Collections;\r\nusing System.Collections.Generic;\r\nusing UnityStandardAssets.Characters.ThirdPerson;\r\n\r\npublic class myscript : MonoBehaviour {\r\n\t\r\n\tpublic GameObject myInstance;\/\/for prefab\r\n\tpublic GameObject myGoal;\/\/for goal object\r\n\tpublic int sakusei = 10;\/\/chara duplicate count\r\n\tpublic GameObject targetbj;\/\/GameObject of chara target\r\n\tTransform targetPos;\/\/\u4f4d\u7f6e\u60c5\u5831\u7528\u306e\u5909\u6570\r\n\tGameObject NavObj;\/\/NavMesh\u306e\u3064\u3044\u3066\u3044\u308bGameObject\r\n\tNavMeshAgent myNav;\/\/NavMeshAgent\u5165\u308c\u7528\r\n\r\n\tList&lt;Vector3&gt; myPoint = new List&lt;Vector3&gt;();\/\/\u30b4\u30fc\u30eb\u5730\u70b9\u30ea\u30b9\u30c8\u7528\r\n\r\n\t\/\/ Use this for initialization\r\n\tvoid Start () {\r\n\t\tmyPoint = new List&lt;Vector3&gt;();\/\/\u30ea\u30b9\u30c8\u521d\u671f\u5316\r\n\t\tmyPoint.Add (new Vector3 (0.0f, 0.5f, -5.0f));\/\/\u30ea\u30b9\u30c8\u9805\u76ee\u8ffd\u52a0   \r\n\t\tmyPoint.Add (new Vector3 (-20f, 0.5f, 14f));\r\n\t\tmyPoint.Add (new Vector3 (20f, 0.5f, 14f));\r\n\r\n\t\t\/\/\u30b4\u30fc\u30eb\u5730\u70b93\u500b\u4f5c\u6210\u7528\uff08\u30c6\u30b9\u30c8\uff09\r\n\t\tGameObject goalObj = Instantiate (myGoal, myPoint [0], Quaternion.identity) as GameObject;\r\n\t\tgoalObj.name =  \"goal1\";\r\n\t\tgoalObj = Instantiate (myGoal, myPoint [1], Quaternion.identity) as GameObject;\r\n\t\tgoalObj.name =  \"goal2\";\r\n\t\tgoalObj = Instantiate (myGoal, myPoint [2], Quaternion.identity) as GameObject;\r\n\t\tgoalObj.name =  \"goal3\";\r\n\r\n\t\t\/\/\u30ad\u30e3\u30e9\uff4e\u4f53\u4f5c\u6210\r\n\t\tfor (int i = 0; i &lt; sakusei; i++) {\r\n\t\t\tGameObject go = Instantiate (myInstance, new Vector3 (i + 1.0f, 0, 0), Quaternion.identity) as GameObject;\r\n\t\t\tstring myAIname =  \"AI\" + i.ToString ();\r\n\t\t\tgo.name = myAIname;\r\n\t\t\tint divideInt = i % 3;\r\n\t\t\tif (divideInt == 0) {\r\n\t\t\t\tGameObject my1 = GameObject.Find(\"goal1\");\r\n\t\t\t\ttargetPos = my1.GetComponent&lt;Transform&gt; ();\r\n\t\r\n\t\t\t}else if (divideInt == 1) {\r\n\t\t\t\tGameObject my2 = GameObject.Find(\"goal2\");\r\n\t\t\t\ttargetPos = my2.GetComponent&lt;Transform&gt; ();\r\n\t\t\t}else if (divideInt == 2) {\r\n\t\t\t\tGameObject my3 = GameObject.Find(\"goal3\");\r\n\t\t\t\ttargetPos = my3.GetComponent&lt;Transform&gt; ();\r\n\t\t\t}\r\n\r\n\t\tmyNav = NavObj.GetComponent&lt;NavMeshAgent&gt; ();\/\/Get Nav mesh from current object\r\n\r\n\t\t\tmyNav.SetDestination (targetPos.position);\/\/set goal pos of myNav\r\n\t\t\tmyNav.stoppingDistance = 3.0f;\/\/offset distance from goal point...korenaito guriguri suru\r\n\t\t\tAICharacterControl  myTar  = NavObj.GetComponent&lt;AICharacterControl&gt;();\/\/find component of NabObj\r\n\t\t\tmyTar.target = targetPos;\/\/set Goal variable\r\n\r\n\t\t}\r\n\t}\r\n\t\r\n\t\/\/ tsukotenai\r\n\tvoid Update () {\r\n\t\r\n\t}\r\n}\r\n<\/pre>\n<div style=\"width: 474px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-2297-1\" width=\"474\" height=\"356\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"http:\/\/nantoka.filmm.info\/blog\/wp-content\/uploads\/2017\/06\/crowdWalking2.mp4?_=1\" \/><a href=\"http:\/\/nantoka.filmm.info\/blog\/wp-content\/uploads\/2017\/06\/crowdWalking2.mp4\">http:\/\/nantoka.filmm.info\/blog\/wp-content\/uploads\/2017\/06\/crowdWalking2.mp4<\/a><\/video><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u6210\u4e2d using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityStandardAssets.C &hellip; <a href=\"https:\/\/nantoka.filmm.info\/blog\/?p=2297\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">A*\u95a2\u4fc2\uff0c\u8907\u6570\u30ad\u30e3\u30e9\u30af\u30bf\u3092\u8907\u6570\u306e\u30dd\u30a4\u30f3\u30c8\u306b\u5411\u304b\u308f\u305b\u308b<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,2],"tags":[],"class_list":["post-2297","post","type-post","status-publish","format-standard","hentry","category-c","category-unity"],"_links":{"self":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2297"}],"version-history":[{"count":3,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2297\/revisions"}],"predecessor-version":[{"id":2302,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2297\/revisions\/2302"}],"wp:attachment":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}