First of all, this is not an error - it's a warning. Warnings are information telling you that you're doing something that may be incorrect.
In this case, move_and_slide()
returns a value. An important value - from the docs:
Returns the linear_velocity vector, rotated and/or scaled if a slide collision occurred.
So when using move_and_slide()
you should always capture that return value as it's the changed velocity.
velocity = move_and_slide(velocity, Vector2(0, -1))
The other thing you're doing wrong is moving the body twice in the same frame. Don't use both movement methods at once. Use move_and_collide()
if you need moving/bouncing. Use move_and_slide()
if you need movement plus a slide collision response.
This will ensure, for example, that the gravity doesn't accumulate when you're moving along the ground.