Hello everyone, I am working on a 2D platformer game, and I am facing a challenge coding the player movement. The intended behaviour is for the player to be able to walk around any shape, circles, triangles, etc, sticking to it and snapping on vertices. Currently I am using a state machine in combination with a series of get_wall_normal(), get_floor_normal() and get_ceiling_normal() functions to rotate the player sprite depending on the surface. This works specially well on the floor where the player can snap to any surface using the editor settings. (Snap Lenght, and Max Angle). But these settings only exist for floors, and I am finding trouble defining the same behaviour to something that is not the floor.
Any suggestions or solutions out there?
How would you start off making something like that with raycasts.
Im really confused about the use of raycasts and other slightly more advanced functions and am quite new to game development in general.
I hear you. It is confusing. You will be wise to start at the start. Do the Godot tutorials and get comfortable with gdscript. Then start searching around for any info about rays etc.
Incremental is the best way.
As to raycasts, all the pageantry aside, you shoot a ray from your player down to their feet. You get a bunch of data back. Part of that is the normal of the surface you are on.
(There’s also a RayCast2D node, which makes it easy to see.)