here's my version of knock back system. It can be used in variety of ways in 2d form.
This is were the knockback happends:
var collision = move_and_collide(velocity * delta)
if collision:
var reflect = collision.remainder.bounce(collision.normal)
velocity = velocity.bounce(collision.normal)
reflect = move_and_collide(reflect)
velocity = velocity.move_toward(Vector2.ZERO, 90 * delta)
if velocity == Vector2.ZERO:
states = (It returns back to your previous states after the knock back)
This is the function in were you put the direction on were to knock back:
func knockback(_point_from_knockback : Vector2):
var knock_point = _point_from_knockback - global_position
velocity = -knock_point.normalized() * 80
states = (whatever state knock back is)