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)