Garry's Mod Wiki

Entity:GetPhysicsObjectNum

  PhysObj Entity:GetPhysicsObjectNum( number physNum )

Description

Returns a specific physics object from an entity with multiple PhysObjects (like ragdolls)

See also Entity:TranslateBoneToPhysBone.

Arguments

1 number physNum
The number corresponding to the PhysObj to grab. Starts at 0.

Returns

1 PhysObj
The physics object

Example

When run, if the player is dead it will throw their ragdoll up in the air by their head.

if ( !LocalPlayer():Alive() && LocalPlayer():GetRagdollEntity() ) then local ent = LocalPlayer():GetRagdollEntity() local head = ent:GetPhysicsObjectNum( 10 ) // 10 is usually the bone number of the head. head:ApplyForceCenter( Vector( 0, 0, 6000 ) ) end

Example

Example function that applies force to all physics objects of given entity.

function ApplySomeForce( ent ) for i = 0, ent:GetPhysicsObjectCount() - 1 do local phys = ent:GetPhysicsObjectNum( i ) phys:ApplyForceCenter( Vector( 0, 0, 10000 ) ) end end