{"id":605,"date":"2006-08-31T16:02:06","date_gmt":"2006-08-31T21:02:06","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=605"},"modified":"2008-08-16T09:48:41","modified_gmt":"2008-08-16T14:48:41","slug":"npcs-and-immersion","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=605","title":{"rendered":"NPCs and Immersion"},"content":{"rendered":"<p><table width='320'  cellpadding='0' cellspacing='0' border='0' align='left'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/quake4_alone.jpg' class='insetimage' width='320' alt='Quake 4: Strogg Base' title='Quake 4: Strogg Base'\/><\/td><\/tr><tr><td class='insetcaption'>All alone: This place can be pretty unnerving.  It would be much less so if I had an NPC following me around looking relaxed and staring into space. The best way to keep NPCs from messing with immersion is to leave them behind.<\/td><\/tr><\/table> Immersion is that much-sought quality in videogames that will make the player think and act as if they were really there.  Immersion is a prerequisite for any sort of emotional response.  If a developer wants the player to be frightened by a situation, sad over the death of a character, angry about a turn of events, or excited about overcoming an obstacle, they first need to convince them that they are part of the game world. <\/p>\n<p>Immersion is one of those qualities like creativity or morale: There is precious little you can do to enhance it, and a million ways you can kill it.  If the player is terrified while crawling through the enemy base, fighting foes in dimly-lit corridors while the walls breathe steam and the machinery casts threatening shadows onto the walls, he&#8217;s <em>immersed<\/em>.  Then let&#8217;s imagine that something stupid happens.  Maybe he finds some critical item like a key or a weapon just laying around or (worse) on <em>display<\/em> and free for the taking. Suddenly he&#8217;s pulled out of the game and remembers that despite the steam and shadows, this is still more or less a tenth-generation copy of the original Wolfenstein formula of gunning down bad guys and rounding up their key[card]s.  <\/p>\n<p>The quickest way to kill immersion is with non-player characters: NPCs. Friends and allies and such. I mentioned before about how <a href=\"?p=237\">your companion in Resident Evil 4 was such a goofy distraction that she killed any sense of fear the game was trying to build<\/a>.<\/p>\n<p>If an enemy monster is stupid (because its &#8220;brain&#8221; is just a couple of hundred lines of computer code running on a personal computer that is busy doing a lot of other stuff) it isn&#8217;t too bad.  <em>Hey, it&#8217;s a monster.  It&#8217;s not supposed to be smart. <\/em> But when a human character shows up the player expects him or her to act like a human.  Then when they walk into the player&#8217;s line of fire, get confused by doorways, get caught up on scenery, or utter the same phrase for the tenth time, they are exposed as a fraud and the illusion of the gameworld is broken. NPCs have so many ways they can break immersion that it&#8217;s difficult to enumerate them all.  I&#8217;ve <a href=\"?p=270\">written<\/a> about <a href=\"?p=274\">AI mishaps<\/a> in the past and how <a href=\"?p=117\">simple things can go absurdly wrong<\/a>, but you don&#8217;t need AI to go haywire to break immersion.  When dealing with NPCs, immersion can be destroyed even when everything is working right.  <\/p>\n<p><table width='320'  cellpadding='0' cellspacing='0' border='0' align='right'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/quake4_medics.jpg' class='insetimage' width='320' alt='Quake 4: Medic Lab' title='Quake 4: Medic Lab'\/><\/td><\/tr><tr><td class='insetcaption'>On display: Players might throw stuff at your NPC.  Shove them.  Stand in the middle of their conversation. If you want NPCs to fill in the game world but don&#8217;t want to deal with all of the strange things players might do to them, just stick your actors behind a glass wall and let them read their lines when the player strolls by.<\/td><\/tr><\/table>Here is a challenging task: Have the NPC follow the player.  The player character is a vortex of unpredictable actions and random behavior.  What will they do? Crawl around in the dark looking for secrets?  Climb over things trying to reach a high ledge? Start gunning down their own teammates?  Shoot stuff at random? Use explosives to try and catapult themselves up to high ledges? Stand in place for five minutes while the player walks away from the computer and makes a sandwich? Even when the player is doing stuff that doesn&#8217;t make sense, they still expect those NPCs to react to their insane actions in a realistic way.  <\/p>\n<p>&#8220;Following&#8221; is one of those things that seems obvious but is maddeningly complex in implementation.  In old games, the follower would always be four steps away, which was annoying.  As you wandered around the NPC would hover over you, dogging your steps and staring at you.  What it needed was to stop once it entered a room and stand nearby while the player explored.  Fine.  But this means NPC&#8217;s have to understand rooms and spaces, which is a tricky concept.  I&#8217;ve seen implementations where the NPC will simply try to keep the player in view.  If it can see you, it stands still, if you move out of sight, it will move to catch up.  Good plan, but you also need to take other factors into account.  If the player had to navigate through something dangerous to get where they are, the NPC probably shouldn&#8217;t attempt to follow.  If the player jumps into a deep hole, the NPC needs some sort of justification for continuing to follow this suicidal idiot. <em>Fine buddy, you wade through the slime and brave the jaws of that big stamping machine.  I&#8217;m staying here.<\/em>  <\/p>\n<p>But what does the NPC do while waiting for the player?  Stand still?  If you don&#8217;t want the NPC to seem like a complete jerk, it needs to sense when the player is trying to walk though and step out of the way. More importantly, if the NPC is going to stand around, what should it look at?  Having them look at something exceedingly dull with their backs to interesting scenery is no good. (Like turning its back on a huge window with stunning scenery to look at an air vent or a wall.  This looks odd and people notice.)   The same goes for staring into a pitch dark corner.  However, the logic needed to sort this out is very complex.  It&#8217;s a lot of work to just figure out which way to <em>look<\/em>, which is just step 1 of solving this problem.  When they aren&#8217;t busy, people tend to move around, fidget, make conversation, or find someplace to lean \/ sit \/ rest, so NPCs ought to do the same.  This translates directly into the need for more detailed models, more animations, more voice acting, and more scripting.  <\/p>\n<p>But we&#8217;re not done yet.  The NPC needs to run to the player&#8217;s side if a battle starts.  They need to be able to make the subjective judgment about friendly fire:  <em>Did the player just shoot me by accident or on purpose?<\/em> That&#8217;s tricky. And then the NPC needs a proper response for each.  <\/p>\n<p><table width='320'  cellpadding='0' cellspacing='0' border='0' align='left'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/quake4_pose.jpg' class='insetimage' width='320' alt='Quake 4: Marines and signal flares' title='Quake 4: Marines and signal flares'\/><\/td><\/tr><tr><td class='insetcaption'>Strike a pose: Another danger of having NPCs hang around is that if you&#8217;re not careful they will all assume identical poses.  This can be distracting when they are standing close to each other.  It looks like these guys are about to lock arms and start kicking in unison like Rockettes.<\/td><\/tr><\/table>Once you code all of this, you can have an NPC that will be able to perform the thrilling task of <em>following a human being around without looking too stupid<\/em>.  After all of this work, it isn&#8217;t going to impress anyone. (Except geeks like me who obsess over this stuff.) The best you can hope for is to not have your NPCs make fools of themselves. <\/p>\n<p>People ask why AI sucks so bad?  This is why:  It&#8217;s hard, it&#8217;s expensive, and when it&#8217;s working right people don&#8217;t notice because they only notice when the thing screws up.  The developer can spend money making the gameworld bigger, or spend money adding lots of detail to some inconsequential NPC just so it doesn&#8217;t kill immersion.  <\/p>\n<p>Half-Life 2 did a pretty good job with NPCs, although there were many habits they had that I found annoying.  <a href=\"http:\/\/www.amazon.com\/gp\/redirect.html?link_code=ur2&#038;tag=twentysided-20&#038;camp=1789&#038;creative=9325&#038;location=\/gp\/search%3F%26index=videogames%26keywords=Quake%204%26_encoding=UTF8\">Quake 4<\/a> is even better, with squads of men working together for prolonged periods of time, who have speaking parts, and who pull all of this off without making obvious fools of themselves.  <\/p>\n<p>It may seem like a small detail, but in my book it&#8217;s a big leap forward.  My hat is off to the AI coders \/ scripters at Raven software.  Nice one guys.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>All alone: This place can be pretty unnerving. It would be much less so if I had an NPC following me around looking relaxed and staring into space. The best way to keep NPCs from messing with immersion is to leave them behind. Immersion is that much-sought quality in videogames that will make the player [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[45,523,18],"class_list":["post-605","post","type-post","status-publish","format-standard","hentry","category-game-design","tag-ai","tag-game-design","tag-quake"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/605","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=605"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/605\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}