Garry's Mod Wiki

Garry's Mod Wiki

  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 or nil if not found

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

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...