{"id":3191,"date":"2016-07-03T23:59:45","date_gmt":"2016-07-03T22:59:45","guid":{"rendered":"http:\/\/phoenixgamedevelopment.com\/blog\/?p=3191"},"modified":"2016-07-04T00:02:04","modified_gmt":"2016-07-03T23:02:04","slug":"p-167-paranoia-update-17-debugging-ai-hunter","status":"publish","type":"post","link":"https:\/\/phoenixgamedevelopment.com\/blog\/p-167-paranoia-update-17-debugging-ai-hunter\/","title":{"rendered":"P-167: Paranoia: Update 17: Debugging Ai (Hunter)"},"content":{"rendered":"<p>I encountered a serious issue when preparing to implement the AI for my Hunter character.<\/p>\n<p>The nav mesh in T3D basically creates a navigable\u00a0surface around any objects that are present inside the bounds of the nav mesh. This worked fine earlier in the project, and then stopped working. I just got around to trying to fix it, and I discovered that the cause was the doors that I had added to the world. The door&#8217;s collision was taken into account by the nav mesh, and the AI was therefore unable to navigate through doorways.<\/p>\n<p>This caused a problem, because I needed to, first of all, create the navmesh with passages through the door ways, and second of all, I needed to allow the AI to open and close doors themselves.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_3184\" aria-describedby=\"caption-attachment-3184\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-29_06_2016-05_04_55-AM.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-3184\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-29_06_2016-05_04_55-AM-300x238.jpg\" alt=\"P167 Paranoia_DEBUG 29\/06\/2016 , 05:04:55 AM Torque 3D MIT - P167 Paranoia\" width=\"300\" height=\"238\" srcset=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-29_06_2016-05_04_55-AM-300x238.jpg 300w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-29_06_2016-05_04_55-AM-768x609.jpg 768w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-29_06_2016-05_04_55-AM-1024x812.jpg 1024w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-29_06_2016-05_04_55-AM.jpg 1026w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-3184\" class=\"wp-caption-text\">P167 Paranoia_DEBUG<br \/>29\/06\/2016 , 05:04:55 AM<br \/>Torque 3D MIT &#8211; P167 Paranoia<\/figcaption><\/figure>\n<figure id=\"attachment_3183\" aria-describedby=\"caption-attachment-3183\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-02_07_2016-10_26_53-PM.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-3183\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-02_07_2016-10_26_53-PM-300x238.jpg\" alt=\"P167 Paranoia_DEBUG 02\/07\/2016 , 10:26:53 PM Torque 3D MIT - P167 Paranoia\" width=\"300\" height=\"238\" srcset=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-02_07_2016-10_26_53-PM-300x238.jpg 300w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-02_07_2016-10_26_53-PM-768x609.jpg 768w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-02_07_2016-10_26_53-PM-1024x812.jpg 1024w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-02_07_2016-10_26_53-PM.jpg 1026w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-3183\" class=\"wp-caption-text\">P167 Paranoia_DEBUG<br \/>02\/07\/2016 , 10:26:53 PM<br \/>Torque 3D MIT &#8211; P167 Paranoia<\/figcaption><\/figure>\n<p>Thankfully, this turned out to be easier than I thought, since collision can be added and removed on an object dynamically, simply by changing the &#8220;collisionType&#8221; property of the object. I was therefore able to create the doors and collision boxes as normal, but disable the collision on the collision objects and add the collision objects to a simset. The Nav Mesh then created a mesh that included the doorways.<\/p>\n<p>Once the nav mesh was complete, I was then able to loop through the objects in the simset and\u00a0enable collision for them. I was then able to use a simple raycast to check for a door in the path of the AI, and open it if a door was found.<\/p>\n<p>This worked fine, except I had to temporarily disable collision for the door while the AI was passing through, since open door position was not added to the navmesh, and was blocking the AI in some cases.<\/p>\n<figure id=\"attachment_3181\" aria-describedby=\"caption-attachment-3181\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-06_42_37-PM.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-3181\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-06_42_37-PM-300x238.jpg\" alt=\"P167 Paranoia_DEBUG 03\/07\/2016 , 06:42:37 PM Torque 3D MIT - P167 Paranoia\" width=\"300\" height=\"238\" srcset=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-06_42_37-PM-300x238.jpg 300w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-06_42_37-PM-768x609.jpg 768w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-06_42_37-PM-1024x812.jpg 1024w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-06_42_37-PM.jpg 1026w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-3181\" class=\"wp-caption-text\">P167 Paranoia_DEBUG<br \/>03\/07\/2016 , 06:42:37 PM<br \/>Torque 3D MIT &#8211; P167 Paranoia<\/figcaption><\/figure>\n<p><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-05_48_43-PM.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-3182\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-05_48_43-PM-300x238.jpg\" alt=\"P167 Paranoia_DEBUG 03\/07\/2016 , 05:48:43 PM Torque 3D MIT - P167 Paranoia\" width=\"300\" height=\"238\" srcset=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-05_48_43-PM-300x238.jpg 300w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-05_48_43-PM-768x609.jpg 768w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-05_48_43-PM-1024x812.jpg 1024w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2016\/07\/PhoenixGameDevelopment-03_07_2016-05_48_43-PM.jpg 1026w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>P167 Paranoia_DEBUG<br \/>\n03\/07\/2016 , 05:48:43 PM<br \/>\nTorque 3D MIT &#8211; P167 Paranoia<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I encountered a serious issue when preparing to implement the AI for my Hunter character. The nav mesh in T3D basically creates a navigable\u00a0surface around any objects that are present inside the bounds of the nav mesh. This worked fine earlier in the project, and then stopped working. I just got around to trying to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-3191","post","type-post","status-publish","format-standard","hentry","category-software-and-games","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"aioseo_notices":[],"builder_content":"","_links":{"self":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts\/3191"}],"collection":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/comments?post=3191"}],"version-history":[{"count":6,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts\/3191\/revisions"}],"predecessor-version":[{"id":3199,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts\/3191\/revisions\/3199"}],"wp:attachment":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/media?parent=3191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/categories?post=3191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/tags?post=3191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}