Garry's Mod Wiki

Revision Difference

PhysObj:ApplyForceOffset#546351

<function name="ApplyForceOffset" parent="PhysObj" type="classfunc"> <description>Applies the specified force on the physics object at the specified position</description>⤶ <description>Applies the specified impulse on the physics object at the specified position.</description>⤶ <realm>Shared</realm> <args> <arg name="force" type="Vector">The force to be applied.</arg> <arg name="position" type="Vector">The position in world coordinates where the force is applied to the physics object.</arg> <arg name="impulse" type="Vector">The impulse to be applied in `kg*source_unit/s`. (World frame)</arg> <arg name="position" type="Vector">The position in world coordinates (`source units`) where the force is applied to the physics object.</arg> </args> </function> <example> <description>Pull what the player is looking at towards him.</description> <code> local tr = Entity(1):GetEyeTrace() if IsValid(tr.Entity) then local phys = tr.Entity:GetPhysicsObjectNum(tr.PhysicsBone) local pushvec = tr.Normal * -100000 local pushpos = tr.HitPos phys:ApplyForceOffset(pushvec, pushpos) end </code> </example>