• 05/13/16 12:10 AM
    Sign in to follow this  

    A Brain Dump of What I Worked on for Uncharted 4

    General and Gameplay Programming

    cjcat2266

    [img=http://allenchou.net/wp-content/uploads/2016/05/Uncharted-4-logo-1024x576.jpg] [url=http://allenchou.net/2016/05/a-brain-dump-of-what-i-worked-on-for-uncharted-4/]Original blog post[/url] This post is part of [url=http://allenchou.net/my-career/]My Career Series[/url]. Now that [url=https://en.wikipedia.org/wiki/Uncharted_4:_A_Thief's_End]Uncharted 4[/url] is released, I am able to talk about what I worked on for the project. I mostly worked on AI for single-player buddies and multiplayer sidekicks, as well as some gameplay logic. I'm leaving out things that never went in to the final game and some minor things that are too verbose to elaborate on. So here it goes: [b]The Post System[/b] Before I start, I'd like to mention the post system we used for NPCs. I did not work on the core logic of the system; I helped writing some client code that makes use of this system.Posts are discrete positions within navigable space, mostly generated from tools and some hand-placed by designers. Based on our needs, we created various post selectors that rate posts differently (e.g. stealth post selector, combat post selector), and we pick the highest-rated post to tell an NPC to go to. [img=http://allenchou.net/wp-content/uploads/2016/05/posts-1024x576.png] [b]Buddy Follow[/b] The buddy follow system was derived from [url=https://en.wikipedia.org/wiki/The_Last_of_Us]The Last of Us[/url].The basic idea is that buddies pick positions around the player to follow. These potential positions are fanned out from the player, and must satisfy the following linear path clearance tests: player to position, position to a forward-projected position, forward-projected position to the player. [img=http://allenchou.net/wp-content/uploads/2016/05/follow-request-1024x576.png] Climbing is something present in Uncharted 4 that is not in The Last of Us. To incorporate climbing into the follow system, we added the climb follow post selector that picks climb posts for buddies to move to when the player is climbing. [img=http://allenchou.net/wp-content/uploads/2016/05/climb-post-1024x576.png] It turned out to be trickier than we thought. Simply telling buddies to use regular follow logic when the player is not climbing, and telling them to use climb posts when the player is climbing, is not enough. If the player quickly switch between climbing and non-climbing states, buddies would oscillate pretty badly between the two states. So we added some hysteresis, where the buddies only switch states when the player has switched states and moved far enough while maintaining in that state. In general, hysteresis is a good idea to avoid behavioral flickering. [b]Buddy Lead[/b] In some scenarios in the game, we wanted buddies to lead the way for the player. The lead system is ported over from The Last of Us and updated, where designers used splines to mark down the general paths we wanted buddies to follow while leading the player. [img=http://allenchou.net/wp-content/uploads/2016/05/lead-spline-1024x576.png] In case of multiple lead paths through a level, designers would place multiple splines and turned them on and off via script. [img=http://allenchou.net/wp-content/uploads/2016/05/multiple-lead-splines-1024x576.png] The player's position is projected onto the spline, and a lead reference point is placed ahead by a distance adjustable by designers. When this lead reference point passes a spline control point marked as a wait point, the buddy would go to the next wait point. If the player backtracks, the buddy would only backtrack when the lead reference point gets too far away from the furthest wait point passed during last advancement. This, again, is hysteresis added to avoid behavioral flickering. We also incorporated dynamic movement speed into the lead system. "Speed planes" are placed along the spline, based on the distance between the buddy and the player along the spline. There are three motion types NPCs can move in: walk, run, and sprint. Depending on which speed plane the player hits, the buddy picks an appropriate motion type to maintain distance away from the player. Designers can turn on and off speed planes as they see fit. Also, the buddy's locomotion animation speed is slightly scaled up or down based on the player's distance to minimize abrupt movement speed change when switching motion types. [img=http://allenchou.net/wp-content/uploads/2016/05/speed-planes-1024x576.png] [b]Buddy Cover Share[/b] In The Last of Us, the player is able to move past a buddy while both remain in cover. This is called cover share. [img=http://allenchou.net/wp-content/uploads/2016/05/tlou-cover-share-1024x576.png] In The Last of Us, it makes sense for Joel to reach out to the cover wall over Ellie and Tess, who have smaller profile than Joel. But we thought that it wouldn't look as good for Nate, Sam, Sully, and Elena, as they all have similar profiles. Plus, Uncharted 4 is much faster-paced, and having Nate reach out his arms while moving in cover would break the fluidity of the movement. So instead, we decided to simply make buddies hunker against the cover wall and have Nate steer slightly around them. [img=http://allenchou.net/wp-content/uploads/2016/05/cover-share-1024x576.png] The logic we used is very simple. If the projected player position based on velocity lands within a rectangular boundary around the buddy's cover post, the buddy aborts current in-cover behavior and quickly hunkers against the cover wall. [img=http://allenchou.net/wp-content/uploads/2016/05/cover-share-debug-1024x576.png] [b]Medic Sidekicks[/b] Medic sidekicks in multiplayer required a whole new behavior that is not present in single-player: reviving downed allies and mirroring the player's cover behaviors. [img=http://allenchou.net/wp-content/uploads/2016/05/medic-revive-1024x576.png] Medics try to mimic the player's cover behavior, and stay as close to the player as possible, so when the player is downed, they are close by to revive the player. If a nearby ally is downed, they would also revive the ally, given that the player is not already downed. If the player is equipped with the RevivePak mod for medics, they would try to throw RevivePaks at revive targets before running to the targets for revival; throwing RevivePaks reuses the grenade logic for trajectory clearance test and animation playback, except that grenades were swapped out with RevivePaks. [img=http://allenchou.net/wp-content/uploads/2016/05/medic-revivepak-1024x576.png] [b]Stealth Grass[/b] Crouch-moving in stealth grass is also something new in Uncharted 4. For it to work, we need to somehow mark the environment, so that the player gameplay logic knows whether the player is in stealth grass. Originally, we thought about making the background artists responsible of marking collision surfaces as stealth grass in Maya, but found out that necessary communication between artists and designers made iteration time too long. So we arrived at a different approach to mark down stealth grass regions. An extra stealth grass tag is added for designers in the editor, so they could mark the nav polys that they'd like the player to treat as stealth grass, with high precision. With this extra information, we can also rate stealth posts based on whether they are in stealth grass or not. This is useful for buddies moving with the player in stealth. [img=http://allenchou.net/wp-content/uploads/2016/05/stealth-grass-1024x576.png] [b]Perception[/b] Since we don't have listen mode in Uncharted 4 like The Last of Us, we needed to do something to make the player aware of imminent threats, so the player doesn't feel overwhelmed by unknown enemy locations. Using the enemy perception data, we added the colored threat indicators that inform the player when an enemy is about to notice him/her as a distraction (white), to perceive a distraction (yellow), and to acquire full awareness (orange). We also made the threat indicator raise a buzzing background noise to build up tension and set off a loud stinger when an enemy becomes fully aware of the player, similar to The Last of Us. [img=http://allenchou.net/wp-content/uploads/2016/05/threat-colors-1024x601.png] [b]Investigation[/b] This is the last major gameplay feature I took part in on before going gold. I don't usually go to formal meetings at Naughty Dog, but for the last few months before gold, we had a at least one meeting per week driven by [url=https://twitter.com/bruce_straley?ref_src=twsrc^google|twcamp^serp|twgr^author]Bruce Straley[/url] or [url=https://twitter.com/Neil_Druckmann?ref_src=twsrc^google|twcamp^serp|twgr^author]Neil Druckmann[/url], focusing on the AI aspect of the game. Almost after every one of these meetings, there was something to be changed and iterated for the investigation system. I went through many iterations before arriving at what we shipped with the final game. There are two things that create distractions and would cause enemies to investigate: player presence and dead bodies. When an enemy registers a distraction (distraction spotter), he would try to get a nearby ally to investigate with him as a pair. The closer one to the distraction becomes the investigator, and the other becomes the watcher. The distraction spotter can become an investigator or a watcher, and we set up different dialog sets for both scenarios ("There's something over there. I'll check it out." versus "There's something over there. You go check it out."). In order to make the start and end of investigation look more natural, we staggered the timing of enemy movement and the fading of threat indicators, so the investigation pair don't perform the exact same action at the same time in a mechanical fashion. [img=http://allenchou.net/wp-content/uploads/2016/05/staggered-investigation-1024x576.png] If the distraction is a dead body, the investigator would be alerted of player presence and tell everyone else to start searching for the player, irreversibly leaving ambient/unaware state. The dead body discovered would also be highlighted, so the player gets a chance to know what gave him/her away. [img=http://allenchou.net/wp-content/uploads/2016/05/dead-body-highlight-1024x576.png] Under certain difficulties, consecutive investigations would make enemies investigate more aggressively, having a better chance of spotting the player hidden in stealth grass. In crushing difficulty, enemies always investigate aggressively. [b]Dialog Looks[/b] This is also among the last few things I helped out with for this project. Dialog looks refers to the logic that makes characters react to conversations, such as looking at the other people and hand gestures. Previously in The Last of Us, people spent months annotating all in-game scripted dialogs with looks and gestures by hand. This was something we didn't want to do again. We had some scripted dialogs that are already annotated by hand, but we needed a default system that handles dialogs that are not annotated. The animators are given parameters to adjust the head turn speed, max head turn angle, look duration, cool down time, etc. [img=http://allenchou.net/wp-content/uploads/2016/05/dialog-look-1024x576.png] [b]Jeep Momentum Maintenance[/b] One of the problems we had early on regarding the jeep driving section in the Madagascar city level, is that the player's jeep can easily spin out and lose momentum after hitting a wall or an enemy vehicle, throwing the player far behind the convoy and failing the level. My solution was to temporarily cap the angular velocity and change of linear velocity direction upon impact against walls and enemy vehicles. This easy solution turns out pretty effective, making it much harder for players to fail the level due to spin-outs. [img=http://allenchou.net/wp-content/uploads/2016/05/jeep-momentum-maintenance-1024x576.png] [b]Vehicle Deaths[/b] Driveable vehicles are first introduced in Uncharted 4. Previously, only NPCs can drive vehicles, and those vehicles are constrained to spline rails. I helped handling vehicle deaths. There are multiple ways to kill enemy vehicles: kill the driver, shoot the vehicle enough times, bump into an enemy bike with your jeep, and ram your jeep into an enemy jeep to cause a spin-out. Based on various causes of death, a death animation is picked to play for the dead vehicle and all its passengers. The animation blends into physics-controlled ragdolls, so the death animation smoothly transitions into physically simulated wreckage. [img=http://allenchou.net/wp-content/uploads/2016/05/bike-ragdoll-1024x576.png] For bumped deaths of enemy bikes, we used the bike's bounding box on the XZ plane and the contact position to determine which one of the four directional bump death animations to play. [img=http://allenchou.net/wp-content/uploads/2016/05/bike-obb-1024x576.png] As for jeep spin-outs, the jeep's rotational deviation from desired driving direction is tested against a spin-out threshold. [img=http://allenchou.net/wp-content/uploads/2016/05/jeep-spin-out-1024x576.png] When playing death animations, there's a chance that the dead vehicle can penetrate walls. A sphere cast is used, from the vehicle's ideal position along the rail if it weren't dead, to where the vehicle's body actually is. If a contact is generated from the sphere cast, the vehicle is shifted in the direction of the contact normal by a fraction of penetration amount, so the de-penetration happens gradually across multiple frames, avoiding positional pops. [img=http://allenchou.net/wp-content/uploads/2016/05/bike-sphere-cast-1024x576.png] We made a special type of vehicle death, called vehicle death hint. They are context-sensitive death animations that interact with environments. Animators and designers place these hints along the spline rail, and specify entry windows on the splines. If a vehicle is killed within an entry window, it starts playing the corresponding special death animation. This feature started off as a tool to implement the specific epic jeep kill in the 2015 E3 demo. [b]Bayer Matrix for Dithering[/b] We wanted to eliminate geometry clipping the camera when the camera gets too close to environmental objects, mostly foliage. So we decided to fade out pixels in pixel shaders based on how close the pixels are to the camera. Using transparency was not an option, because transparency is not cheap, and there's just too much foliage. Instead, we went with [url=https://en.wikipedia.org/wiki/Dither]dithering[/url], combining a pixel's distance from the camera and a patterned [url=https://en.wikipedia.org/wiki/Ordered_dithering]Bayer matrix[/url], some portion of the pixels are fully discarded, creating an illusion of transparency. [img=http://allenchou.net/wp-content/uploads/2016/05/dithering-1-1024x576.png] Our original Bayer matrix was an 8x8 matrix shown on [url=https://en.wikipedia.org/wiki/Ordered_dithering]this Wikipedia page[/url]. I thought it was too small and resulted in banding artifacts. I wanted to use a 16x16 Bayer matrix, but it was no where to be found on the internet. So I tried to reverse engineer the pattern of the 8x8 Bayer matrix and noticed a recursive pattern. I would have been able to just use pure inspection to write out a 16x16 matrix by hand, but I wanted to have more fun and wrote a tool that can generate Bayer matrices sized any powers of 2. [img=http://allenchou.net/wp-content/uploads/2016/05/bayer-matrix.gif] After switching to the 16x16 Bayer matrix, there was a noticeable improvement on banding artifacts. [img=http://allenchou.net/wp-content/uploads/2016/05/dithering-1024x295.png] [b]Explosion Sound Delay[/b] This is a really minor contribution, but I'd still like to mention it. A couple weeks before the 2015 E3 demo, I pointed out that the tower explosion was seen and heard simultaneously and that didn't make sense. Nate and Sully are very far away from the tower, they should have seen and explosion first and then heard it shortly after. The art team added a slight delay to the explosion sound into the final demo. [b]Traditional Chinese Localization[/b] I didn't switch to Traditional Chinese text and subtitles until two weeks before we were locking down for gold, and I found some translation errors. Most of the errors were literal translations from English to Traditional Chinese and just did't work in the contexts. I did not think I would have time to play through the entire game myself and look out for translation errors simultaneously. So I asked multiple people from QA to play through different chapters of the game in Traditional Chinese, and I went over the recorded gameplay videos as they became available. This proved pretty efficient; I managed to log all the translation errors I found, and the localization team was able to correct them before the deadline. [b]That's It[/b] These are pretty much the things I worked on for Uncharted 4 that are worth mentioning. I hope you enjoyed reading it. :)



      Report Article
    Sign in to follow this  


    User Feedback

    Create an account or sign in to leave a review

    You need to be a member in order to leave a review

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now


    yutsura

    Report ·

      

    Share this review


    Link to review
    Oldfella

    Report ·

      

    Share this review


    Link to review
    Talvish

    Report ·

      

    Share this review


    Link to review
    maxfire

    Report ·

      

    Share this review


    Link to review
    Degi

    Report ·

      

    Share this review


    Link to review
    Heelp

    Report ·

      

    Share this review


    Link to review
    slayemin

    Report ·

      

    Share this review


    Link to review
    moeen k

    Report ·

      

    Share this review


    Link to review
    sortris

    Report ·

      

    Share this review


    Link to review
    papakosh

    Report ·

      

    Share this review


    Link to review
    Daixiwen

    Report ·

      

    Share this review


    Link to review
    David_pb

    Report ·

      

    Share this review


    Link to review
    Syntac_

    Report ·

      

    Share this review


    Link to review