[SOLVED] Player teleports when using Rigidbody.AddForce

When I hit an enemy, I use a function that pushes the player away from the enemy.
But for some reason, the player teleports instead of being pushed.
Pushing:

        Vector3 direction = (transform.position - enemyPos).ZeroY().normalized;
        _body.AddForce(direction * forceToPush, ForceMode.Impulse);

But the funny thing is that I use AddForce for jumping and for jump platforms on the Y axis and it works perfectly. Why is that?

Jumping:

        Vector3 _jumpingVector = new Vector3(0, jumpSpeed, 0);
         _body.AddForce(_jumpingVector, ForceMode.Impulse);

Jump Platform:

        _playerBody.velocity = Vector3.zero;
        _playerBody.AddForce(directionToBounce * forceForBounce);

I don’t use any Standard assets for controlling the player (I know they are buggy)
The player is not Kinematic and uses gravity.
Players animator is not on Animated physics.
Rigidbody is not constrained.
My movement is not resetting the X and Z axis. (I even tried removing the movement script to test that)

I have figured what have been constraining the player and instead of using physics, he teleported.
Something with his animation that did not let him be physically pushed ( I disabled the animator and he is being pushed again. )

Edit: the cause of it was “Apply Root Motion” in the Animator.

3 Likes