Tried to force control angular velocity to get no rotation to my object but I failed.
Even if I set angularVelocity two times (before render and after), the object still rotates. How to stop it from rotating?
engine.runRenderLoop( () => {
if ( player.physicsImpostor ) {
player.physicsImpostor.setAngularVelocity(
new BABYLON.Vector3( 0, 0, 0 )
);
}
scene.render();
if ( player.physicsImpostor ) {
player.physicsImpostor.setAngularVelocity(
new BABYLON.Vector3( 0, 0, 0 )
);
}
} );
Also tried this approach but it also doesn’t allow me to limit the angular velocity:
scene.registerBeforeRender( () => {
if ( player.physicsImpostor ) {
player.physicsImpostor.setAngularVelocity( new Vector3( 0, 0, 0 ) );
}
} );
scene.registerAfterRender( () => {
if ( player.physicsImpostor ) {
player.physicsImpostor.setAngularVelocity( new Vector3( 0, 0, 0 ) );
}
} );
engine.runRenderLoop( () => {
scene.render();
} );
Example: Playground
Let’s say we are making a physics humanoid character controller that presented as a capsule impostor (or something like this) and we should prevent it from fall to its side (I mean not to lay down to its side). So we have two possible options here: freeze rotation (don’t know how to do it ) and slightly control the rotation to always have almost the same direction of a capsule (more natural behaviour).