So, slopes already work perfectly dure to godot 4's characterbody system, but i have a problem. I want the player to go into a new state when they are crouching and on a slope, but i have no idea how. if possible, could the player's velocity be changed by how steep the slope is? Thanks.

    SuperMatCat24
    You could use a raycast pointing down and use get_collision_normal().
    Also if you are using move_and_collide() it returns collision information including what you are looking for.

    9 months later

    SuperMatCat24
    Just a sideby question. How did you manage the slopes with the characterbody system?
    I always use raycasting so it would be interested every other way.
    No little jumps while going downwards on slopes?

      8 days later

      c0d3r9 You mean like snapping to the slope? I'd just change the snap_length in the charachterbody floor settings.

      a month later

      My method is in your CharacterBody2D script, check if get_floor_angle() is over let's say 0.4 (you can figure out which angle you want to use. 45 degree is over 0.7 for sure). If it returns a 0, you're on flat ground. if it's over 0.7, you're on a 45. 0.4 is a good round number. I use this to disable running up a 45 degree angle which I use for my staircases.