Cannon raycast vehicle not moving

G’day All!

I’ve been trying to setup a raycast vehicle with a gltf model attached to it and I cannot for the life of me figure out how to get it to move correctly.

It was working fine when I tested it out with plane old cubes and cylinders, but when I added the gltf model it stopped moving. I’ve tried changing the quaternions about but that just causes it to fly off in all directions.

Here is a quick playground I setup replicating the problem

If anyone can lend me a hand and let me know where I’m going wrong it would be much appreciated.

Hello and welcome
pinging @trevordev to help :slight_smile:

If your scene works with primitives, then I assume this is a transform issue. I don’t know what application you are exporting from, but perhaps it has a different up axis on export. Or perhaps your working in left handed space vs. right handed space. This is where I would start.


I’m exporting from blender with y axis as up, so the model is in left hand space.

I’ve been experimenting with it some more and found that it moves when directionLocal in the wheel options is set to a negative number, only problem is it throws off height field collisions and follow camera.

Another interesting clue I found is the suspension does not move when colliding with the ground after falling from the start position when the directionLocal is a positive number

@Mr_K in the playground you shared it looks like there is an error in the loaded callback as seen in the console due to new meshes not containing the body transform node. It can be worked around with . If you have an example working with a primitive can you link that? If it works for a primitive can’t you use that, make it invisible and make the gltf a child of the primitive you use?

Parenting the gltf model to the primitives appears to have done the trick. Thanks for the suggestion @trevordev

Hi Trevor! I’ve been trying for a day to implement the raycast vehicle from cannon.js but no luck.

Do you kow why does your playgrond doesn’t work anymore?

Adding @Cedric to check if he sees smthg obvious ?

Nop, nothing obvious. I’ve found a PG with cannong vehicle. maybe it can help :

Adding @RaananW as well cause I think he implemented one at some point ?

The demo pasted by @Cedric was created by me around 3 years ago and still works :slight_smile:

The cannon’s raycast vehicle’s class cannot work with our architecture, as we abstract the physics engine completely and do not expose the objects as expected. If you want, you can always create your own impostor-to-mesh implementation and use cannon’s implementation. This is more than possible and should work well

1 Like