Player gets pushed away when he get attacked by an enemy(knockback)

Make sure to format your code pastes


Knockback is a common issue with the character body template, the player needs to accelerate towards their target SPEED rather than be set instantly to it.

Should change to something like this

const ACCELERATION = 1500

var target_velocity: Vector2 = direction * SPEED
velocity = velocity.move_toward(target_velocity, ACCELERATION * delta)