{"id":65,"date":"2026-03-03T11:01:37","date_gmt":"2026-03-03T10:01:37","guid":{"rendered":"https:\/\/www.noocturnalgamesstudio.com\/blog\/2026\/03\/03\/design-credible-and-diverse-ai-in-unity-from-guards-to-zombies-with-a-modular-approach\/"},"modified":"2026-03-03T11:01:37","modified_gmt":"2026-03-03T10:01:37","slug":"design-credible-and-diverse-ai-in-unity-from-guards-to-zombies-with-a-modular-approach","status":"publish","type":"post","link":"https:\/\/www.noocturnalgamesstudio.com\/blog\/2026\/03\/03\/design-credible-and-diverse-ai-in-unity-from-guards-to-zombies-with-a-modular-approach\/","title":{"rendered":"Design Credible and Diverse AI in Unity: From Guards to Zombies with a Modular Approach"},"content":{"rendered":"<div style='font-family: system-ui, -apple-system, sans-serif; line-height: 1.8; color: #e2e8f0; font-size: 16px;'>\n<p style='margin-bottom: 15px;'> One of the biggest challenges for an indie developer is making enemies feel alive without the project collapsing under the weight of monolithic, thousand-line scripts. We have all been there: a single AI script trying to handle patrols, combat, stealth, and alert states, becoming a debugging nightmare. <\/p>\n<p style='margin-bottom: 15px;'> At Noocturnal Games Studio, we believe the key is not writing more complex code, but designing smarter systems. Today we show you how our &#8216;Personality by Composition&#8217; approach allows you to build unique AI archetypes by combining plug-and-play components. <\/p>\n<hr style='border: 0; border-top: 1px solid #4a5568; margin: 30px 0;'>\n<h3 style='color: #39FF14; margin-top: 30px; font-weight: 700; letter-spacing: 0.5px;'> Goodbye Spaghetti Code: The Modular Philosophy <\/h3>\n<p style='margin-bottom: 15px;'> Imagine your AI as a LEGO set. Instead of one giant script, you have specialized pieces (Addons) that do one single thing extremely well. This decoupled architecture allows your NPCs to be incredibly flexible. <\/p>\n<div style='background-color: rgba(255, 255, 255, 0.05); border-left: 3px solid #f687b3; padding: 15px; margin-bottom: 20px; border-radius: 0 8px 8px 0;'>\n<p style='margin-bottom: 0; font-style: italic;'> The secret lies in event-driven communication. Senses (like sight or hearing) emit signals that the muscles (movement or attack) listen to and execute automatically. <\/p>\n<\/p><\/div>\n<h4 style='color: #fff; margin-top: 30px; font-weight: 600;'> The Brain Components <\/h4>\n<ul style='color: #cbd5e0; margin-bottom: 15px;'>\n<li><strong>PlayerDetector:<\/strong> The field of view with Line of Sight (LOS) validation.<\/li>\n<li><strong>SimpleChase:<\/strong> Optimized chase logic for NavMesh.<\/li>\n<li><strong>SearchBehavior:<\/strong> Persistence that makes the AI investigate the last place it saw you.<\/li>\n<li><strong>FleeBehavior:<\/strong> Tactical flight logic for non-combatant NPCs.<\/li>\n<\/ul>\n<hr style='border: 0; border-top: 1px solid #4a5568; margin: 30px 0;'>\n<h3 style='color: #39FF14; margin-top: 30px; font-weight: 700; letter-spacing: 0.5px;'> Creating Archetypes: Personality by Composition <\/h3>\n<p style='margin-bottom: 15px;'> Thanks to this kit, defining an enemy personality is as simple as dragging components into the Unity Inspector. Let is look at four classic examples: <\/p>\n<h4 style='color: #fff; margin-top: 30px; font-weight: 600;'> 1. The Standard Patrol Guard <\/h4>\n<p style='margin-bottom: 15px;'> You need an enemy that guards an area and chases you if spotted. Just combine: <\/p>\n<p> <code style='display:block; background: #1a202c; color: #68d391; padding: 10px; border-radius: 5px; margin: 5px 0; font-family: monospace; border: 1px solid #2d3748;'> AIController + PlayerDetector + SimplePatrol + SimpleChase + MeleeAttack <\/code> <\/p>\n<p style='margin-bottom: 15px;'> The system is self-subscribing: when the detector sees the player, the controller pauses the patrol and activates chase and attack automatically. <\/p>\n<h4 style='color: #fff; margin-top: 30px; font-weight: 600;'> 2. The Tactical Archer (AI with Minimum Distance) <\/h4>\n<p style='margin-bottom: 15px;'> An archer that stands still is an easy target. By using <code style='background: #1a202c; padding: 2px 5px;'>RangedAttack<\/code> alongside <code style='background: #1a202c; padding: 2px 5px;'>SimpleChase<\/code>, you can set a &#8216;Minimum Distance&#8217;. If the player gets too close, the archer will automatically back away to maintain its tactical advantage. <\/p>\n<h4 style='color: #fff; margin-top: 30px; font-weight: 600;'> 3. The Horde Zombie (Social AI) <\/h4>\n<p style='margin-bottom: 15px;'> Zombies usually do not patrol; they wait. But when one sees you, everyone should know. By adding the <code style='background: #1a202c; padding: 2px 5px;'>Alerter<\/code> and <code style='background: #1a202c; padding: 2px 5px;'>AlertReceiver<\/code> components, you create a social AI network: <\/p>\n<div style='background-color: rgba(255, 255, 255, 0.05); border-left: 3px solid #f687b3; padding: 15px; margin-bottom: 20px; border-radius: 0 8px 8px 0;'>\n<p style='margin-bottom: 0;'> Zombie A detects you -> Emits an alert -> Zombie B (who has not seen you) receives the alert and enters chase state immediately. <\/p>\n<\/p><\/div>\n<hr style='border: 0; border-top: 1px solid #4a5568; margin: 30px 0;'>\n<h3 style='color: #39FF14; margin-top: 30px; font-weight: 700; letter-spacing: 0.5px;'> Performance: AI that does not drain your CPU <\/h3>\n<p style='margin-bottom: 15px;'> Many AI systems fail because they run too many Raycasts in the Update() method. Our kit uses optimized Coroutines and a C# event-based system. <\/p>\n<p style='margin-bottom: 15px;'> Instead of asking every frame &#8216;Do I see the player?&#8217;, the <code style='background: #1a202c; padding: 2px 5px;'>PlayerDetector<\/code> performs staggered checks and only notifies the controller when there is a real state change. This allows dozens of active agents simultaneously without frame drops, vital for VR projects or mobile devices. <\/p>\n<h3 style='color: #39FF14; margin-top: 30px; font-weight: 700; letter-spacing: 0.5px;'> Conclusion <\/h3>\n<p style='margin-bottom: 15px;'> Creating diverse AI does not have to be a Herculean task. With Noocturnal Games Studio modular approach, you can go from a basic prototype to a horde of intelligent enemies in minutes, focusing on what really matters: the fun of your game. <\/p>\n<div style='background: linear-gradient(145deg, #1a202c, #2d3748); border: 1px solid #4a5568; padding: 25px; border-radius: 12px; margin-top: 40px; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.3);'>\n<p style='margin-bottom: 10px; font-weight: bold; color: #fff; font-size: 1.1em;'>Level up your game today<\/p>\n<p style='margin-bottom: 0; color: #cbd5e0;'>Get this asset on the <a href='#' style='color: #39FF14; text-decoration: underline; font-weight: bold;'>Unity Asset Store<\/a>.<\/p>\n<\/p><\/div>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>One of the biggest challenges for an indie developer is making enemies feel alive without the project collapsing under the weight of monolithic, thousand-line scripts. We have all been there: a single AI script trying to handle patrols, combat, stealth, and alert states, becoming a debugging nightmare. At Noocturnal Games Studio, we believe the key [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-sin-categoria"],"_links":{"self":[{"href":"https:\/\/www.noocturnalgamesstudio.com\/blog\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.noocturnalgamesstudio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.noocturnalgamesstudio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.noocturnalgamesstudio.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.noocturnalgamesstudio.com\/blog\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":0,"href":"https:\/\/www.noocturnalgamesstudio.com\/blog\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.noocturnalgamesstudio.com\/blog\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.noocturnalgamesstudio.com\/blog\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.noocturnalgamesstudio.com\/blog\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}