Garry's Mod Wiki


  CTakeDamageInfo:SetDamageForce( Vector force )


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.


1 Vector force
The vector to set the force to.


Workaround for player knockback quenching.

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