Garry's Mod Wiki

CTakeDamageInfo:SetDamageForce

  CTakeDamageInfo:SetDamageForce( Vector force )

Description

Sets the directional force of the damage.

This function seems to have no effect on player knockback. To disable knockback entirely, see EFL_NO_DAMAGE_FORCES or use workaround example below.

Arguments

1 Vector force
The vector to set the force to.

Example

Workaround for player knockback quenching.

local ent = Entity(1) local oldvel = ent:GetVelocity() -- Damage taking example local dmgi = DamageInfo() dmgi:SetDamageType( DMG_RADIATION ) dmgi:SetDamage( 5 ) dmgi:SetAttacker( Entity(0) ) dmgi:SetInflictor( Entity(0) ) ent:TakeDamageInfo( dmgi ) local newvel = ent:GetVelocity() ent:SetVelocity( oldvel - newvel )