[solved] Car engine force

gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

[solved] Car engine force

Post by gjaegy »

Hi everybody,

I am currently trying to create a little arcade car game using Bullet vehicle.

First of all, I have a problem positioning the car. Just before the race starts, I would like the car to be on the road, immobile. However, if I set the original position to be on the ground, the wheels are actually colliding with the ground (because of the expanded suspensions), which means the car directly jump as soon as I enable the physic simulation. Bullet sample solve that by having the car being "in the air" at the beginning, which would look realistic in my case. I could also position it just above the road, but in that case the suspension will compress and it wouldn't be realistic as well. Any idea how I could solve that ?

The second problem I have to face is to apply the right torque according to the current gear and rpm. Has anybody done some work on that subject ?

Thanks,
Greg
Last edited by gjaegy on Wed Jun 04, 2008 3:43 pm, edited 2 times in total.
chunky
Posts: 145
Joined: Tue Oct 30, 2007 9:23 pm

Re: Initial car positioning / Car engine force

Post by chunky »

You could cheese it by dropping the car onto the road and running the simulation for a brief while ahead of time, before actually starting rendering. You could probably also empirically drop a car onto the road, see what height it settles at, and in future just spawn the car at exactly that height above the road?

There's probably better ways of doing it, but really if dropping the car from a height above the road is feasible for your game, that's probably easiest and fastest, and least hakky.

Gary (-;
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Initial car positioning / Car engine force

Post by gjaegy »

thanks for your reply. this is what I tried first, however, I don't know why, the car doesn't bounce symetrically, i.e. I don't get it at the exact same location X/Z after the simulation has been run a few times, as when it is in the air.

It also gets some velocity after the bounce, move forward, which is not very handy..
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Initial car positioning / Car engine force

Post by gjaegy »

OK I manage to have the car in the right initial position, putting it a little bit above the road and running the simulation a few time.

Concerning the second question, I guess I will need to use a graph that describes the engine power according to the RPM.

I am not sure what kind of input do I need to provide applyEngineForce() with. Is that the engine torque ?

See below the piece of pseudo-code:

Code: Select all

float throttle = Inputs.PositiveYAxis();

float EngineTorque = Engine.GetTorque(Engine.GetRPM()) * throttle;

float GearTorque = EngineTorque * Gear.GetCurrentRatio();

float DriveTorque = GearTorque * DriveTrain.GetFinalRatio();


float TyreAngularVelocity = Car.GetForwardVelocity() / Tyre.Radius();

float EngineRPM = TyreAngularVelocity * DriveTrain.GetFinalRatio() * Gear.GetCurrentRatio();

Engine.SetRPM(EngineRPM);
I am not sure what applyEngineForce() needs as input. Is that simply GearTorque ? A torque is in Nm wheres a force is in N. Hmmm, I am a bit lost, I think I lost my memory...
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Car engine force

Post by gjaegy »

I manage to solve this problem too. If anyone is interested in the code I use (lua code) i can post it here.

Thanks !
mcan
Posts: 15
Joined: Tue Feb 03, 2009 10:04 am

Re: [solved] Car engine force

Post by mcan »

I'm very interested about the code!

It's almost a year since your post, have you managed to find out more about what the input is? torque?