Vehicle Physics

This line of code is throwing an error

this.carChassis = localCreateRigidBody(100, tr, compound);

“localCreateRigidBody is not defined”

I am looking through the code but have yet to notice a bug.

BTW, awesome job so far! I honestly think solving this problem could be very beneficial to the community.

Okay fixed that error, it should have been
this.carChassis = this.localCreateRigidBody(100, tr, compound);
Now for the next error!

Ok nice! maybe we can work on this on the same project?
EDIT: Also this is the next error this.body.setContactProcessingThreshold(1000000.0);

Hey check it out


launched game

The script is running but the wheels aren’t showing?

Yeah I’m stuck with this one, it appears the wheels are rendering but their positions are all wrong and they don’t have collisions applied.

The graphical position of the wheels confuses me on line 414 as I had to scale up the local position for each wheel which makes no sense to me. But it works :thinking:

Edit: Ported the camera and also fixed up the materials so they look the same as the original project.

So I loaded in my own model, but the wheels of the model are rotating on the wrong axis it seems. They are flipping over themselves instead of spinning like a normal wheel. I am using the code above posted by yaustar.

Any ideas?

You are going to have to look over the vehicle code as there quite a few things that were specific to that model that was originally used.

Can you point me in the right direction? I was messing around with this code to no success.

this.pos.set(p.x(), p.y(), p.z());
this.quat.set(q.x(), q.y(), q.z(), q.w());

You can change the orientation of your vehicle in a 3D tool like blender

I changed the orientation from y-axis up to z-axis up to no difference.

Figured it out! Thanks for help all

Let us know if there is something to test…

i’m also having the same problem with the orientation of the wheels. how did you solve that?

1 Like

@isabelaimufo Try looking in the project here this shows all the code and how it works im thinking of putting comments down showing which spots of code do what towards the vehicle so it can be used in other projects

I correct myself the project has been compromised and not healthy to use as an example im not sure what my partner has done to the code for the vehicle but i will fix it asap.

Hey Nathan, I checked your code, is it me or the car is not slowing down after releasing the race button? Even though friction has been set in the code.

At your vehicle.js line number 71, the debug has been set to true, so it is showing the generated colliders by the ammo physics engine. You can turn it off by making it 0.

I know i was told so and i put a reminder in your post. There is still alot of problems with the script that can still be fixxed i will let you know what i find and edit so you can use it