Thanks @RaananW!
I’ve found your demo in some old topic
I think I can get some inspiration from that code.
Thanks @RaananW!
I’ve found your demo in some old topic
I think I can get some inspiration from that code.
That’s what I call “travel the world”
This must be 6 years old!
@RaananW I would be thankful if you could take a look at my code.
As I told before I’m trying to marry this example
with BabylonJS.
So at first I’m creating the meshes:
and later I’m creating the bodies for the physical engine
And at the end I’m setting the positions of the wheels but it doesn’t work.
The whole PR is just here
I had “working babylon vehicle” with usage of mesh.parent
but I can’t get it working with physics engine.
Gosh, I feel like I should take some “basic gamedev course”.
pulling this PR will be enough to run the project?
Yes, it works locally.
@RaananW I can try creating PG. I think it should work with cannon, it’s pretty basic stuff.
Here is the PG:
that seems to be causing a fight between babylon’s physics loop and the cannon changes, no? You are using babylon’s phyiscs impostors on the wheels, and then update them in the postStep again. Do you need the physics impostors? or better - do you need the physics engine plugin in this case?
You know, I’m really like
Removing the physics impostors on the wheels doesn’t seem to change anything.
Maybe there is something wrong with this postStep
function. I copied it from cannon-es example.
If I use only BabylonJS Physics, and I have box as parent with wheels it doesn’t work because mesh children impostors don’t work - so I guess I need the physics engine plugin.
The story of my life!
This kind of hybrid solution would require a lot of playing around with the babylon cannon plugin and special configuration to the impostors.
You want to avoid transforming your meshes twice. either the babylon physics engine is doing it (as in my example), or youa re doing it manually (and then you don’t need enabling the babylon physics engine. I will be happy to find time and show you a simple example of this way of working, but i won’t make it today, that’s for sure…
No problem! I’m also done for today. Thank you for your help - it really opens new doors in my head
So when you wrote about the physics engine plugin
you meant the Babylon impostors?
If so - I think I won’t need it. I want to build simple car racing game with heightmaps so I will need Cannon plugin - it should do all the work.
Hey, I followed your instructions and I removed Babylon impostors and at the moment I’ve got something like this:
Don’t know what a heck is going on with the wheels but I’m heading somewhere definitely
EDIT:
Ok, so the
chassisBody.angularVelocity.set(0, 0.5, 0);
was the reason of the rotating wheels. So I’ve got
@RaananW do you think it looks ok?
If so I’ll try to add driving code to it.
It does look ok! There were a few issues with the data conversion, but this should work now - cannon simple vehicle | Babylon.js Playground (babylonjs.com)
(I switched the camera’s position). There seems to be an issue with the force application. This might be the version of cannon we are using over the version of cannon this was developed for. It is possible that cannon-es has fixed a but (or added params), that are not supported in the old cannon implementation. that’s probably why steering is not working as you expect.
Thanks @RaananW, I’m on that too atm.
But it doesn’t go forward / backward it goes to the sides…
Did I messed up something while building the vehicle for the physics engine?
No, i really believe this is a difference between cannon and cannon-es.
In my demo I fixed it by changing the axis for every wheel and applied difference force on both wheels. I can’t seem to find the line that does it, but it seems like the force is applied incorrectly.
Okey, so I opened the demo you shared
and I’m just clicking WSAD and I see
Sorry, I meant - the demo I have created 6 years ago. You can see how I solve it there, to fix the cannon architecture
I’ve changed the camera, and that the force is not applied now to the steering wheels
It does look like the wheels are working against each other?
It’s really hard for me to find the solution because I don’t understand what is going on here. Do you know why it’s not working if the wheels are spinning in the same direction?
Hello again, @RaananW
So I started porting this cannon-es-debugger
(which is working with ThreeJS only) to make this work with the BabylonJS to check if I can figure out how to build raycastVehicle with cannon-es and BabylonJS.
It looks like I’m almost there:
(driving the vehicle is WSAD, and toggling the debugger is c
)
https://neu5.github.io/cannon-es-debugger-babylonjs/
rotationQuaternion
but with no luck.repo:
The code of the example is here:
I’d be glad if anyone could look at this