# PhysicsV2 Car Simulation Template

**URL:** <https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801>\
**Category:** Tutorials and tips\
**Tags:** physics, examples, havok\
**Created:** [September 27, 2024, 1:02pm UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801 "2024-09-27T13:02:44Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tr909](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tr909/32/44497_2.png) [@Tr909](https://forum.babylonjs.com/u/Tr909)\
**Post date:** [September 27, 2024, 1:02pm UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/1 "2024-09-27T13:02:44Z")

</div>

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:** ![regna](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/regna/32/23915_2.png) [@regna](https://forum.babylonjs.com/u/regna)\
**Post date:** [September 27, 2024, 3:50pm UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/2 "2024-09-27T15:50:31Z")

</div>

Awesome, thank you for sharing 😄

---

<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:36pm UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/3 "2024-10-01T12:36:38Z")

</div>

This is absolutely amazing, thank you so much for sharing, I have been working on something like this for a while and couldn’t get it to work.

---

<div class="post-metadata">

**Author:** ![Tr909](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tr909/32/44497_2.png) [@Tr909](https://forum.babylonjs.com/u/Tr909)\
**Post date:** [October 6, 2024, 3:40am UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/4 "2024-10-06T03:40:43Z")

</div>

Thanks for the positive feedback! Here’s what it can look like with a nice car model dropped in and some dramatic lighting -

[Driving Simulation with Babylon.js / Havok Physics (youtube.com)](https://www.youtube.com/watch?v=C2DxRH5qP4Y)

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 15, 2025, 6:39am UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/6 "2025-04-15T06:39:56Z")

</div>

Spiral race track - [https://www.babylonjs-playground.com/#ANV5OM#123](https://www.babylonjs-playground.com/#ANV5OM#123)

---

<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:** [April 15, 2025, 7:02am UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/7 "2025-04-15T07:02:09Z")

</div>

the guardrail is a nice touch 😆 I would keep falling without it

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 15, 2025, 11:03pm UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/8 "2025-04-15T23:03:06Z")

</div>

Circular race track - [https://www.babylonjs-playground.com/#ANV5OM#139](https://www.babylonjs-playground.com/#ANV5OM#139)  
With speed meter and time counter.  
The next step is to add some obstacles 🙂

---

<div class="post-metadata">

**Author:** ![ARAMONIS\_5](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aramonis_5/32/31509_2.png) [@ARAMONIS\_5](https://forum.babylonjs.com/u/ARAMONIS_5)\
**Post date:** [April 16, 2025, 10:40am UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/9 "2025-04-16T10:40:06Z")

</div>

Really useful thing

---

<div class="post-metadata">

**Author:** ![Tr909](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tr909/32/44497_2.png) [@Tr909](https://forum.babylonjs.com/u/Tr909)\
**Post date:** [April 18, 2025, 9:02am UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/10 "2025-04-18T09:02:03Z")

</div>

You’ve inspired me to tweak the physics to be a bit more fun and fast [PhysicsV2 Car Simulation Example | Babylon.js Playground](https://www.babylonjs-playground.com/#ANV5OM#143)

Makes your track a lot more difficult though!

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 18, 2025, 11:19pm UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/11 "2025-04-18T23:19:02Z")

</div>

> [@Tr909](#):
>
> Makes your track a lot more difficult though!

Yes, now it has more sporty riding style 🙂

---

<div class="post-metadata">

**Author:** ![Tom\_Haddon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tom_haddon/32/2189_2.png) [@Tom\_Haddon](https://forum.babylonjs.com/u/Tom_Haddon)\
**Post date:** [May 18, 2025, 1:57pm UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/12 "2025-05-18T13:57:39Z")

</div>

If I wanted to change the initial position of the car, how would I do that? I’ve tried adding `carFrame.position.x = carFrame.position.x + 1;` as the last line of `CreateCar()` but that doesn’t seem to have any effect.

I’d like to try this out on some external models, which is why I’m looking to update the initial position.

---

<div class="post-metadata">

**Author:** ![Tom\_Haddon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tom_haddon/32/2189_2.png) [@Tom\_Haddon](https://forum.babylonjs.com/u/Tom_Haddon)\
**Post date:** [May 20, 2025, 7:06am UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/13 "2025-05-20T07:06:38Z")

</div>

I’ve been able to make this work by doing the following:

```auto
const initialPosition = new BABYLON.Vector3(0, 2, 0);
carFrame.position = new BABYLON.Vector3(0 + initialPosition.x, 0.3 + initialPosition.y, 0 + initialPosition.z);

```

And then the same for all the wheels and axles. I’ll try this out on an external model, but will then also look into how to set the initial rotation.

---

<div class="post-metadata">

**Author:** ![Tr909](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tr909/32/44497_2.png) [@Tr909](https://forum.babylonjs.com/u/Tr909)\
**Post date:** [May 20, 2025, 10:49am UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/14 "2025-05-20T10:49:50Z")

</div>

Hello, you have to set the disablePreStep property to false on each physics body before changing the cars position. Here is an updated playground with this implemented [PhysicsV2 Car Simulation Example | Babylon.js Playground](https://www.babylonjs-playground.com/#ANV5OM#161)

Pressing “r” triggers the Reset() function which moves the car back to the start of the track.

---

<div class="post-metadata">

**Author:** ![manuelhintermayr](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/manuelhintermayr/32/45775_2.png) [@manuelhintermayr](https://forum.babylonjs.com/u/manuelhintermayr)\
**Post date:** [October 12, 2025, 1:49pm UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/15 "2025-10-12T13:49:34Z")

</div>

I really love it. Thank you very much for sharing! How did you solve the lighting to work so smooth in your youtube video and also reflect on the floor? I tried to do a based on your code and the physics works smooth even with a custom model, but I cannot get the lights working so smooth or else my FPS drop really low: [https://projects.manuelhintermayr.com/babylon-js-car-example](https://projects.manuelhintermayr.com/babylon-js-car-example) (and here the code behind it [babylon-js-car-example/game/babylon-game.js at main · manuelhintermayr/babylon-js-car-example](https://github.com/manuelhintermayr/babylon-js-car-example/blob/main/game/babylon-game.js)). Again, great work, thanky for sharing.

---

<div class="post-metadata">

**Author:** ![Tr909](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tr909/32/44497_2.png) [@Tr909](https://forum.babylonjs.com/u/Tr909)\
**Post date:** [October 13, 2025, 9:02am UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/16 "2025-10-13T09:02:15Z")

</div>

Your game is looking great so far - feels a lot more fun than the original playground for sure! I ran it with the headlights and tail lights enabled but it ran totally smoothly on my computer so it’s hard to pin point any problems.

In theory these should help though:

- Swap the pointlights for spotlights (setting the angle to 120 or less ideally)
- Removing shadow generators from the tail lights (you would probably barely see the shadows these generate anyway)
- Reducing shadow generator texture size

Hopefully that can get it running better on your machine!

---

<div class="post-metadata">

**Author:** ![manuelhintermayr](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/manuelhintermayr/32/45775_2.png) [@manuelhintermayr](https://forum.babylonjs.com/u/manuelhintermayr)\
**Post date:** [October 14, 2025, 6:38pm UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/17 "2025-10-14T18:38:18Z")

</div>

Thank you for the input, i love now it works with the lights and very smooth

 ![wut](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/2/e241e57fc1b633c8aa86f8e4b3d00f8fc22f6a35.jpeg)

 ![wut2](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/d/bd04cb1d24083df74ca6e6cc0d7a14f09b94b944.jpeg)

Only the lights seem to have no effect at all at the car (light reflections/lightning, just like in your video), only all the other objects, but i think after that, it is a really cool playground example (updated code is in the github repo)

---

<div class="post-metadata">

**Author:** ![Tr909](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tr909/32/44497_2.png) [@Tr909](https://forum.babylonjs.com/u/Tr909)\
**Post date:** [October 15, 2025, 9:26am UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/18 "2025-10-15T09:26:58Z")

</div>

See my fork for reflections and glow layer 🙂

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [October 15, 2025, 10:27am UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/19 "2025-10-15T10:27:41Z")

</div>

You may make some parts of the car more reflective, especially glass parts, and, for example, apply clearcoat to the metal parts.

---

<div class="post-metadata">

**Author:** ![manuelhintermayr](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/manuelhintermayr/32/45775_2.png) [@manuelhintermayr](https://forum.babylonjs.com/u/manuelhintermayr)\
**Post date:** [October 18, 2025, 11:16am UTC](https://forum.babylonjs.com/t/physicsv2-car-simulation-template/53801/20 "2025-10-18T11:16:31Z")

</div>

Love it  
 ![preview](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/6/d6e93a0b43d0df4f2f6178460b9c245d18bc6f77.gif)

Thanks, I included the solution in the main repo for everyone else to see in action 🙂
