Inheriting platform velocity on rigidbody character controller

Godot Version

4.3

Question

So I’m building a RigiBody3D Character controller for my game and I’m using the floating capsule method which uses a raycast for it’s feet, and floats the RigidBody above using a spring function. It’s been easy enough to pass gravity through the raycast to the platform below and normals and other things, but I’m struggling with platform velocity. Looking online, it seems like an issue people either never encounter, or never resolve. I figured I better ask for help before I go crazy :stuck_out_tongue:

What I want is for the character to gain the velocity of whatever it’s standing on in a realistic way. it should lurch a little bit when the platform moves but mostly stick to its position. I also want it the keep the velocity if it jumps off of, say, a swing, to gain a longer jump.

Currently, I have a function set up to get the velocity at the raycast collision point. I add that velocity to a function that calculates the character’s movement and it’s multiplied by the character’s mass and applied as a force. The problem is it’s sluggish and inaccurate. I’ve tried lots of different formulas and methods to apply the force, or just changing the velocity directly, but nothing that works works any better than the original method.

I used another method to parent the player to whatever platform he’s on, and it worked perfectly. The problem I have with this is when you jump off of a moving object, you seemingly lose the extra velocity.

I made moving platforms using a RigidBody node attached to a CharacterBody by a physics joint. This gives me some fun wobbling and stuff. I also made a rotating tube to test the point velocity. I’ve noticed that sometimes the rotating tubes’ velocity passes through to the player much more accurately.

Things I am going to try:

  • making platforms with AnimatableBodys, and RigidBodys with no character Controllers, and see if makes a difference.
  • Make platforms with different movements types (rotating, tilting, etc.
  • maybe using joints in a similar way to parenting?
  • retry the parenting method and see if I can get velocity to pass into a jump

If anyone has any advice, tutorials, or insight to how physics works in Godot (currently using Jolt for the joints), or how physics works in general because I’m not that smart, I’m all ears!!

You can try adding a physics material to both rigid bodies and turn up the friction. (the body with the least friction will provide the friction coefficient, so player should be really high, and the surfaces can be calibrated to various materials. (ice, dirt, etc.))

The issue is the player is floating above the surface, so I’m looking to simulate friction somehow. I’m now sure how friction is calculated mathematically so I can’t get the value right.