I am trying to make a character that can switch between a normal rolling and jumping mode(normal mode), to a mode that keeps any velocity from the other mode and can bounce, but you can’t control it while bouncing (I will refer to it as “bounce mode”). I felt like I got close to pulling it off. However, switching between “move_and_slide” and “move_and_collide” changes the physics while in bounce mode, causing the velocity from normal mode to slightly change when entering or exiting bounce mode.
I can’t find much information online about switching from move_and_slide to move_and_collide. Does anyone have an idea of how I would implement this?
This page explains the difference between the two movement methods.
# using move_and_collide
var collision = move_and_collide(velocity * delta)
if collision:
velocity = velocity.slide(collision.get_normal())
# using move_and_slide
move_and_slide()
Anything you do with move_and_slide() can also be done with move_and_collide(), but it might take a little more code. However, as we’ll see in the examples below, there are cases where move_and_slide() doesn’t provide the response you want.