Topic was automatically imported from the old Question2Answer platform.
Asked By
deezy
hello. i am trying to learn about move_and*_collide and move_and_slide functions. i am getting 2 errors where they returns a value but never used. i would like to know why it happens and what to do to fix it.
i want to inform that everything is working. it moves, bounces and jumps. but i do want to learn about how it works but why, and solving errors is one way to improve.
here is the errors.
W 0:00:00:0681 The function ‘move_and_collide()’ returns a value, but this value is never used.
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.
i understand some of what your saying, but i dont understand how im using both at the same time. and in that case, how to fix it. do i move the move_and_slide so it dosent affect the move_and_collide.
deezy | 2019-08-29 14:04
What I mean by using multiple calls: first, you have move_and_collide(). If there’s a collision, you call move_and_collide() again, but don’t check for a returned collision from that one. And then after that, you call move_and_slide(), also failing to check for its returned value of the new velocity vector after a slide collision.
What happens if there’s a collision from the second move_and_collide() call? Why do you need the move_and_slide() at all? What if that move hits something? It’s not at all clear what you’re trying to accomplish here.