"moveWithCollisions" with havoc?

Hey team,

What’s the best method to setup meshes to work simular to “mesh.moveWithCollisions” using Havoc?
Here i tried something very simple, any key makes the dummy run forward and push the sphere.

But what if i want the sphere to be static? i give it mass 0 and dummy pass straight through it!
Same for the ground mesh if i add gravity to the dummy’s velocity, falls straight through the ground mesh :slight_smile:

Any thoughts?

Digging a bit further in the docs, it seems because i used BABYLON.PhysicsMotionType.ANIMATED

So now how could you use BABYLON.PhysicsMotionType.DYNAMIC but lock rotations so it doesn’t fall over or anything, just stop moving :thinking:

Does Havoc have a method to lock the rotations of a physics body?
I found this in an old post, @Cedric suggesting a solution for ammojs

I tried body.setAngularVelocity(BABYLON.Vector3.Zero()) every frame
and body.setAngularDamping(Number.MAX_SAFE_INTEGER) which seem to be the only angular methods exposed? it did not fix it.


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 :smile:
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


It´s not perfect but Hope it helps!


Looks cool! :slight_smile:
But without a angular lock, something could still knock him over :slightly_frowning_face:
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 :thinking:

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,

I dont know, but hope Havoc have a proper angular lock on physicsBody internally that just haven’t been exposed yet :slight_smile:

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

1 Like

Maybe yeah, keep the physicsBody on a parent of the model so you can rotate the model itself freely :+1:

       inertia: new BABYLON.Vector3(0, 0, 0)

Manually setting inertia is what we’re looking for


Seems logic!! Good job sir :raised_hands::raised_hands::raised_hands:

Working nice!
Using the Capsule collider and the inertia solution provided by @Raggar


Works super fine! Congrats :slight_smile:

1 Like

I think I’m not yet used to how powerful Havok is :smiley:


Great find!

1 Like

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.


@Cedric any news on that Character Controller?