In open world games like GTA 5, what happens to NPCs when no one is around? Do they still “move,” drive, etc?



In open world games like GTA 5, what happens to NPCs when no one is around? Do they still “move,” drive, etc?

In: Technology

Most games

As soon as you step out a certain range the npc will simply not exist anymore

It depends on the games. Cyberpunk makes NPC spawn in when you look but disappear when you turn away. Fallout keeps your area loaded but disappears it when you leave. Not sure about GTA but I’d imagine it’s the same as fallout. You can have all things spawned in at all times but it would take so much ram and be so hard to play since you have to account for all things!

Videogames typically use a technique called “Culling”, which basically means, when an object or a part of the map is not in view, or not in the area of the player, it is typically removed from the scene, to save memory/processing power. Once the player/camera is in view of a new area or in view of some NPCs and Cars they quickly get put back into the scene. This is why you can sometimes see Objects and cars loading in if you look at them zoomed-in from far away.

So to answer your question, when no one is around, the NPCs are simply removed from the scene.

It depends on the game as obviously a game can be programmed any way you want. But typically an open world game as large and detailed as GTA, it is not feasible to keep the whole world simulation going outside of the player’s little bubble. It’s too much strain on memory and processing resources.

Graphically, assets are removed from graphics memory (culled, as redditspamnotbot described)) when they aren’t visible, this frees up much needed GPU resources. The same process is in place when it comes to the ‘existence’ of objects in the game world. At some point they will be despawned and no longer exist, to save on system memory and CPU resources. No need to remember what the pedestrian looked like, what animation state they were in, what car they were driving, the damage state of that car, calculate their physics etc.

It may be that these two areas are not the same; if you run away from a vehicle collision to the point that you can’t see it, it will be culled, but if you run back to it, it will still be there because it didn’t despawn. But if you run away even further it will cease to exist, there will be no traffic jam or other flow on effects, etc. When you return to the same spot, other objects will randomly spawn into the world, even if it creates an impossible contradiction to the state you had previously observed.

It’s also not a necessarily binary decision. You can implement some state in-between where the object isn’t completely despawned, but reduces how much resources it consumes. As NoCelery1168 explained it might exist in a state where position and vector is maintained but it does not adhere to normal physical or collision detection. Or maybe the object continues to “exist” and travel on some pre-determined path, but like it doesn’t retain the car’s damage state or the fact that you shot 2 of the passengers dead.

It depends entirely on the game.

The most aggressive and pretty universal removal is the graphics. The graphics card calculates the look of everything around you, and there are separate and pretty aggressive routines to not calculate what you can’t see.

Then you have the simulation of movement and actions. It will simply be different from game to game.

Metal Gear 5 is an example with a huge world, where if you place a mine on a road, and go far enough away, you can still see the mine on the map, and the movement of the enemy vehicle, but the mine won’t be triggered.

This because mine triggering is done by a costly calculation involving exact proximity – enemies far enough away are simulated in simpler ways.

The rule of thumb for making video games is this: try to make it look like as much as possible is happening while at the same time doing as few calculations as humanly possible.

Simulating anything accurately is technically very straightforward, on the other hand is very computationally expensive and relies the computational capacity of the hardware. Computer hardware has never been cheap, which is why often the most technically impressive games are the ones that have figured out a way to convince the player that much more is going on than there actually is.

Those random NPC’s don’t even exist when you aren’t looking at them. The game simply makes them appear in your general area to give the illusion of a vibrant, populated city. As soon as they are far enough away to not be relevant, the game engine forgets them and breathes a sigh of relief.

The game engine has to draw 60 pictures to the screen every second, which doesn’t really sound like it means anything, but when you rephrase it, it means it has to simulate the entire game world, the physics, the actions of the AI etc in one sixtieth of a second, 60 times a second, every single second, without stalling. What it boils down to is that the less work the game engine has to do, the better.

The more NPC’s there are to consider, the less likely that sustained framerate is going to actually happen, so the game engine is intentionally designed in a way that allows it ignore everything it possibly can, that includes scenery and NPC’s. All of the greatest game engines every designed have had the same thing in common: they excel at knowing exactly how much work they can avoid doing.

In all likelihood, for nearly any given game, there is probably a rigidly defined quota of how many random NPC’s can be comfortably handled by the program without affecting the game playability, and they are continuously replaced as the player character moves around the game world. As long as there are never too few or too many, the illusion is easily and stably sustained.

This doesn’t rule out the possibility of having specific NPCs that are more accurately tracked and simulated, if they are relevant to the story. Think about it in terms of the relationship between extras in a movie vs the main cast. Both are pretty much essential to make the movie convincing, but their roles are very different.

In general, NPCs only do things when in the current rendering area. However, there are some cases where they do move around.

Skyrim is a good example of this, there are several npcs where their location is calculated via time of day or time since journey started (for certain follow quests). But these npcs are generally special, I’d say about 90% are either static or randomly generated and cease to exist when outside of the player’s area.

GTA is a pretty good example of random NPC generation. I haven’t experimented, but I would expect for cars on the road or NPCs on the sidewalk to be different each time they’re loaded in. I’ve seen it particularly obvious in other games where there’s a defined spawn point for the tile.