Hi, I'm the programmer of this here fine game.
Thought I’d share some gifs and outline my journey to get the character to contour along the deformable surface. The decision to allow the player to contour to the surface was to fix the buggy feel of climbing up slopes (which was pretty much just jumping up them).
I started with a simple, raycast from the bottom vertices of the character, find the floor hit position, and place the vert at hit position.
Basic scenarios were working. But steep slopes were problematic. If you increase the ray length then the shape extended way too far down the slope. So, I rotated the player and raycast down based on the surface normal.
That sucked because if the corners couldn’t find a position then you’d just snap to the rectangle.
So far, this was just visual shape, the collider was still a rectangle and that was impractical because at steep slopes where the collider was and what you could visually was way off. I took drastic measures and decided to change the collider as I contoured the visual shape.
I start with an initial raycast down to find the highest surface point (yellow circle). That’s the anchor point. Then I iterate from the point raycasting at negative the normal of the previous point. Basically the idea is that the surface shouldn’t be thaaaaat different.
Movement was slick, collider was changing, performance was good.
That was the next challenge was angling the character based on the surface. A few of the previous gifs show some experiments into how I tried going about to angling the sides based on the surfaces.
I went with, if the normals of the surface of the sides were similar then I’d just choose one normal and rotate the verts based on that side. Otherwise to try and get the top verts to curve based on having both sides different was too complicated for what it would add.
Last step was to add the eyes. I travel along the floor verts until the length is similar to the x length of the base rectangle eye position. Then place the eye above that postion based on the normal of the surface at a distance equivalent to the base height.
This part was funny. Loved the crazy eyes bug.
The system is far from perfect. The biggest thing for me was trying to shoe horn around all the other systems built into the character like the animation system, collision system, etc. It’s a raycasting masterpiece. LOL. :’D
If you’ve got any ideas, thoughts, anything. If you have good articles on collision detection, platformer movement, physics, anything you think I should read. Let me know.