Custom position update with havok

My situation: I use moveWithCollisions with some extra code solving upstairs/slope/jump to calculate a new position per frame for a character, now I want to play football using the character controller, and I hope the physics part affect the football but not the character so my previous work can still be used.

Take the playground above as a simple example, if I just update position, the pin moved because of the two shapes coincide rather than collide, the pin will not get a force/impulse. Besides, because the ball have mass, so the pin will affect the ball’s velocity after coincide, I tried to get velocity using getLinearVelocity and getAngularVelocity before and after frame but all zero, and I did not find a function to stop this part of velocity.

What about setLinearVelocity and setAngularVelocity to stop movement and rotation?

physicsBody.setLinearVelocity(new BABYLON.Vector3(0, 0, 0)); // movement velocity
physicsBody.setAngularVelocity(new BABYLON.Vector3(0, 0, 0)); // rotation velocity

Thanks it do work! I think I get something wrong when I was using getLinearVelocity and getAngularVelocity. But the first question still remained, maybe I need to drop my previous code.

1 Like