Anyone here using PhysX to simulate cars?

Started by
8 comments, last by bzroom 16 years ago
I am having a bit of trouble getting my car movement to work correctly. When I use getAxleSpeed() and try to limit the speed of the car this has no effect as the car continues to accelerate. I am using the engine torque to accelerate the car. Should I switch to using setAxleSpeed() and NX_WF_AXLE_SPEED_OVERRIDE? What bonuses do I loose by using the setAxleSpeed()? Thanks
Advertisement
post some code of what you're trying to do.
void PlayerMoveForward(void){	if(physx->GetRPM(WHEEL_REAR_RIGHT) > MAX_SPEED || physx->GetRPM(WHEEL_REAR_LEFT) > MAX_SPEED)		physx->gCurrentMotorTorque = 0;	else	{		if(gUseSpeedBoost)			physx->gCurrentMotorTorque +=(TORQUE_VALUE + speedBoost);		else			physx->gCurrentMotorTorque +=TORQUE_VALUE;	}	physx->gCurrentBrakeTorque = 0;	physx->bSetCurrentMotorTorque = true;	physx->bSetCurrentBrakeTorque = true;}int PhysX::GetRPM(unsigned int wheel){	return int(wheels[wheel]->getAxleSpeed());}


Edited Source to show working version

Update, what I have found is, if I use the setAxleSpeed() I can limit the RPM as GetRPM() shows the limit I set it to. So I can only assume that I can do this without using setAxleSpeed(), but I have no clue why the built in simulation will not allow me to limit the axle speed so the car doesn't accelerate past my limit...

[Edited by - MARS_999 on April 3, 2008 8:24:58 PM]
I've only just started looking at the wheelShape (finally given up with the rigid/d6Joint combo, as it just didn't like edges, much;))...

Sounds like you're applying torque in a vacuum! There's nothing "fighting back", so your car goes on accelerating forever?

From my tests, the simplest way to stop acceleration is simply
wheel->setMotorTorque (0.0f);
Of course, that's essentially engaging the clutch, or neutral gear. So you really want to get some aero/drag on the go I guess?!
Jezham thanks for the reply, I can stop the car with and slow it down and works fine. But when I accelerate the car to say 500 for torque and it hits the max at 500 the GetRPM just keeps on climbing. So as of now I am not sure why this is, or if its a bug. If I use setAxleSpeed() I can limit the speed but I will need to control the acceleration myself to make it behave correctly. I would rather use the built in simulation but as of now I don't see that happening unless someone can point out what is wrong, or if I am missing a flag or function call.
your torque should fall off as rpm reach their limit. thats how a real engine "works." If it didn't, it would climb to infinity and explode.

You need to introduce the concept of a revlimiter. Where the RPM'S are calculated from the wheels speed, rev limited, then the torque is calculated from the RPM and applied to the wheel.

So basically, when you reach top speed, set torque to zero..
bzroom you are right, I just didn't think about how real this would have to be to get it to work... So basically the power curve vs. RPM is a inverse of each other as one gains the other should loose value. Now there should be some function that you can use to calculate this based of simple mathematical equation. So you can tailor it for various car motors...

Thanks
I usually just fake it with simple interpolation. Usually around 6 torque samples will give you decent results. Then, some hard limit at the top.
bzroom have you tried to make your car spinout or when you turn left or right fast enough? If so how are you accomplishing this?

Thanks BTW++

and thanks Jezham ++ also
calculate the energy at the contact patch. combat the energy with great force until the energy level passes a threshold. then combat the energy with significantly less force until it drops below another threshold.

these are commonly refered to as static and kinetic friction ;)

vehicle tuning is not an easy task, i'm just warning you.

This topic is closed to new replies.

Advertisement