Skip to main content

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
)
NameTypeDefaultDescription
LocationVector(0,0,0)World position to spawn the mesh
RotationRotator(0,0,0)Initial rotation of the mesh actor
MeshPathstringRequiredAsset path to a UStaticMesh (e.g. Shape_Cube)
CollTypeenumCollisionType.Auto
bStationarybooleanRequiredSets 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

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)
โœจ