Remove player pushack

From Valve Developer Community
Revision as of 13:44, 24 June 2025 by DrN0 (talk | contribs)
Jump to navigation Jump to search

In this tutorial i will show you how to remove the push back velocity when a player takes a hit.

Nopushback.gif

This tutorial was made using Source SDKbase 2013 Multiplayer - the legacy version >_> not the team fortress 2 update.

To start open your game solution - find and open the player.cpp file and find the CBasePlayer::OnTakeDamage_Alive function around line 1708

in the middle of the function youll find this block of code below [code]if ( info.GetInflictor() && (GetMoveType() == MOVETYPE_WALK) && ( !attacker->IsSolidFlagSet(FSOLID_TRIGGER)) ) { Vector force = vecDir * -DamageForce( WorldAlignSize(), info.GetBaseDamage() ); if ( force.z > 250.0f ) { force.z = 250.0f; } //ApplyAbsVelocityImpulse( force ); drn0 disabled to remove pushback on hit }[/code]

like so remove the call ApplyAbsVelocityImpulse( force ); from the end of the calculation

this removes the velocities resolution from the OnTakeDamage - but still Alive fuction

Then proceed towards line 5670 to find the void CBasePlayer::VelocityPunch( const Vector &vecForce ) function within this youll find the code void CBasePlayer::VelocityPunch( const Vector &vecForce ) { // Clear onground and add velocity. SetGroundEntity( NULL ); //ApplyAbsVelocityImpulse(vecForce ); drn0 removing pushback on hit }

this is the initial velocity function to set the force applied at the time i believe so we remove that tihs too.

go ahead and compile the solution - there shouldnt be any errors but if you get any let me know. now when you get hit you dont get magically slide backwards 2 arm lengths away - you just stand there and eat it. this was implemented in A Nights Haunting: Source