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

That’s a really helpful explanation.

1 Like

Thx for that. That’s actually quite helpful to know. Although I switched the system to be almost completely dependent on dynamic by incorporating 3 states: grounded normal, Midair, and kinematic (for moving platforms)

Now that I’ve got everything that feels good to move, time for the main part of this system that I’ve been working on: recording. I will eventually turn this project into a 3D remake for my game, but for now, I am just trying to make pre-rendered 3D cutscenes for my current version. I have a script that makes the recording process by finding the position of Qiste while currently recording and storing it; then I can read the stored list to play back the recording. I was thinking of making Qiste move around while I record the angle and positions of them, then play back the movements to make sure it looks good, then create the scene that the cutscene plays, and map camera positions and angles to watch the cutscene play out, then add the animations to Qiste before making the final version, then screen record the final version

unfortunately, I can’t seem to make the angling work. I tried multiple methods, but they all set the angle to non-numeric values. And it’s kinda needed to angle the character. I will say that the actual entity isn’t rotating, but because the model is stored in a child entity of Qiste, I am rotating the model’s base entity, since the model is broken up into different children of the base model entity (since it was originally a VRM file, which are usually naturally broken up for smoother and more consistent rigging). the problem seems to be a problem with slerp, as it’s always coming back as “[NaN, NaN, NaN, NaN]”. I could use the teleport command, but that breaks the rest of the script, so I’d rather not.

once I get that, I need to change the actual Qiste Model, since rigging it would be really hard, and the current model won’t be able to be as expressive as the new model, as the model not to good for it. I’m thinking of switching to a more rigid and blocky style, so I can draw the faces on, allowing for more expressive personality and charm than the current version, it will also be easier to animate as I won’t have to worry about the animation looking realistic, but at least good. I will try to be as realistic as possible though.

NVM I got it working. I forgot to define this.rotationSpeed

still will have other issues later

Welcome to this wonderful community BTW. Almost everyone is willing to help you if you’re experiencing any troubles.

1 Like