Accurately get velocity of btKinematicCharacterController
Posted: Sun Jan 18, 2015 3:59 pm
I need to keep track of the velocity of my btKinematicCharacterController, but it seems that's not such an easy task.
Since it's kinematic, it doesn't have any internal velocity, so I store the velocity inside my player class.
After the simulation step I need to update the velocity, in case a collision occurred. (Otherwise I'd run into problems, such as the downwards velocity continuously increasing due to gravity)
To do that, I figured I could just store the controller's position before the simulation step, then subtract it from the new position after the simulation step, to get the delta velocity. This would work fine in principle if it wasn't for a small problem:
When the character falls downwards (due to gravity or any other force) and hits the ground, there is a small moment of penetration with the ground. (I've compiled bullet with 'double' precision already)
After that, the character's position immediately shifts to the ground level, to resolve the penetration.
This, however, is interpreted as upwards velocity, because the character was slightly below the ground before the simulation step, and is now ON it, which leads to a kind of 'bouncing' effect:
http://youtu.be/ZkmyrGCgshE
That's of course not acceptable at all, so I was wondering, what is the 'proper' way of keeping track of a character's velocity, while still keeping things like collisions into account?
Since it's kinematic, it doesn't have any internal velocity, so I store the velocity inside my player class.
After the simulation step I need to update the velocity, in case a collision occurred. (Otherwise I'd run into problems, such as the downwards velocity continuously increasing due to gravity)
To do that, I figured I could just store the controller's position before the simulation step, then subtract it from the new position after the simulation step, to get the delta velocity. This would work fine in principle if it wasn't for a small problem:
When the character falls downwards (due to gravity or any other force) and hits the ground, there is a small moment of penetration with the ground. (I've compiled bullet with 'double' precision already)
After that, the character's position immediately shifts to the ground level, to resolve the penetration.
This, however, is interpreted as upwards velocity, because the character was slightly below the ground before the simulation step, and is now ON it, which leads to a kind of 'bouncing' effect:
http://youtu.be/ZkmyrGCgshE
That's of course not acceptable at all, so I was wondering, what is the 'proper' way of keeping track of a character's velocity, while still keeping things like collisions into account?