StaticMesh
StaticMesh is a callable class for spawning a static mesh actor into the world with configurable collision behavior.
It wraps Unrealโs AStaticMeshActor and its UStaticMeshComponent, giving direct access to mesh, mobility, transform, materials, and all standard component functions.
This is ideal for props, obstacles, architecture, or decorative geometry in your scene
/// tip
StaticMesh is an Actor so it inherits all functions from Actor
///
Constructorโ
Example
local cube = StaticMesh(
Vector(0, 0, 100),
Rotator(0, 0, 0),
"/Engine/BasicShapes/Shape_Cube.Shape_Cube",
CollisionType.StaticOnly,
false
)
| Name | Type | Default | Description |
|---|---|---|---|
Location | Vector | (0,0,0) | World position to spawn the mesh |
Rotation | Rotator | (0,0,0) | Initial rotation of the mesh actor |
MeshPath | string | Required | Asset path to a UStaticMesh (e.g. Shape_Cube) |
CollType | enum | CollisionType.Auto | |
bStationary | boolean | Required | Sets mobility |
Functionsโ
SetStaticMeshโ
Changes the mesh to another asset at runtime
- StaticMesh:
UStaticMeshโ the mesh asset to apply
Example
cube:SetStaticMesh(LoadObject("/Game/Props/MyMesh.MyMesh"))
SetMaterialโ
Applies a material to the mesh by index
- ElementIndex:
numberโ material slot index - Material:
UMaterialInterfaceโ material to assign to the slot
Example
cube:SetMaterial(0, MyMaterial)
SetCollisionEnabledโ
Changes the meshโs collision mode after spawn
- CollisionType: CollisionType โ collision mode to apply
Example
cube:SetCollisionEnabled(CollisionType.NoCollision)
SetMobilityโ
Sets whether the mesh is movable, static, or stationary
- Mobility:
EComponentMobilityโ mobility state (Static, Stationary, Movable)
Example
cube:SetMobility(UE.EComponentMobility.Movable)