Skip to content

Commit ebf83da

Browse files
author
Roberto De Ioris
authored
Update Level_API.md
1 parent 5b0465b commit ebf83da

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

docs/Level_API.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
11
# The Level API
2+
3+
## ULevel vs UWorld
4+
5+
Before dealing with the Level api, we need to focus on the thin difference between a level and a world.
6+
7+
To be rough, the matter is at the implementation level.
8+
9+
A UWorld is a container for actors, but for allowing features like 'level streaming' (common in open worlds game, where you cannot completely load a huge level but instead you load only the currently-relevant fractions of it), a UWorld can be mapped to one or more "levels".
10+
11+
To be more clear: when you create a new Level (or a new 'map' in some naming convention) you are effectively creating a new UWorld asset (it has even a factory !):
12+
13+
```python
14+
from unreal_engine.classes import WorldFactory
15+
16+
factory = WorldFactory()
17+
new_world = factory.factory_create_new('/Game/Maps/FooLevel')
18+
```
19+
20+
The new_world object is effectively a UWorld. Whenever you create a level from the editor you are creating a world (yes, it sounds weird...)
21+
22+
Now, sometimes (like in the open world example before), you want multiple of this world to be active at the same time in the same viewport. But a viewport is mapped to a single world, so an additional abstraction (ULevel) is required.
23+
24+
So by default, for each UWorld you have a ULevel object representing it, but you can load additional UWorld's and 'combine' them with the 'main' one.
25+
26+
Let's try to clarify things wth another example (read comments carefully):
27+
28+
29+
```python
30+
from unreal_engine.classes import WorldFactory
31+
32+
factory = WorldFactory()
33+
34+
# create a world (it will be the main one, the one you load into the editor by double clicking it)
35+
main_world = factory.factory_create_new('/Game/Maps/MainWorld001')
36+
37+
# create another world
38+
child_world1 = factory.factory_create_new('/Game/Maps/ChildWorld001')
39+
40+
# create another world
41+
child_world2 = factory.factory_create_new('/Game/Maps/ChildWorld002')
42+
43+
# now the important part, each UWorld, has a ULevel mapped to it (the PersistentLevel):
44+
45+
main_level = main_world.PersistentLevel
46+
child_level1 = child_world1.PersistentLevel
47+
child_level2 = child_world2.PersistentLevel
48+
49+
```

0 commit comments

Comments
 (0)