#[Tip] Using Python Script Auto Generate Floor & Wall
4 messages · Page 1 of 1 (latest)
you can also use PCG in python, but I haven't learned about that yet. The script is really powerful, so I hope we can share more about how to use it in different ways.
[Tip] Using Python Script Auto Generate Floor & Wall
import unreal
# Constants
WALL_MESH_PATH = "/Game/Assets/Dungeon/SM_Wall_4x2"
WALL_SPACING = 800
WALL_HEIGHT = 220
def create_wall():
# Get the editor utility library
editor_util = unreal.EditorLevelLibrary
# Before creating the wall, delete all the walls
world = editor_util.get_editor_world()
actors = unreal.GameplayStatics.get_all_actors_of_class(world, unreal.StaticMeshActor.static_class())
for actor in actors:
if actor.get_actor_label().startswith("Wall"):
editor_util.destroy_actor(actor)
# Define wall segments
wall_segments = [
{"start": unreal.Vector(0, 0, WALL_HEIGHT), "end": unreal.Vector(4800, 0, WALL_HEIGHT), "rotation": 0, "label": "Wall-Up"},
{"start": unreal.Vector(0, -4800, WALL_HEIGHT), "end": unreal.Vector(4800, -4800, WALL_HEIGHT), "rotation": 0, "label": "Wall-Down"},
{"start": unreal.Vector(-900, 200, WALL_HEIGHT), "end": unreal.Vector(-900, -3800, WALL_HEIGHT), "rotation": -90, "label": "Wall-Left"},
{"start": unreal.Vector(4600, 200, WALL_HEIGHT), "end": unreal.Vector(4600, -3800, WALL_HEIGHT), "rotation": -90, "label": "Wall-Right"},
]