PhysObj.IsValid

From GMod Wiki

Jump to: navigation, search
Function
Syntax PhysObj:IsValid( )
Description:
Returns true if the PhysObj is really valid physis.
Returns: Boolean
In Object: Physobj
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=PhysObj.IsValid]PhysObj.IsValid [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionIn this example we use Ent:GetPhysicsObject():IsValid() to determine whether or not a entity has Mass.
Used onNewerServer.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