# Missing Havok Features

**URL:** <https://forum.babylonjs.com/t/missing-havok-features/47021>\
**Category:** Questions\
**Created:** [January 6, 2024, 11:50pm UTC](https://forum.babylonjs.com/t/missing-havok-features/47021 "2024-01-06T23:50:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [January 6, 2024, 11:50pm UTC](https://forum.babylonjs.com/t/missing-havok-features/47021/1 "2024-01-06T23:50:18Z")

</div>

Yo @Cedric or any other Havok Gurus out there.

I am trying to make the big switch from Ammo.JS to Havok for the Babylon Unity Exporter.

I got most things working but really need some help with a few things.

First and foremost… Terrain Heightfield… In Ammo.js i was directly setting the heights using a Float32Array of heights

```auto
        public static CreateHeightfieldTerrainShapeFromMesh(terrainMesh:BABYLON.Mesh, terrainWidth:number, terrainDepth:number, terrainMinHeight:number, terrainMaxHeight:number, terrainWidthExtents:number, terrainDepthExtents:number, flipQuadEdges:boolean = false):any {
            // This parameter is not really used, since we are using PHY_FLOAT height data type and hence it is ignored
            const heightScale = 1;

            // Up axis = 0 for X, 1 for Y, 2 for Z. Normally 1 = Y is used.
            const upAxis = 1;

            // hdt, height data type. "PHY_FLOAT" is used. Possible values are "PHY_FLOAT", "PHY_UCHAR", "PHY_SHORT"
            const hdt = "PHY_FLOAT";

            // Create heightfield physics shape
            const heightData:FloatArray = terrainMesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);

            // Creates height data buffer in Ammo heap
            (<any>terrainMesh).ammoHeightData = Ammo._malloc(4 * terrainWidth * terrainDepth);

            let height = 0, p2 = 0;
            for (let i = 0; i < heightData.length / 3; i++) {
                height = heightData[i * 3 + 1]; // Note: Get The Y Component Only
                // ..
                // FIXME: Maybe Minus The Mesh Position Y To Offset Not A Zero Origin - ???
                // ..
                Ammo.HEAPF32[(<any>terrainMesh).ammoHeightData + p2 >> 2] = height;
                // 4 bytes/float
                p2 += 4;
            }

            // Creates the heightfield physics shape
            const heightFieldShape:any = new Ammo.btHeightfieldTerrainShape(
                terrainWidth,
                terrainDepth,
                (<any>terrainMesh).ammoHeightData,
                heightScale,
                terrainMinHeight,
                terrainMaxHeight,
                upAxis,
                hdt,
                flipQuadEdges
            );

            // Set horizontal scale
            const scaleX:number = terrainWidthExtents / (terrainWidth - 1);
            const scaleZ:number = terrainDepthExtents / (terrainDepth - 1);
            heightFieldShape.setLocalScaling( new Ammo.btVector3(scaleX, 1, scaleZ));
            heightFieldShape.setMargin(BABYLON.SceneManager.DefaultHeightFieldMargin);
            return heightFieldShape;
        }

```

How do i use the raw Havok API to create a terrain heightfield shape ??? (@3th maybe you can help here)

Second… How do I lock an axis from movement… In ammo i would use **setLinearFactor** and **setAngularFactor** … so for rotation i can use setAngularFactor(0,1,0) to lock a capsule upright to it would not tip over… you can only rotate around the Y axis

Third… In Ammo… I was using **btKinematicCharacterController** as well as **btRaycastVehicle** with wheel collider support… Is there a character controller and raycast wheeled vehicle support in havok…

It seems a bit strange that we **upgraded** to a more commercial physics but is does not seem to readily expose some of the basic physics engine stuff we had before in Ammo.

- Kinematic Character Controllers
- Raycast Wheel Vehicle Support
- Terrain Height Field Shapes

These are MAJOR issues for me and my Babylon Toolkit.

Any light you guys can shed on these matter would be sweeeeeeet… Thank you so much 🙂

@Pryme8 … Andy what you think ???

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [January 7, 2024, 1:35am UTC](https://forum.babylonjs.com/t/missing-havok-features/47021/2 "2024-01-07T01:35:43Z")

</div>

I have not done much work with Havok yet and seem to struggle to find documentation on it whenever I google for it.

There is this:

> <https://github.com/sigmaco/havok-2013/blob/master/Physics2012/Collide/Shape/HeightField/hkpHeightFieldShape.h>

Not sure how much help for you that is though.

I would assume you just need to make the terrain and then do something like this:

```auto
const aggregate = new BABYLON.PhysicsAggregate(terrain, BABYLON.PhysicsShapeType.HEIGHTFIELD, { mass: 0, friction: 0.5, restitution: 0.5 }, scene);

```

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [January 7, 2024, 10:27am UTC](https://forum.babylonjs.com/t/missing-havok-features/47021/3 "2024-01-07T10:27:42Z")

</div>

I got terrain height map collision working for my export terrain meshes. Not using a heightmap image, instead I create the Float32Array of heights directly from the terrain mesh exported from unity. No precision loss because of encoding the heights to 8 bit image.

But i still need to get a alternative for Ammo.js **setLinearFactor** and **setAngularFactor**

And how to handle **Kinematic Character Controllers** and **Raycast Wheeled Vehicles**

---

<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:** [January 8, 2024, 10:00am UTC](https://forum.babylonjs.com/t/missing-havok-features/47021/4 "2024-01-08T10:00:38Z")

</div>

I’m back from the break 🙂  
Here is current state of Havok physics for your concern:

Heightmap terrain shape is in progress. It should be merged by End of Feb, just before 7.0 code freeze

you can do axis lock this way : [setAngularFactor for Havok - #3 by Takemura](https://forum.babylonjs.com/t/setangularfactor-for-havok/41954/3)

No ETA for **Kinematic Character Controllers** and **Raycast Wheeled Vehicles** yet. It’s something we want to do for quite some time and as usual, prioritizes change.

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [January 8, 2024, 11:27am UTC](https://forum.babylonjs.com/t/missing-havok-features/47021/5 "2024-01-08T11:27:23Z")

</div>

> [@Cedric](#):
>
> you can do axis lock this way : [setAngularFactor for Havok - #3 by Takemura](https://forum.babylonjs.com/t/setangularfactor-for-havok/41954/3)

What about setLinearFactor ?

---

<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:** [January 11, 2024, 4:48pm UTC](https://forum.babylonjs.com/t/missing-havok-features/47021/6 "2024-01-11T16:48:09Z")

</div>

@carolhmj Do you remember something related to setlinearfactor in Havok API?

---

<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:** [January 11, 2024, 5:59pm UTC](https://forum.babylonjs.com/t/missing-havok-features/47021/7 "2024-01-11T17:59:35Z")

</div>

There is SetLinearDamping and SetLinearVelocity, but no SetLinearFactor 🤔

---

<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:** [January 12, 2024, 2:12pm UTC](https://forum.babylonjs.com/t/missing-havok-features/47021/8 "2024-01-12T14:12:41Z")

</div>

with a damping of 1, it’s like setting a factor of 0, I guess.

EDIT: nope.

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [January 12, 2024, 8:49pm UTC](https://forum.babylonjs.com/t/missing-havok-features/47021/9 "2024-01-12T20:49:24Z")

</div>

Yeah i tried that too… Its really to damping over time… Not like the multiply factor of SetLinearFactor … Luckily the mas properties inertia is multiplay against angular velocity so give me a way to freeze the rotation axis of the physics body as if havok had a setAngularFactor…

But i still need to come up with a way to freeze the linear velocity as well

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [May 20, 2024, 10:57pm UTC](https://forum.babylonjs.com/t/missing-havok-features/47021/10 "2024-05-20T22:57:09Z")

</div>

Yo @Cedric and @carolhmj … Any idea when we are gonna expose vehicle classes for Havok Physics?

---

<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 21, 2024, 12:38pm UTC](https://forum.babylonjs.com/t/missing-havok-features/47021/11 "2024-05-21T12:38:23Z")

</div>

Hi @MackeyK24  
Sorry, no ETA yet. We are working on planning ATM. Maybe I’ll have more to share 🙂
