Okay, so here i used a 6DoF constraint to lock rotations, joint to a small static ground plane… but i feel like it’s a bit hacky
Also I haven’t quite figured out how to resize or update the shape? since it’s created while the dummy is in T-pose, it’s too wide!
Hi, maybe you can try to add this in your setup :
hk.setAngularDamping( dummyAggregate.body,Number.MAX_SAFE_INTEGER);
It seems to work (if I well understand your need ?) : Physics V2 Simple scene with Aggregate | Babylon.js Playground (babylonjs.com)
Hi @samuelgirardin
setAngularDamping
wont work, it seems to slow the angular velocity down, but the mesh will eventually fall over
So yeah, from what i’ve gathered, a 6DoF constraint is the only solution at the moment
To fix the shape, i used a capsule mesh as parent to the dummy, and a capsule physicsShape.
Next step is moving away from Aggregates to have better control over shapes etc. so i can then avoid the capsule mesh and set the shape size directly.
Result so far;
Edit; updated to use scene.onBeforeRenderObservable
for better result in the sample
There are a few features like angular locks(Also a Rigidbody character controller) I’ll need as well, before I can port my current project to V2. But I think giving people some time to get used to the new plugin system before adding features is only fair
Hi @aWeirdo.
Today i´ve been playing with Havok.
I´ve made some updates in your code.
The main thing is create a new Mesh to include your player and use it as PhysicsRoot
https://playground.babylonjs.com/#Z8HTUN#68
It´s not perfect but Hope it helps!
Looks cool!
But without a angular lock, something could still knock him over
i’m not a huge fan of the box shape, maybe a cylinder?
and there could be issues with e.g. stairs/sloped meshes,
both with tipping over and the flat bottom could make it impossible walking upwards/over small obstacles
Totally agree.
Undoubtedly the option would be to use a Capsule-type Mesh.
It would be necessary to see another viable solution when going up a ramp or stairs, I remember that there was a post that talked about that issue.
Also It would be a matter of investigating how to block certain axes to avoid angular rotation.
With the 6DoF constraint you can define limits,
here i just blocked all angular axis, probably should remove BABYLON.PhysicsConstraintAxis.ANGULAR_Y
to allow turning
let sixDofJoint = new BABYLON.Physics6DoFConstraint(
{
pivotA: new BABYLON.Vector3(0, 0, 0),
pivotB: new BABYLON.Vector3(0, 0, 0),
perpAxisA: new BABYLON.Vector3(0, 0, 0),
perpAxisB: new BABYLON.Vector3(0, 0, 0),
},
[
{
axis: BABYLON.PhysicsConstraintAxis.ANGULAR_X,
minLimit: 0,
maxLimit: 0,
},
{
axis: BABYLON.PhysicsConstraintAxis.ANGULAR_Z,
minLimit: 0,
maxLimit: 0,
},
{
axis: BABYLON.PhysicsConstraintAxis.ANGULAR_Y,
minLimit: 0,
maxLimit: 0,
},
],
scene
);
I dont know, but hope Havoc have a proper angular lock on physicsBody internally that just haven’t been exposed yet
IMO, it’s better to lock all axes and keep a separate variable for the rotation of the model. This way you don’t invalidate contact points by rotating around, although it might be negligible
Maybe yeah, keep the physicsBody on a parent of the model so you can rotate the model itself freely
capsuleAggregate.body.setMassProperties({
inertia: new BABYLON.Vector3(0, 0, 0)
});
Manually setting inertia is what we’re looking for
Works super fine! Congrats
I think I’m not yet used to how powerful Havok is
Great find!
Angular factor is BullerPhysics/Ammojs only.
Havok provides characterController to do basically what you did but more effectively. It’s a planned feature that will land in Babylon in the coming months.
Until thenm using this trick is perfectly valid.