Dumped the 2D game. It was going okay technically but just wasn't fun to play so had to make the decision to scrap it.
Back determined to write a 3D platform game again, so back to grappling with a 3D character controller. Learned a few tricks in the 2D game to do with raycasting to find the floor for handling slopes, hopefully will make this more successful than last time. CC's are a nightmare to get right.
At least I made a reasonable model as part of the 2D game that I can use in this one when I get to that point.
Have written a simple level editor that should be able to be expanded as this develops.
But until I can get the capsule behaving correctly with slopes and so on, no progress in any other area.
I have my own GJK implementation working fine as is - the character can be moved around with WASD and R/F to rise/fall and collides and responds correctly to the level geometry, and it is set up to be able to do raycasts but I've had a few dummy runs of trying to get slope behaviour working well with gravity and so far it has all ended in tears.
The key seems to be to only apply gravity when you are not grounded, but the distance to the ground is different for a capsule depending on the angle of the slope, which makes it tricky. I also want to have a maximum climbable slope angle and have steeper slopes block the character but still allow sliding. Its a nightmare. Nobody understands my pain.
I will battle on. Victory or death.
I understand the pain, believe me !
Character controller as mix of user controlled and physics controlled, is really hard. I'm still not satisfied with my character controller yet, thought here are some ideas:
Ground detection: I use two flags for ground contact, one for even frames and one for uneven frames. I only take away user control, if both flags are not set, that is, if the character don't have contact in two consecutive frames.
Raytests: Raytests are really useful, but the question is how do you use the result ?
If you try to teleport the character to the target position after a successful raytest, you could end with an unwanted intersection. One solution would be to either use forces to move the character into the desired direction and let the physics engine handle all the stuff, including walking up a slope, or you can do a collision test before teleportion. The first approach would result in some messy force stuff (keep forces so that velocity is constant regardless of slope), the latter stuff needs more collision test (if first collision test failes, move it up/down and test again, binary search)