What is the maximum world size

This questions comes up a lot and I was researching it too. You find a lot of learned discussions about this but never a simple answer so I thought I post the answer here myself to save others the bother in case somebody is looking for the same :slight_smile:

So here are the constant definitions in the current version (4.12):

#define WORLD_MAX					2097152.0				/* Maximum size of the world */
#define HALF_WORLD_MAX				(WORLD_MAX * 0.5)		/* Half the maximum size of the world */
#define HALF_WORLD_MAX1				(HALF_WORLD_MAX - 1.0)	/* Half the maximum size of the world minus one */

I understand that you can place objects in the world from - HALF_WORLD_MAX to HALF_WORLD_MAX

So in the end, the usable size is about -10Km … +10Km around the point of origin or 20*20Km

I’m having difficulties finding the CPP file in the UE4 sln that contains these constant definitions. Can you direct me to it?

https://github.com/EpicGames/UnrealEngine/blob/08ee319f80ef47dbf0988e14b546b65214838ec4/Engine/Source/Runtime/Engine/Public/EngineDefines.h#L30

I actually found the #defines in EngineDefines.h and Lighting.h; something important to note for anyone else attempting to increase the WORLD_MAX is that the current maximum is not some arbitrary number.

2097152 = 1000000000000000000000 in binary, or a little over 20.9km

If I’m not mistaken, you should be able to add a few more 0’s after that binary 1 to create a larger number in decimal that should play well with the engine. Google has a tool for converting binary to decimal.

Increasing this is not recommended! See: When does the smallest gap between two floats reaches 1.0? - Arkanis Development

Using a double for the definition changes nothing if you don’t change everything to double. All vectors in Unreal use float you would have to change a LOT of code to be able to use double for the coordinate system. It’s not just the vectors its also lots of things like distance calculations and sizes. Basically you would have to search the whole codebase for the word float and decide on a case by case basis if it needs to be change into a double. Then you’ll probably get issues with the code that serializes things like for network traffic or storing on disk which all works with float but not double. Also see this answer from an Unreal staff member which explains it more and talks about a solution.

Thanks for this! I see that Epic uses HALF_WORLD_MAX for several float inputs throughout the solution, however the way they define WORLD_MAX (and therefore HALF_WORLD_MAX) makes it double precision because there is no ‘f’ on the end of the numerical input to the #define.

I assumed they would have used double for all references, so I was surprised when I saw they used float. That was why I assumed it should be okay to exceed 8388608 for the world max. However, I see that this could be a problem unless I go through and replace all float references with doubles–but then there would be other problems, UE4 definitely uses floats as the golden standard throughout the code.

My goal is to create a 117km x 117km map of the greater Tokyo area. So I need to define the world size to be 16777216~=167km (or three more digits of precision in binary). I’m using world composition, level streaming, and origin shifting with 257 tiles.

So perhaps it isn’t even a problem if I increase the WORLD_MAX this much because the origin will always be at my player-character (if I understand how origin-shifting works) and therefore anything within a distance of 8388608 of the character will have better than 1.0000 precision? And anything farther away than that is much less important to represent precisely. Do you have any thoughts on this?

:frowning: I typed a whole reply but it somehow got lost when I posted it. It boiled down to that if you want to change WORLD_MAX to a double you will have to change FVector and a LOT of other things to double as well (you will basically have to search for “float” and manually go though all of them to see if they need to change). This answer by an Epic staff member sums it up as well and gives a solution.