Garry's Mod Wiki

Entity:PhysicsFromMesh

  boolean Entity:PhysicsFromMesh( table vertices, string surfaceprop = "default", Vector massCenterOveride = nil )

Description

Initializes the physics mesh of the entity from a triangle soup defined by a table of vertices. The resulting mesh is hollow, may contain holes, and always has a volume of 0.

While this is very useful for static geometry such as terrain displacements, it is advised to use Entity:PhysicsInitConvex or Entity:PhysicsInitMultiConvex for moving solid objects instead.

Entity:EnableCustomCollisions needs to be called if you want players to collide with the entity correctly.

Arguments

1 table vertices
A table consisting of MeshVertex structure (only the pos element is taken into account). Every 3 vertices define a triangle in the physics mesh.
2 string surfaceprop = "default"
Physical material from surfaceproperties.txt or added with physenv.AddSurfaceData.
3 Vector massCenterOveride = nil
If set, overwrites the center of mass for the created physics object.
This was recently added in version (2024.10.29). It might only be available on the Dev Branch right now.

Returns

1 boolean
Returns true on success, nil otherwise.