Garry's Mod Wiki

Entity:GetPhysicsObjectNum

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

Page Links


Special Pages


Wikis

?

Render Time: 41ms

DB GetPage 3
Generate Html 8
SaveChanges (1) 15
Render Body 0
Render Sidebar 12