Entity:PhysicsInitConvex
boolean Entity:PhysicsInitConvex( table points, string surfaceprop = "default", Vector massCenterOverride = nil )
Description
Initializes the physics mesh of the entity with a convex mesh defined by a table of points. The resulting mesh is the of all the input points. If successful, the previous physics object will be removed.
This is the standard way of creating moving physics objects with a custom convex shape. For more complex, concave shapes, see Entity:PhysicsInitMultiConvex.
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.
function ENT:Think()
if ( CLIENT ) then
local physobj = self:GetPhysicsObject()
if ( IsValid( physobj ) ) then
physobj:SetPos( self:GetPos() )
physobj:SetAngles( self:GetAngles() )
end
end
end
Issue Tracker: 5060
You can use the following workaround for movement, though clientside collisions will still be broken.
Issue Tracker: 5060
Arguments
1 table points
A table of eight Vectors, in local coordinates, to be used in the computation of the convex mesh. Order does not matter.
2 string surfaceprop = "default"
Physical material from surfaceproperties.txt or added with physenv.AddSurfaceData.
3 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
Example
Creates a "box" physics mesh for the entity.