Help with custom kinematic/dynamic rigidbody movement engine

So, this is going to sound a bit weird, but for my 2D game, I’m making a 3D version alongside it. I’m doing it for the cutscenes, which are going to be pre-rendered recordings of me playing back things in the 3D thing, but with augmentations to animate everything.

I know completely well that doing a fully dynamic engine would work well, and it does, but my main problem is that I go for a bit more realism for it, as the 2D version delves mostly into realism; I kinda need it for the 3D part.

Unfortunately, doing that in full dynamic just sucks. I want a bit of slippery, but not much slippery, so I set the dampening high; then I don’t fall well. And finally, I was like, “I could have the grounded state have custom dampening, then switch to dynamic for the mid-air stuff. Unfortunately, doing kinematic rigidbodies is quite hard, as everything requires a check to work. I can’t figure out how to add some of the things that are quite important, like slopes and walls. The more I do, the buggier it gets, so I’m getting kinda scared to touch it.

Does anyone know how to fix this?

Scene: PlayCanvas | HTML5 Game Engine

Code: PlayCanvas | HTML5 Game Engine

Note: When in dynamic mode, your inputs don’t affect movement quite as much as it does in kinematic mode, since dynamic is meant for the air, where you aren’t supposed to be able to adjust your movement very well, but you still can, just a little bit.

The way I’ve done this in the past is to apply custom forces depending the on state of the player. eg I wanted a jump that was lofty going up but when going downwards, I wanted it a bit faster. So I applied extra downward force on the player when the velocity in the Y axis is negative (downwards)

eg PlayCanvas 3D HTML5 Game Engine

So, do permanent dynamic everywhere except on moving platforms, like normal? Okay. TBH, I didn’t think about it too much, as I feel like touching any of the dynamic rigidbody variables causes the system to reset to nothing, but I have learned how to keep momentum after that, so.

I guess I could try that. Give me a bit.

Alright, I think I got it working with a more dynamic driven system. because of how complicated some of the system workings are, I needed to rewrite a good amount, and because there’s a mode for being “In the air”, I decided that the best way to run it is with a list of IDs that show what floors that the player touched, and when they stop touching a floor, to remove the ID from the list, and if the list is empty, enter air mode.

Gravity now gets applied with a manual increase when Qiste is falling. (Gravity is untested)

I will work on other things as I find them, but it feels a lot better and I’m no longer about to pull my hair out.

If both your character shape (capsule?) and ground have friction 1.0, then there will be no “slippery” motion. You can keep your character friction at 1.0 always, and adjust your ground friction depending on surface and desired effect. The physics engine will multiply them both together to get final value of how “slippery“ it would feel.

1 Like