{"id":179,"date":"2024-03-01T07:37:24","date_gmt":"2024-03-01T07:37:24","guid":{"rendered":"https:\/\/wildtechgames.com\/?p=179"},"modified":"2024-03-09T19:51:49","modified_gmt":"2024-03-09T19:51:49","slug":"my-unreal-engine-learning-journey-day-28-enemy-ai-pathfinding-and-bug-fixing","status":"publish","type":"post","link":"https:\/\/wildtechgames.com\/?p=179","title":{"rendered":"My Unreal Engine Learning Journey \u2013 Day 28 \u2013 Enemy AI, Pathfinding and Bug Fixing"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction:<\/h2>\n\n\n\n<p>I made it past the previous bug with torches and moved onto creating the first Enemy and some basic AI Pathfinding.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"718\" src=\"https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-1024x718.png\" alt=\"\" class=\"wp-image-181\" srcset=\"https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-1024x718.png 1024w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-300x210.png 300w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-768x539.png 768w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-1536x1077.png 1536w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image.png 1691w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Bug Fixing:<\/h2>\n\n\n\n<p>Previously I got stuck on a bug where the BP_Torch component of the player blueprint (attached to the body) didn&#8217;t show up when trying to connect to it within the BP_Webs blueprint.  I was doing it through casting to the BP_Player blueprint.  I have no explanation for this next part, but after restarting Unreal Engine it suddenly works and all of the player components are now showing up correctly.  I typically leave Unreal Engine open for days at a time, so may need to restart it more often to avoid weird bugs.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"658\" src=\"https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-1-1024x658.png\" alt=\"\" class=\"wp-image-182\" srcset=\"https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-1-1024x658.png 1024w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-1-300x193.png 300w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-1-768x493.png 768w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-1-1536x986.png 1536w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-1.png 1682w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"737\" src=\"https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-2-1024x737.png\" alt=\"\" class=\"wp-image-183\" srcset=\"https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-2-1024x737.png 1024w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-2-300x216.png 300w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-2-768x552.png 768w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-2-1536x1105.png 1536w, https:\/\/wildtechgames.com\/wp-content\/uploads\/2024\/03\/image-2.png 1685w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Enemy AI and Pathfinding:<\/h2>\n\n\n\n<p>Using Quixel Bridge I chose a character model for the first enemy of the game. I chose someone who kind of reminded me of the Terminator from Terminator 2. Not super close resemblance, but close enough.  <br><br>I then moved onto creating my very first enemy AI and pathfinding events.  Basic AI\/Pathfinding is very easy to do in Unreal Engine 5, but I can see how more advanced AI may take some time to think through, but also should be fun to create later on.  <br><br>First created the Enemy AI character class, added &#8216;sight&#8217; as it&#8217;s primary AI\/detection and then used a navMeshBoundary to create the space which allows the Enemy AI to navigate.  However I used specific Target Points for the actual pathing, meaning where the AI will try to walk to.  <br><br>The difference is the navMesh enables an &#8216;allowable area&#8217; for the Enemy AI\/pathfinding to navigate through and the Target Point tells the AI exactly where to go.  In Unreal Engine the built-in AI\/pathfinding already gives the AI\/Pathfinding enough knowledge of how to maneuver around or onto objects, such as moving around a corner of going up or down stairs, etc.  So a lot of the nuance is already moved right from the start.  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion:<\/h2>\n\n\n\n<p>For fun I also added a rectangle light to one of the dark tunnels just to see what it would look like. I really like the outcome!  <br><br>Next up will be giving the Enemy something to do besides walking between points, which in this case will be to chase the player when it sees the player.  <\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"My Unreal Engine Learning Journey \u2013 Day 28 \u2013 Enemy AI, Pathfinding and Bug Fixing\" width=\"640\" height=\"480\" src=\"https:\/\/www.youtube.com\/embed\/k59vjxKMWIM?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><br><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: I made it past the previous bug with torches and moved onto creating the first Enemy and some basic AI Pathfinding. Bug Fixing: Previously I got stuck on a bug where the BP_Torch component of the player blueprint (attached to the body) didn&#8217;t show up when trying to connect to it within the BP_Webs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1,8],"tags":[10,11,14,9],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/wildtechgames.com\/index.php?rest_route=\/wp\/v2\/posts\/179"}],"collection":[{"href":"https:\/\/wildtechgames.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wildtechgames.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wildtechgames.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wildtechgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=179"}],"version-history":[{"count":4,"href":"https:\/\/wildtechgames.com\/index.php?rest_route=\/wp\/v2\/posts\/179\/revisions"}],"predecessor-version":[{"id":186,"href":"https:\/\/wildtechgames.com\/index.php?rest_route=\/wp\/v2\/posts\/179\/revisions\/186"}],"wp:attachment":[{"href":"https:\/\/wildtechgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wildtechgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wildtechgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}