Car Physics

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
goldsword
Posts: 18
Joined: Fri Dec 05, 2008 8:46 pm

Car Physics

Post 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?
User avatar
Zukarakox
Not a Site Admin
Posts: 426
Joined: Mon Jul 10, 2006 4:28 am

Re: Car Physics

Post 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?
i has multiple toes
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Car Physics

Post 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.
goldsword
Posts: 18
Joined: Fri Dec 05, 2008 8:46 pm

Re: Car Physics

Post by goldsword »

So I have to create an EventHook delegate to listen for collision against the car body I presume?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Car Physics

Post 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.
goldsword
Posts: 18
Joined: Fri Dec 05, 2008 8:46 pm

Re: Car Physics

Post by goldsword »

yes thats what I was looking for thank you
Post Reply