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
Any thoughts?
Edit;
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
TLDR;
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
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!
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
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
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.