Skip to content

Commit 7371c0d

Browse files
author
Roberto De Ioris
committed
2 parents fd510cc + 157a6b3 commit 7371c0d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/Foliage_API.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# The Foliage API
2+
3+
Each UWorld can have its AInstancedFoliageActor dedicated to drawing foliage.
4+
5+
Basically the foliage system is massive instancing of static meshes.
6+
7+
UFoliageType is the representation of a StaticMesh that can be drawn as Foliage.
8+
9+
You can create a UFoliageType easily:
10+
11+
```python
12+
from unreal_engine.classes import FoliageTypeFactory, StaticMesh
13+
import unreal_engine as ue
14+
15+
factory = FoliageTypeFactory()
16+
foliage_type = factory.factory_create_new('/Game/Foliage/FirstFoliageType')
17+
foliage_type.Mesh = ue.load_object(StaticMesh, '/Game/Mesh/StaticMesh001')
18+
foliage_type.save_package()
19+
```
20+
21+
To add a UFoliageType to a UWorld just do:
22+
23+
```python
24+
25+
world.add_foliage_asset(foliage_type)
26+
```
27+
28+
Eventually you can add a StaticMesh (instead of a FoliageType) directly to the AInstancedFoliageActor:
29+
30+
```python
31+
world.add_foliage_asset(ue.load_object(StaticMesh, '/Game/Mesh/StaticMesh001'))
32+
```
33+
34+
Note: unfortunately the foliage editor is not automatically updated, just switch the editor mode manually to the foliage mode to update the assets list.
35+
36+
You can get a reference to the AInstancedFoliageActor of a world using:
37+
38+
```python
39+
foliage_actor = world.get_instanced_foliage_actor_for_current_level()
40+
```

0 commit comments

Comments
 (0)