Entity.GetPhysicsObject

From GMod Wiki

Jump to: navigation, search
Function
Syntax Entity:GetPhysicsObject( )
Description:
Returns the entity's physics object. Only physics entities have physics objects.
Returns: Physobj
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.GetPhysicsObject]Entity.GetPhysicsObject [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionCreates a prop_physics and wakes the physics object.
Used onNewerShared.png
Code
 
local ent = ents.Create("prop_physics");
ent:SetModel("model path");
ent:Spawn();
local entphys = ent:GetPhysicsObject();
if entphys:IsValid() then
     entphys:EnableGravity(true);
     entphys:Wake();
end
 
OutputN/A



DescriptionGets a prop_physics and returns its mass.
Used onNewerShared.png
Code
 
//function to return entitys mass
function returnMass(ent)
	//get physis
	local phys = ent:GetPhysicsObject();
 
	//alwayd do a IsValid check!
	if phys:IsValid() then
		//return using GetMass
		return entphys:GetMass()
	else
		//return zero if it wasnt valid
		return 0
	end
end
 
OutputMass int


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox