How are video games programmed with the possibility of the playable character being able to go anywhere on the map without crashing the game?

518 views

How are video games programmed with the possibility of the playable character being able to go anywhere on the map without crashing the game?

In: Technology

3 Answers

Anonymous 0 Comments

Really simplified:
They work very hard to make sure the player can only go where they’re intended to.
Sometimes, there are bugs or oversights that let players go “out of bounds” and there, many things can happen such as the game crashing.
The most common type of bound on a map is the famous “invisible wall”, but some games try a different approach by teleporting you back inside the map with a loading screen if they detect that you’re outside the map.
Performance-wise, not all the map is loaded everytime. Usually maps are designed in chunks or “blocks” and they load the next zone while you’re travelling your current one. And they unload the unneeded zones once you travel far enough from them. That’s typically why you’ve got loading times when fast travelling from one point on the map to another : the game unloads your current zone (npcs, items etc) and loads the one you’re teleporting into.

If you’d try to keep the whole map loaded at all times, with all NPCs, items etc, you would quickly end up having your RAM full, in which case if you try to load anything more, the game won’t be able to and will most likely crash.

Games try very hard to balance their memory use by constantly loading and unloading stuff. That’s why open world games tend to have an average amount of RAM used, they very cleverly load/unload stuff in your RAM as you need them or not. You typically will never see a game like cyberpunk taking your whole ram, otherwise it would most likely indicate what’s called a memory leak : the game “forgot” it had loaded stuff so it will never unload it, and after some time, your RAM will be full, the game won’t be able to load anything more, and will most likely crash

You are viewing 1 out of 3 answers, click here to view all answers.