How can my character stop moving immediately after it gets hit by enemy?

My character have a rigidbody and using a third person controller to make it move. I have add some script to let the character cannot move and attack when it get hit by enemy.

After that, when it get hitted it seems have an inertia so that it is playing my “hit” animation and sliding towards a direction which I get hit before.
How can I solved this sliding problem?

I have try to put the below script when the player is play hit and attack animation.

rigidbody.velocity = Vector3.zero;

But it is not work and still sliding away from the last position.

Here is how we freeze (and unfreeze) our physics for objects. (We use it for Pause/Play but you should be able to adapt it for your case):

public void Pause()
{
    velocity = rigidbody.velocity;
	angularVelocity = rigidbody.angularVelocity;
    rigidbody.velocity = Vector3.zero;
	rigidbody.angularVelocity = Vector3.zero;
	rigidbody.useGravity = false;
    rigidbody.isKinematic = true;
}

public void Play()
{
    rigidbody.isKinematic = false; 
    rigidbody.velocity = velocity;
	rigidbody.angularVelocity = angularVelocity;
	rigidbody.useGravity = true;
    
}