Page 1 of 1

Car Physics

Posted: Tue Dec 09, 2008 7:29 pm
by goldsword
Just got the hang on the Vehicle / Wheel classes, they work great! I managed to create a car using 4 wheels working perfectly in all regards, I then hooked up the car into my projectile collision system and started to apply various hit effects but here I ran into trouble.
When I detect a hit against a wheel I will after some damage remove the wheel from the car, this will cause the car to behave like I would imagine in all aspects except when it comes to angular velocity. When the wheel is blown off the car under gravitational influences will push that corner of the car down into the ground causing frictional forces from the car chassi to apply, slowing the car down, increasing the dynamic friction value will indeed make the car go slower and slower when more wheels are blown off. However the car will not start to yaw when say 1 tire from the left side is blown off I want to car to start to pull to the left but the car will still head straight ahead, why is this? I have tried to increase the inverse inertia tensor around the Y axis to make the car spin around easier, and I have confirmed this works by shooting the car causing it to spin around Y more if I increase the values. I figured the physic system would give me this behaviour automatic but maybe I need to find a workaround?

Re: Car Physics

Posted: Tue Dec 09, 2008 9:40 pm
by Zukarakox
Well, Im guessing that a car with only 3 wheels would still manage to go straight, until it run into ridiculously large amounts of 'friction' because of the 4th corner actually jamming INTO the ground, not just encountering friction like in the simulation.

I havn't looked into the vehicle class, but you could either apply GIANT amounts of friction onto the body or detecting when a wheel is blown off and causing any hits to the actual car body to have a backwards impulse. Both solutions wouldnt be very great, but would cause the effect you're looking for.

Maybe you could just add an automatic veer to the vehicle controls whenever a wheel is blown off?

Re: Car Physics

Posted: Tue Dec 09, 2008 11:28 pm
by Norbo
I'd recommend the last option. For these sorts of very fine tuned behaviors, its usually best to implement them explicitly so you have more control over it. An arbitrary extra friction force, perhaps based on the velocity of the car and if the car is on the ground or not (wouldn't want the force spinning you around while you're in the air), would work. Toolbox.getVelocityOfPoint can be used to find the velocity at a world-coordinates point as if it were connected to a given entity.

Re: Car Physics

Posted: Wed Dec 10, 2008 7:50 am
by goldsword
So I have to create an EventHook delegate to listen for collision against the car body I presume?

Re: Car Physics

Posted: Wed Dec 10, 2008 1:14 pm
by Norbo
I would probably use the Wheel.hasSupport/Vehicle.hasWheelSupport/Vehicle.supportedWheelCount to determine if the vehicle is on the ground if that's what your goal is. After deciding it is grounded (and whatever other conditions you'd like, such as velocity), you can apply the 'bad steering' impulse.

Re: Car Physics

Posted: Fri Dec 12, 2008 8:23 pm
by goldsword
yes thats what I was looking for thank you