I'm making 2D top down character controller. Right now it looks something like this
direction = get input direction
velocity = (direction * speed)
if not direction.x:
decelerate x
if not direction.y:
decelerate y
Now what if I want to receive knockback from getting hit by an enemy? If I add the knockback vector to velocity, it will just be overwritten the next frame and reset back to the movement velocity. How do I make a character controller that allows for knockback?