# Havok physics on walk

**URL:** <https://forum.babylonjs.com/t/havok-physics-on-walk/45184>\
**Category:** Questions\
**Tags:** physics, havok\
**Created:** [October 25, 2023, 1:01pm UTC](https://forum.babylonjs.com/t/havok-physics-on-walk/45184 "2023-10-25T13:01:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Octo8080X](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/octo8080x/32/35703_2.png) [@Octo8080X](https://forum.babylonjs.com/u/Octo8080X)\
**Post date:** [October 25, 2023, 1:01pm UTC](https://forum.babylonjs.com/t/havok-physics-on-walk/45184/1 "2023-10-25T13:01:20Z")

</div>

![PXL_20231024_214721456.MP (1)](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/d/dd5484de83abb9c228570996be8c674fb054d354.jpeg)

I would like to use Havok physics to walk on the simulation space.

If I enable physics, I cannot move or slide the object to any angle or to any position to bend the joint.

What implementation is needed to achieve this behavior?

I want it to walk like in the following video.

[![](https://img.youtube.com/vi/ux8jEvQ0bvw/maxresdefault.jpg "電動アクション ギルラプター") ](https://www.youtube.com/watch?v=ux8jEvQ0bvw&t=5s)

Please let me know if you need additional information so I can prepare it.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 25, 2023, 7:21pm UTC](https://forum.babylonjs.com/t/havok-physics-on-walk/45184/2 "2023-10-25T19:21:31Z")

</div>

cc @carolhmj and @Cedric

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [October 26, 2023, 7:19am UTC](https://forum.babylonjs.com/t/havok-physics-on-walk/45184/3 "2023-10-26T07:19:14Z")

</div>

did you try this ? [PhysicsBody | Babylon.js Documentation](https://doc.babylonjs.com/typedoc/classes/BABYLON.PhysicsBody#disablePreStep)

---

<div class="post-metadata">

**Author:** ![Octo8080X](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/octo8080x/32/35703_2.png) [@Octo8080X](https://forum.babylonjs.com/u/Octo8080X)\
**Post date:** [October 27, 2023, 1:54pm UTC](https://forum.babylonjs.com/t/havok-physics-on-walk/45184/4 "2023-10-27T13:54:52Z")

</div>

@Cedric  
Thanks I’ll give it a try.

---

<div class="post-metadata">

**Author:** ![Octo8080X](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/octo8080x/32/35703_2.png) [@Octo8080X](https://forum.babylonjs.com/u/Octo8080X)\
**Post date:** [October 28, 2023, 4:42am UTC](https://forum.babylonjs.com/t/havok-physics-on-walk/45184/5 "2023-10-28T04:42:32Z")

</div>

@Cedric

Thank you.

I can now do the physics calculations and move the parts around.  
I can also see it in the playground.

I have a constraint between two objects, but it slips.  
Do I need to use other restraints?

Or do I need a completely different approach?

> **[Babylon.js Playground](https://playground.babylonjs.com/#5RYY90%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [November 1, 2023, 12:01pm UTC](https://forum.babylonjs.com/t/havok-physics-on-walk/45184/6 "2023-11-01T12:01:34Z")

</div>

BTW, It appears that the specification for the Physics extension of glTF is currently under development.  
Perhaps in the near future, once this is completed, it will be possible to make a robot walk with a single glTF file.

[![](https://img.youtube.com/vi/sstdRXYbZrI/maxresdefault.jpg "Let’s Get Moving! Adding Physics to glTF") ](https://www.youtube.com/watch?v=sstdRXYbZrI&t=2114)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/6/f672367f4e6a32c65e9ce8e59dc14b22a400366a.jpeg)

---

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [November 2, 2023, 3:22am UTC](https://forum.babylonjs.com/t/havok-physics-on-walk/45184/7 "2023-11-02T03:22:45Z")

</div>

@eoin Can I try the robot in the glTF physics extension sample above?

---

<div class="post-metadata">

**Author:** ![eoin](https://avatars.discourse-cdn.com/v4/letter/e/f14d63/32.png) [@eoin](https://forum.babylonjs.com/u/eoin)\
**Post date:** [November 2, 2023, 3:08pm UTC](https://forum.babylonjs.com/t/havok-physics-on-walk/45184/8 "2023-11-02T15:08:58Z")

</div>

Hi @cx20,

Surprised that video is going around so quickly - it was only recorded on Tuesday 🙂.

You sure can see the robot, but I’m not sure how helpful it will be - it’s very much a work-in-progress and the asset isn’t done yet. In particular, I’m looking at adding a new motor type to Babylon physics (though shouldn’t be necessary for OP’s use-case) and we’ve renamed some of the glTF physics fields, so some of the existing sample assets need to be re-exported to work.

Couple of options for you; check out the “constraintMotors” branch of the plugin ([GitHub - eoineoineoin/glTF\_Physics\_Babylon at constraintMotors](https://github.com/eoineoineoin/glTF_Physics_Babylon/tree/constraintMotors)) then drag-and-drop the [robot](https://eoinrul.es/tmp/Robot_skinned.glb) (hosted on my personal site while it’s WIP) onto the demo. I also have this branch running on my personal site [here](https://eoinrul.es/tmp/babylondev/index.html#sceneUrl=https://eoinrul.es/tmp/Robot_skinned.glb) if you just want to check it out.

It’s setup a _little_ unusually, as I want it to run purely with physics (i.e. without any animation or code) but for OP’s use-case, there’s definitely a simpler way. What I’d recommend OP do is to setup a constraint which permits the “leg” to move in the allowed range. You can’t describe the red area exactly, but the idea would be to set the limits so that they cover at least that area.

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/4/e462ba3e597928a884178428174aa7eb2b841772.png)

Then, add a PhysicsConstraintMotorType.POSITION motor to the two axes; set a high max force and stiffness. In code, calculate where you want the leg to be on each axis and set the motor’s target to that position.

As for how the robot works without any code/animation, the setup looks like this:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/c/a/ca954cdf177abbb9b07533fdb8b58bdeb6ee9aa4.jpeg)

There’s a bunch of constraints which work together to get the effect.

The grey cylinder in that image represents a body which has no shape. That cylinder is constrained to the robot body and can only rotate around the cylinder axis. It has a PhysicsConstraintMotorType.VELOCITY motor causing it to rotate around the cylinder axis.

Then, each of the legs has a BallAndSocketConstraint attaching it to the cylinder, so the legs will move in a circle as the cylinder rotates.

Finally, to keep the legs at the right orientation, there’s a constraint between each leg and the body of the robot, locking all three angular axes to make sure the legs have the same orientation as the robot body.
