Uploaded September 2022 | Updated September 2026, 2 weeks ago
Original Course Video: youtu.be/8rTK68omQow
I've been experimenting and I find one way is to increase the linear drag on the rigidbody set in Dynamic mode. Instead of the Lerp to 0 (removing those lines entirely), you can set the rb.drag to a higher amount to get it to stop faster (Stop drag vs moving drag as 2 different variables for different character states). This lets the knockback apply more correctly.
So for movement
// Move animation and add velocity
// Accelerate the player while run direction is pressed (limited by rigidbody linear drag)
rb.AddForce(moveInput * moveSpeed * Time.fixedDeltaTime, ForceMode2D.Force);
And in the scripts where you apply force to the player
// Apply force to the slime
// Impulse for instantaneous forces
rb.AddForce(knockback, ForceMode2D.Impulse);
Letting the linear drag handle the knockback lets the rigidbody physics smooth out the velocity between the normal run and the knockback impulse.
Original Course Video: youtu.be/8rTK68omQow
I've been experimenting and I find one way is to increase the linear drag on the rigidbody set in Dynamic mode. Instead of the Lerp to 0 (removing those lines entirely), you can set the rb.drag to a higher amount to get it to stop faster (Stop drag vs moving drag as 2 different variables for different character states). This lets the knockback apply more correctly.
So for movement
// Move animation and add velocity
// Accelerate the player while run direction is pressed (limited by rigidbody linear drag)
rb.AddForce(moveInput * moveSpeed * Time.fixedDeltaTime, ForceMode2D.Force);
And in the scripts where you apply force to the player
// Apply force to the slime
// Impulse for instantaneous forces
rb.AddForce(knockback, ForceMode2D.Impulse);
Letting the linear drag handle the knockback lets the rigidbody physics smooth out the velocity between the normal run and the knockback impulse.




