Entity/GetPhysicsObject

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Doesn't return clientside)
(Better note)
 
Line 1: Line 1:
 
{{Func
 
{{Func
 
|Description=Returns the entity's physics object, if the entity has physics.
 
|Description=Returns the entity's physics object, if the entity has physics.
{{Note|Doesn't return valid physics object on clientside.}}
+
 
 +
{{Note|Entities don't have clientside physics objects by default, so this will return [NULL PHYSOBJ] on the client in most cases.}}
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=Yes
 
|IsClass=Yes

Latest revision as of 23:19, 20 June 2019

 Entity:GetPhysicsObject( )

Contents

Description

Returns the entity's physics object, if the entity has physics.

NOTE

Entities don't have clientside physics objects by default, so this will return [NULL PHYSOBJ] on the client in most cases.

Returns

PhysObj

The entity's physics object.

Examples

Example

Gets the mass of an entity.

local phys = ent:GetPhysicsObject()
if ( IsValid( phys ) ) then -- Always check with IsValid! The ent might not have physics!
	return phys:GetMass()
else
	return 0
end


Personal tools
Navigation