![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | MoarHunter11 |
Hi, I’m a fairly inexperienced developer but I feel pretty comfortable with Godot. I upgraded to Godot 4 recently and one feature, the move_and_slide() function, has been bothering me.
I’m trying to make the player get knocked back whenever an enemy comes in contact. The way I would do it in Godot 3 is like this:
knockback = knockback.move_toward(Vector2(), 140 * delta)
knockback = move_and_slide(knockback)
However, in Godot 4, move_and_slide() only works with the built in variable ‘velocity’. How can I knock the player back without interfering with my movement, which uses velocity?