(Update!) Better Knockbacks using Add Force and Linear Drag Only - Unity 2022 @ChrisTutorialsYT
(Update!) Better Knockbacks using Add Force and Linear Drag Only - Unity 2022  @ChrisTutorialsYT
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.
(Update!) Better Knockbacks using Add Force and Linear Drag Only - Unity 2022Typed Dictionaries & Arrays ~ Gdscript Tutorial for Godot 4.4+Global Singleton SignalBus to Send Data Between Objects Anonymously ~ Godot 4.1 ExampleOn Hit Make Enemy Red Shader Script ~ 1 Bit Platformer Part 13 ~ Godot 4.3Setting Import Presets in the Preset Manager ~ Unity GameDev TutorialHow to Make UI React to Gameplay with UnityEvents & UnityActions C# Tutorial
Chris Tutorials |

(Update!) Better Knockbacks using Add Force and Linear Drag Only - Unity 2022

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER