PhysObj.SetMaterial

From GMod Wiki

Jump to: navigation, search
Function
Syntax PhysObj.SetMaterial( String material )
Description:
Sets the material. Used for Various things.
Returns: nil
In Object: Physobj
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=PhysObj.SetMaterial]PhysObj.SetMaterial [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionRandomly chooses a material and applies it to the physics object
Used onNewerShared.png
Code
MaterialTypes = { "metal_bouncy",
				"metal",
                                "default", // for props with no assigned physics material - similar to wood
				"dirt",
				"slipperyslime",
				"wood",     //floats on water
				"glass",
				"concrete_block",
				"ice",
				"rubber",
				"paper",
				"zombieflesh",
				"gmod_ice",      //slippery
				"gmod_bouncy",
                               "gmod_silent" } // no collision noises
 
local phys = self:GetPhysicsObject()
 
if ValidEntity( phys ) then
 
	phys:Wake()
	phys:SetMaterial( table.Random( MaterialTypes ) )
 
end
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox