A character that can switch between basic controls and bouncy ball physics

Godot Version

4.4

Question

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?

what about it changes slightly? Can you paste your code?

the thing is, i got it to work but wasn’t happy with it, so I started over. if I get back to the point where I was I will send it.

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.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.