Garry's Mod Wiki

Entity:PhysicsInitBox

  boolean Entity:PhysicsInitBox( Vector mins, Vector maxs, string surfaceprop = "default", Vector massCenterOverride = nil )

Description

Makes the physics object of the entity a AABB.

This function will automatically destroy any previous physics objects and do the following:

If the volume of the resulting box is 0 (the mins and maxs are the same), the mins and maxs will be changed to Vector( -1, -1, -1 ) and Vector( 1, 1, 1 ), respectively.
Clientside physics objects are broken and do not move properly in some cases. Physics objects should only created on the server or you will experience incorrect physgun beam position, prediction issues, and other unexpected behavior.

A workaround is available on the Entity:PhysicsInitConvex page.

Issue Tracker: 5060

Arguments

1 Vector mins
The minimum position of the box. This is automatically ordered with the maxs.
2 Vector maxs
The maximum position of the box. This is automatically ordered with the mins.
3 string surfaceprop = "default"
Physical material from surfaceproperties.txt or added with physenv.AddSurfaceData.
4 Vector massCenterOverride = 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. This fails when the game cannot create any more PhysCollides.