# Havok car experiment

**URL:** <https://forum.babylonjs.com/t/havok-car-experiment/51561>\
**Category:** Demos and projects\
**Tags:** physics, havok\
**Created:** [June 24, 2024, 2:53pm UTC](https://forum.babylonjs.com/t/havok-car-experiment/51561 "2024-06-24T14:53:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Post date:** [June 24, 2024, 2:53pm UTC](https://forum.babylonjs.com/t/havok-car-experiment/51561/1 "2024-06-24T14:53:26Z")

</div>

Hey folks!

I am starting a small car controller experiment with Havok based on this discussion [Are motorized constraints still being introduced? - #10 by Octo8080X](https://forum.babylonjs.com/t/are-motorized-constraints-still-being-introduced/49617/10)

I am not sure how far I want to take this, but there you go:

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

(controls are WASD or ZQSD)

Known limitations include not being able to turn while moving forward, but you have to start somewhere! 😂

---

<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:** [June 24, 2024, 3:27pm UTC](https://forum.babylonjs.com/t/havok-car-experiment/51561/2 "2024-06-24T15:27:23Z")

</div>

This is a great start! Can’t wait to see your progress here 🙂

---

<div class="post-metadata">

**Author:** ![Spaceman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/spaceman/32/42848_2.png) [@Spaceman](https://forum.babylonjs.com/u/Spaceman)\
**Post date:** [September 27, 2024, 7:13pm UTC](https://forum.babylonjs.com/t/havok-car-experiment/51561/3 "2024-09-27T19:13:25Z")

</div>

The vehicle always spawns at the center of the world. How can I change that? No matter what I try, either the position I specify is not adopted or overwritten by the physics, or the vehicle flies chaotically through the world after starting.

I didn’t think that setting the start position would be such a difficult. 😅

---

<div class="post-metadata">

**Author:** ![Spaceman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/spaceman/32/42848_2.png) [@Spaceman](https://forum.babylonjs.com/u/Spaceman)\
**Post date:** [September 29, 2024, 10:45pm UTC](https://forum.babylonjs.com/t/havok-car-experiment/51561/4 "2024-09-29T22:45:03Z")

</div>

I can change the new start position of the vehicle using chassis.position and adjust the position of the tires relative to the chassis. But when chassisAggregate.body.addConstraint(wheelAggregate.body, motor) is executed, the chassis object jumps to the center of the world, while the tires remain at the new start position.

I have been trying to understand and solve the problem for hours. But I just don’t understand anything. This behavior makes no sense to me. I have tried a lot of things but it just won’t work. Can’t anyone help me? 😞

I’m really shocked at how something as trivial as an arbitrary starting point has become a challenge. Either something is wrong or I’m really stupid.

---

<div class="post-metadata">

**Author:** ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Post date:** [September 30, 2024, 8:16am UTC](https://forum.babylonjs.com/t/havok-car-experiment/51561/5 "2024-09-30T08:16:31Z")

</div>

Good point it shouldn’t be that difficult! The issue is that designed each element independently and now if I move the chassis, the rest of the car does not with it move which create issues.

I think this car works better overhaul, you will probably have a better time with it:

> [@Simple Vehicle Wheel Physics](https://forum.babylonjs.com/t/simple-vehicle-wheel-physics/53569/):
>
> Hi all, I am very new to all this but ran out of resources to find a solution for my issue (including all the AI bots out there). I am trying to build a simple wheel + vehicle mechanic and control. Movement is simply forward/backward/left/right. I am able to steer the wheel left (testing with left only, will replicate a working solution to steer right), and i am able to return the wheel to its previous original position with the key to steer left is no longer pressed, but both the steer AND re…

It is really not your fault, this car is very much a prototype and I didn’t have the time to make more than the bare minimum work 😕

---

<div class="post-metadata">

**Author:** ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Post date:** [September 30, 2024, 8:19am UTC](https://forum.babylonjs.com/t/havok-car-experiment/51561/6 "2024-09-30T08:19:28Z")

</div>

Another great car controller that works much better than this one:

> [@PhysicsV2 Car Simulation Template](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/):
>
> Hi All, I’ve created a car simulation example with Havok/PhysicsV2 that I think would be a great starting point for anyone interested! It implements: Motorised joints for powered wheels and steering Stiffness and damping (spring) 6DoF joints for suspension Effective use of mass and friction This means it might also be helpful for anyone struggling with those aspects of PhysicsV2. [PhysicsV2 Car Simulation Example | Babylon.js Playground (babylonjs-playground.com)](https://www.babylonjs-playground.com/#ANV5OM) Hope it helps! TR

---

<div class="post-metadata">

**Author:** ![qv1](https://avatars.discourse-cdn.com/v4/letter/q/7cd45c/32.png) [@qv1](https://forum.babylonjs.com/u/qv1)\
**Post date:** [October 1, 2024, 12:35pm UTC](https://forum.babylonjs.com/t/havok-car-experiment/51561/7 "2024-10-01T12:35:48Z")

</div>

This is amazing! thank you for sharing!

---

<div class="post-metadata">

**Author:** ![Spaceman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/spaceman/32/42848_2.png) [@Spaceman](https://forum.babylonjs.com/u/Spaceman)\
**Post date:** [October 2, 2024, 12:30am UTC](https://forum.babylonjs.com/t/havok-car-experiment/51561/8 "2024-10-02T00:30:52Z")

</div>

Thanks. I have now found the solution to my problem. You just have to add the following code:

```auto
backLeftWheel.parent = chassis;
backRightWheel.parent = chassis;
frontLeftWheel.parent = chassis;
frontRightWheel.parent = chassis;

```
