Garry's Mod Wiki

Revision Difference

CTakeDamageInfo:SetDamageForce#549416

<function name="SetDamageForce" parent="CTakeDamageInfo" type="classfunc"> <description> Sets the directional force of the damage. <note> This function seems to have no effect on player knockback. To disable knockback entirely, see [EFL_NO_DAMAGE_FORCES](https://wiki.facepunch.com/gmod/Enums/EFL#EFL_NO_DAMAGE_FORCES) or use workaround example below. </note> </description> <realm>Shared</realm> <args> <arg name="force" type="Vector">The vector to set the force to.</arg> </args> </function> <example> <description>Workaround for player knockback quenching.</description> <code> local oldvel = Entity( 1 ):GetVelocity() 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) ) Entity( 1 ):TakeDamageInfo( dmgi ) local newvel = Entity( 1 ):GetVelocity() Entity( 1 ):SetVelocity( oldvel - newvel ) ent:TakeDamageInfo( dmgi ) local newvel = ent:GetVelocity() ent:SetVelocity( oldvel - newvel ) </code> </example>