# Floating origin with Havok

**URL:** <https://forum.babylonjs.com/t/floating-origin-with-havok/40130>\
**Category:** Questions\
**Tags:** physics\
**Created:** [April 23, 2023, 4:42pm UTC](https://forum.babylonjs.com/t/floating-origin-with-havok/40130 "2023-04-23T16:42:58Z")\
**Posts on this page:** 7\
**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:** [April 23, 2023, 4:42pm UTC](https://forum.babylonjs.com/t/floating-origin-with-havok/40130/1 "2023-04-23T16:42:58Z")

</div>

Hey everyone, I’m trying to get Havok to work when I keep the camera at the origin of the scene like here: [Playground](https://playground.babylonjs.com/#Z8HTUN#56) (use WASD or ZQSD to move around)

I think the disablePreStep thingy is making the sphere miss a few physics update when I move the scene around. The sphere seems to jitter a bit and sometimes goes through the ground. Is there another way to move everything at once that would be havok friendly?

---

<div class="post-metadata">

**Author:** ![jeremy-coleman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jeremy-coleman/32/15493_2.png) [@jeremy-coleman](https://forum.babylonjs.com/u/jeremy-coleman)\
**Post date:** [April 23, 2023, 6:36pm UTC](https://forum.babylonjs.com/t/floating-origin-with-havok/40130/2 "2023-04-23T18:36:12Z")

</div>

Havok does continuous collision detection , the unity docs have a good write up on the concept. [Unity - Manual: Continuous collision detection (CCD)](https://docs.unity3d.com/Manual/ContinuousCollisionDetection.html) . I suggest also looking at the typescript definitions of the havok wasm module inside node\_modules (it actually has no dependency on or reference to anything babylon related). It’ll quickly help translate some abstract concepts, such as a joint just being a constraint variant.

---

<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 24, 2023, 9:49am UTC](https://forum.babylonjs.com/t/floating-origin-with-havok/40130/3 "2023-04-24T09:49:31Z")

</div>

It is really impressive that Havok can manage CCD while being so fast. I looked in the ts definitions of the wasm module, I will try `HP_Body_SetQTransform` and report if I am successful or not!

---

<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 25, 2023, 12:55pm UTC](https://forum.babylonjs.com/t/floating-origin-with-havok/40130/4 "2023-04-25T12:55:18Z")

</div>

Alright I modified the playground quite a bit and reused some findings from ["moveWithCollisions" with havoc? - #13 by Raggar](https://forum.babylonjs.com/t/movewithcollisions-with-havoc/40118/13)

It works a lot better but there is still a small issue: [Playground](https://playground.babylonjs.com/#Z8HTUN#104)  
I’m adding gravity in the linear velocity of the box and it makes it jitter for some reason.

For comparison when using Havok gravity: [Playground](https://playground.babylonjs.com/#Z8HTUN#105) the box behaves as expected.

Is there something about the way havok computes its own gravity, I guessed it would just be added to the linear velocity but it seems to be different 🤔

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [April 25, 2023, 2:13pm UTC](https://forum.babylonjs.com/t/floating-origin-with-havok/40130/5 "2023-04-25T14:13:31Z")

</div>

Gravity is an acceleration so it has to be multiplied by time no? @Cedric

---

<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 25, 2023, 2:21pm UTC](https://forum.babylonjs.com/t/floating-origin-with-havok/40130/6 "2023-04-25T14:21:28Z")

</div>

That would make sense indeed.  
I tried it but the results are a bit underwhelming: [Playground](https://playground.babylonjs.com/#Z8HTUN#106). And dividing the deltaTime by 1000 causes the box to not fall at all…

I think one possible issue is that setting the linear velocity might override other forces havok adds to the body. But it does not explain why it works here: [Playground](https://playground.babylonjs.com/#Z8HTUN%23100)

---

<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:** [May 2, 2023, 9:13am UTC](https://forum.babylonjs.com/t/floating-origin-with-havok/40130/7 "2023-05-02T09:13:20Z")

</div>

Yes, so acceleration \* deltaTime give the velocity.
