This is a 2D top down game. I want to player to get knocked back far away, when collide with an enemy. The problem is, the player gets knocked back too fast that you can barely see the animation of being knocked back. How do I get smooth knockback like the player slowly slide back? This is on my Player script: Code (CSharp): public void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.tag == "Enemy" && health.MyCurrentValue > 0) { Direction = (transform.position - other.transform.position); MyRigidbody.AddForce(Direction.normalized * 5000, ForceMode2D.Force); } }
thanks, I solved it I used rigidbody.MovePosition(position) and freeze direction = vector2.zero(player cant move while knockback). Then I added knockback length and distance to my original code. I removed Addforce because its too strong. New method makes the player slide back really smoothly and you can adjust the values. https://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html