Transcript for:
NPC Traffic Analysis in GTA V

now what I'm about to show you might trigger a form of PTSD we've seen way too many situations of this and this and that when NPCs in GTA 5 will go out of their ways literally to bump you off the road especially when you're carrying something fragile or important now I understand Los Santos is supposed to reflect a real life version of the city of Los Angeles and yes that's how I say it deal with it so it is expected for traffic to look exactly like it has been populated by bunch of methods who have an unhealthy attraction to trading paint and smash bumpers like this Mario Kart it has been widely accepted in the GTA V community that GTA V has actually been programmed to force NPCs to Swerve onto your predicted path but is this really true well certainly most of you think so overwhelmingly actually and I have spent an unhealthy amount of hours tracing back this myth to any forums to any rated communities that could have pointed me in the right way to prove this myth once and for all to be true but I was met with the traditional outcome of trust me Pro science right I can fully 100% commit to the statement that this myth is false any one of you could prove me wrong but I am a man of science and I want evidence God damn it of which I haven't found yet but I see what you see these actions seem way too deliberate for it to just be an accident but isn't a real World filled with what the [ __ ] moments from people that act like NPCs America is a nation that can be defined in a single word I was to put him fo so could this be another situation of NPC just being NPCs or is there something murky in the code that allows us to actually be intentional I wanted to find that out so I decided to do something that I do not wish or want you to do little Timmy don't do this at home because once you get into modding and code hunting you just never come back I actually wanted to know how the traffic inherently Works in GTA 5 especially now that we have access to the actual source code of the game how do the traffic lights and Junctions actually work can NPCs recognize danger and be smart about it for once and most importantly how can they be such precise [ __ ] by complete accident to understand all this we have to analyze the Baseline system surrounding the control of NPC those being pedestrians or vehicular NPCs now with a pretty nifty software called code Walker I'm actually able to rumage through every single major asset regarding map Management in a very visual way instead of looking at a huge wall of text which is not very attractive not very demure my fiance is a bad influence on my humor Jesus Christ we can see scenarios which are prescripted events which add a little bit of Ambience to the game something outside of the box of just tra traffic like this bus stopping at a bus station or Industrial Vehicles leaving a construction site and a huge multitude of others we have Collision meshes which made me realize that trees in GTA V are actually just a bunch of lollipops and NV meshes that are in simple terms areas where NPCs can transverse both with vehicles and on foot but these are not the actual paths that NPCs navigate through but rather a bunch of allowed areas if NPCs find themselves going off of course we typically kick the term AI left and right but true artificial intelligence truly only kicks in when let's say NPCs are chasing you the player beyond what they are typically scripted to do cop NPCs will pretty much mimic every single input you apply even if that area is not typically accessed by NPCs in essence NPCs actually travel like their trains with a specific set of tracks that they can deviate from well kind of but we'll get to that for this we actually consider traffic paths if we slip our way into the game files we'll see paths as an RPF item the short version of Rockstar pack file now these packs these folders if you want to think it like that typically hold cars textures audio files and if you actually mod GTA 5 God bless your patience you know these are typically very easy to access as they hold models and XML files which is pretty much raw text it people let's be honest SML is just text but paths are different they're composed by a multitude of node areas if we check back into code Walker we'll see that each area is going to be determining how traffic is regulated in a way even though code Walker makes it seem like everything is one continuous set of paths and the game kind of works that way each of these node areas have to be interconnected that means if you have six Roads connecting two different area nodes you'll have about 12 node Links at the very least all this to say that Rockstar didn't really design traffic as a whole but rather as a conglomerate of little pieces of traffic these little dots right here these are notes and this is the core system that serves as a baseline for how NPCs are expected to behave and you can think of these noes as a sort of magnet in fact Rockstar calls these attractors when at the very least we speak about the scenarios that we've discussed earlier NBC traffic will always try to get as close as possible possible to the nearest magnet and respect its orientations properties attributes set by each of these nodes now this is a very important part because even though this road right here has a connection to an Alleyway the alleyway itself lacks the scripted flag which won't allow for NPCs to just randomly drive down set Alleyway to show you how strict these scripted paths are I'm using a mod that essentially deletes the brain of the NPC any directives that he had about paths and just follows the player so I drive him down the alleyway and as you can see as soon as I release him and tell him go on your Merry way do whatever he does drive down the alleyway because there is a path but since his journey started now he's only going to follow the directive of the nearest magnet the nearest node which is to drive down the alleyway but no matter how many times I try to redirect the original traffic that does have the bot brain to follow the scripted path file they will do everything they will do 360 crash into bars walls whatever their only directive is to reach the next scripted node so if I cut them off at the node 630 they will not rest until they reach the node 650 they have very little autonomy other than reach the next node by any means necessary no matter how many NPCs they run over I guess this road node right here will be your standard two-way street nothing special here while this one actually has a specific flag to not allow left turns but we happen to have a left turn lane that does need to allow that so how does GTA 5 fix this this node with three lanes has to be split into two nodes with different flags one containing that cannot go left flag for the lanes 2 and three and the other one that has a slip lane flag for the lane one that can go left you'll see a lot of these splits in traffic and this is where the [ __ ] hits the fan for NPCs most of the times the reality is that path file does not tell NPCs when to shift Lanes this makes it a Make It or Break It situ ation and it's completely randomized NPCs can merge at any point between lanes of the same node an easy way to force this is to present them with a slow moving object like this barrier that I'm you know basically placing in front of their faces all these lanes are in the same node so it's fine however it is completely randomized to whether they decide to stick with a new lane or shift back but as soon as that slip lane starts which means another node that is it I tried hundreds of times and I couldn't Force this single NPC to do a late merge out of nowhere after committing to the new node and you'd think well that's good that's predictable but if they get deviated somehow they will not see a clear space in traffic as a valid path just for the simple fact it belongs to an unlink node remember that Alleyway scenario they will drive in circles on sidewalks oncoming traffic until they find themselves into that slip lane again they can't go back to that main road or vice versa I even tried to place a stationary barrier at the end of the slip lane and amazingly some NPCs were smart enough to detect Collision but they always merged early while it was all still one node before they commit to that slip lane Noe while some NPCs seem to miss the memo and they try to plow through the obstacle again completely randomized there's no pattern there's no specific vehicles that do that it's just praying that they don't do that remember all this for when we start talking about their alleged intentional crashing but there is no pattern coding here only goes so far this is the responsibility of the AI engine since a scripted Behavior by path nodes would just make it look way too robotic if all NPCs just decideed to shift Lanes at the exact same spot or node in this case this is a true moment when Rockstar starts to improvise a solution within a flawed system the combination of AI decision making and scripted paths will always create a conflict I mean look at the Junctions themselves there's no dedicated lanes for them really it's just a box with a height map that indicates this whole area is a junction that's pretty much it under normal circumstances considering that the you know you didn't shoot a gun and they became agitated which is whole held Breaks Loose I suppose but that's pretty much how the AI traffic engine actually works in Junctions if car is about to crash then car don't crash that's pretty much it their only scripted directive is to connect to another node don't get me wrong despite this hybrid solution being quite unpredictable the AI system is needed to create a human element to it compared with games like Watch Dogs 2 where the cars simply stop they wait until the obstacle is gone they don't try to adapt they just stick to their path and path only sure this might cause less crashes but it looks [ __ ] weird this is kind of shitty Ubisoft I'm not going to lie grab this L over here all right and pile it up with the thousands of L that you have every day but in GTA 5 NPCs will actually try to tackle the issue that's the important part right and as you can see they can actually be pretty effective at it I'm able to deviate a whole row of cars in the highway to a different Lane as it would happen in real life if you have you know roadside work or an accident so a hybrid system will always be required at least if we want something that looks genuine to simulate both normal and erratic Behavior as we do have in real life now how do we tackle erratic Behavior inside Junctions in real life ding ding ding ding you are correct traffic lights will do the trick so you would expect that GTA 5 the bestselling entertainment piece of all time not just game would Inspire itself in the same traffic light systems as we have in real life right I I mean it's literally copying so it's even easier that way well now traffic lights in GTA V are actually a fun thing to look into I'm sure by now you have realized that the traffic lights don't seem to really matter in the game because once you crash into them NPCs still react as if nothing happened they can still go through a junction with no problem but crashing into traffic lights does not necessarily mean that these entities in the game just stop existing even when when you crash into a dynamic object which are objects that will fly off when you hit them basically they never actually cease to be a thing in the game the entities still exists so what happens if I actually delete the entities by using a world editor yeah starting to burst your bubble but in GTA V these traffic lights are completely [ __ ] useless I mean these lights are not even real they're 2D shaders that just pop in in front of the light placements but the way these NPCs regulate themselves as if these traffic lights were working is kind of funny to look into behind the scenes you see these traffic lights are actually set within every Junction node and any node that links to that Junction node that's why you can push an NPC to break the law in GTA 5 by making him run a red light once you force an NPC you crash into him or push him to go over the node linked to that Junction node well all better off for that NPC any flags that told him to wait are no longer applied in this specific scenario right here this NPC ignores that is on a canot go left node and just Hill marries across two lanes that he shouldn't be going through all because he left his magnet when he was not supposed to do so I can place this traffic pole facing a completely different direction and in a different position but due to the proximity of light props to the junction nodes this traffic pole will still create these 2D shaders that give a false impression the lights are actually working that's because the junction nodes have a specific type that in conjunction with other flags that even most moders don't know exactly what the [ __ ] they do the next thing we're going to do is make sure the flags are correct I don't know what any of these flags mean you're actually able to set traffic lights to any Junction in the game at your heart's contempt now what you might still Ponder is how does the timing of these traffic lights work exactly well initially I thought thought these were dependent on each node area and this wouldn't be such a terrible idea if you allow to pet my own ego here because you would actually simulate a real life version of a grid type system as seen in real life a lot of traffic lights in the same vicinity will be timed accordingly even from Junction to Junction to maximize traffic flow so in a straight you can have a red light that will turn green 5 seconds after the previous one also turns green this way you can have a huge chunk of a straight road with a nice steady traffic flow and even though it breaks my heart to say it GTA V is not this clever it seems like each Junction has a completely randomized timer that makes other Junctions not have the lights flare up the same time the only consistency I was able to find is that apparently all Junctions behave the exact same way with the exact same timing doesn't matter what the area doesn't matter how many lanes you have is exactly the same every time 40 seconds of red light and 5 Seconds of green light yeah you heard that right you probably didn't realize this because I mean who follows traffic laws in GTA V other than role players I suppose but it's bad and as soon as a red light turns green an adjacent light will immediately turn red this is also a big no no in real life there's typically a gray period where both streets from different directions have a red light on to account for those who run red lights or allow a junction enough time to clear out the traffic which GT5 could use that [ __ ] obviously in real life this would be chaotic as a lot of times in GTA 5 you can actually see one side of the junction going through a green while you could very well have both sides running parallel simultaneously so you're probably wondering sure that tackles the times NPCs crash into me when they are deciding to turn on in Junction or exit but why do NPCs crash onto me on a straight road when there's no Junctions no merging or converging lanes and the reason why it may seem so deliberate to us is that they sometimes go back to the exact same [ __ ] Lane they were before it seems like they're just trying to [ __ ] with us this is annoying isn't it but let me ask you a question do you typically get this type of behavior from NPCs in GTA 5 single player or in GTA Online if this was truly a case of coded Behavior scripted whatever you would see equally in both but this behavior is almost exclusively or at least most frequently happening when people are playing GTA online now let me get ahead of the curve here before anyone says well we do have examples of this happening in single player now I did research about those to see if I could find any I couldn't find anything but one from whatever big YouTuber I'm pretty sure you guys know him and yes it does seem like a situation of an NPC just getting in your way but this proves my whole point of about this whole video is that uh this is not traffic this my friends what you're seeing is a scenario and scenarios do not give a [ __ ] the current state of the traffic they do not give a [ __ ] about Crash detection they will play out the scenario until they're clear to Joint traffic I went to Cod Walker for this exact spot in front of the city hall or quarter I'm not even sure what this is but yeah this is a scenario and these will play out and they don't care who gets in their way but it's sure is not intentional this has been if there's when it comes to being programmed this is the most programmed thing ever it doesn't change it is always like this now the system of pathing if that's a word is exactly the same in both modes however GTA online has to consider the behavior of other players and the performance of other systems especially when rockar is too much of a cheap ass to have dedicated servers and has to rely on peer-to-peer connection which is not the best now with this NPC Behavior has to be synced across different systems with different specs and it has to be uniform inside the server but it doesn't really matter if you have players nearby these things are still loaded into a share platform so syncing is a constant problem for online servers oh not to mention GTA online will always have a much more resource intensive nature since it can't rely on onscreen space rendering for those who don't know most games will only load what is within your field of view or in other words what you can possibly see but GTO online has a 360 approach to this sometimes they have to load properties that are beyond your field of view for the simple fact that a player can just spawn in and see it even if you don't and you see these sinking issues all the time between players but it will also happen with NPCs so when you see an NPC dodging absolutely nothing in front of you it doesn't mean that they're not actually trying to dodge something they saw it's just that the obstacle is not appearing according to your system NPCs will still have a tendency to follow these nodes but a sudden brief moment where they see something that doesn't actually exist makes them swerve and then immediately go back to where they were most of these invisible objects are actual objects that spawn in for about 10 milliseconds which makes the AI recognize there's danger I have to dodge this but not enough for you to see it just like how some NPCs might pop in right in front of you to them another poorly spawned NPC or player could cause that also let me to state that some of you do not present a good case for it either when you give examples such as these I mean this one NPCs don't purposly crash into you is the abstein didn't kill himself of GTA love the title creative I like that but I can literally see your crew mates shooting from the back of the van no wonder the NPCs are going to bug out and panic when they're around you you can even see the van kind of desyncing which proves my point about this is most likely a GTA online problem or or this one as Rockstar admitted they have coded NPCs to get in the way it's a little too blatant at the moment what are you talking about I can literally see the red icons in your map there's an active shooter behind you chasing you and for those who still haven't picked this up I suppose and it's kind of natural when you think about it it's kind of human to think this way think of an active shooter in the game as someone who has a force field and NPCs will always see that shooter as something to get away from so no wonder that the people that are in front of you the NPCs that are in front of you on the oncoming traffic will try to do an 180 and that means that they will step into your Lane and go the same direction that you're going essentially because they're trying to run away too yeah when you're doing these missions it expect to be cut off but regardless even if I don't remember these specific situations ever happening that badly to me usually my connection is stable and all that not flexing here but I wanted to see if I could actually Force these things or push the NPCs uh to actually crash into me in a blatant way so I spent about 1 hour driving around Los Santos in a semi full lobby with 26 people and see what I would actually get from this now it didn't take me 5 minutes to get to a very dangerous situation where it does seem like an NPC does a very what a lot of people describe as very intentional Lane shift but as soon as I compared with single player I realized that this must be something to do with the nodes and would you look at that uh it is even though it is a left turn lane here both nodes are pretty much glued to each other which is going to cause for some really aggressive and sudden Lane shifts in fact in single play was even worse because he shifted two lanes across and this is something that I cross reference with other videos and my own experience yes there are some lanes that just shift so quickly that will make NPCs very unpredictable but it's not their fault they are not coded to crash into you they're just poorly coded in the way of I guess merging tolerance how much they can actually go before they have to merge sometimes it's sudden but that's because of how the paths were defined I tried to bait a few making myself very predictable to you know basically go on their left or right and that didn't cause anything in fact one of them actually cleared for me once they realize that I was directly on their side I caught two scenarios which would make me believe that a lot of players would say this is very intentional to me one of which seems like the NPC is waiting just to basically [ __ ] up your path but because I was being careful as I typically Drive in GTA Online Su me I'm not Reckless this would have definitely caught a player that doesn't understand that there's a scenario here of a car parking that usually slows down and then very quickly just parks and sure I had a fair bunch of them kind of swerving into me but that's because the crash detection system for NBCS only operate with forward threats never rear ones so this was something expectable and if you are going to go onto an uncoming traffic they might freak out there was another one that seemed like it had no prop no car no NPC in front of him and he still does something very aggressive which is to just turn left into another Lane but if you pay attention on cold Walker or you actually review the footage very closely there's a line that even though it doesn't make any sense if in real life this would actually be a thing to just have a sudden line that has to converge one lane into another one so yeah blame it on map design on this one the path is proper but it will make for some very sudden changes that is true again not coded to crash into you it's just that and this has been pretty much the typical pattern NPC just do [ __ ] really [ __ ] quickly which makes them very unpredictable and unsafe and in GTA Online this is the kind of [ __ ] that you catch only on online which makes me believe even more that there's no such thing as you know purposely trying to make players crash it's just shitty resource management and you can see literally an abandoned car in the middle of nowhere like an NPC car that has no occupant no nothing just chilling right in front of my Lane if I was going 140 Mi as a lot of players go through this area yeah most likely they would crash into it and believe that this was a ghost card just planted to uh I guess get their way but no this was spawn a while ago now there is one situation where NPCs are trained or coded to actually cut you off and as cop cars would try to intercept you if they end up spawning in front of you and we know how little effective they can be at crashing against you you can pretty much Dodge their interception every time right so how come rockar can code civilian NPCs to tackle your ass this perfectly but they don't do this for cops kind of weird that they wouldn't apply this code on both sides no and there's also a human factor to this myth sometimes we just see what we want to see we need to blame something other than ourselves for how our mission is going to [ __ ] obviously it's not my fault but believe me NPCs have erratic Behavior even when they're not within your path at times you can see the NPCs in the distance kind of just like spazzing out and sideswiping their own vehicle like this is [ __ ] rocket League or some [ __ ] you just usually don't care because it doesn't affect you so far there's no proof or indication that NPCs have a form of erratic Behavior when they are nearby now you can also ask are traffic path the only way that NPCs are set with a preset Behavior now sure you're on to something here there's also something called vehicle MAA and these files will typically contain the attributes of each specific model for example something that is very curious and something that has cursed the lspdfr community you know the guys that like to pretend that they cops in GTA which flips the whole game on its head and it's that big vehicles in GTA V are naturally programmed coded to never yield for emergency vehicles in order to fix this every single vehicle in the game has the tag flag big turned to false even if the vehicle is in fact a big vehicle like a truck hell you even have flags for allowing Sunday driving in certain cars but even in this file which is not 100% dedicated to AI Behavior gave me no indication that they do have a specific behavior towards the proximity of a player it just doesn't exist so face it it's just the fact that some NPCs bug out big time and the bigger that your server is the likelihood of that happening is 10-fold now listen I understand I just completely obliterated the number one excuse for most of us GTA online players had for when they lose their whole import export payout okay a very fun myth that was cool to joke about uh but hey GTA V doesn't care about your feelings okay Buster it's disappointing I know but I think this is a valuable time for us to finally realize that maybe we could do better with some uh defensive driving this we already know that NPCs will go ape [ __ ] near us and listen a lot of yall can't drive in GTA Online let's be honest we got to fix that the amount of people that still with a controller cannot drive is a bit alarming it's not like we playing Forza for crying out loud but I uh what the [ __ ] am I making this video for most of y'all are going to grab the flying broomstick and scadaddle your way to the objective either way so U thank you to all you dinosaurs like me that still drive land vehicles in GTA Online all right it's 10f brother been this forever in thei they throw me brush it pick myself up moving on better hey