Garry's Mod Wiki

PhysObj:GetMaterial

  string PhysObj:GetMaterial()

Description

Returns the physical material ($surfaceprop) of the physics object.

See util.GetSurfaceData for a function that adds these types as well as further explanation of what they are.

Returns

1 string
The physical material name. ($surfaceprop)

Example

Play an appropriate sound when we hit something.

function ENT:Initialize() local phys = self.Entity:GetPhysicsObject() if IsValid(phys) then self.ImpactSound = util.GetSurfaceData(util.GetSurfaceIndex(phys:GetMaterial())).impactHardSound end end function ENT:PhysicsCollide(data, physobj) if (data.Speed > 50) then self:EmitSound(Sound(self.ImpactSound)) end end