Make car stick to ground

Posted By: PadMalcom

Make car stick to ground - 08/15/13 09:02

Hi, I've implemented a simple car physic using the example from the manual:

Code:
function simple_car(){
  ENTITY* car = ent_create("car.mdl",vector(100,-200,40),NULL); 
  pXent_settype(car,PH_RIGID,PH_BOX);
  ENTITY* FLwheel = ent_create("wheel.mdl",vector(168,-170,17),NULL);
  ENTITY* FRwheel = ent_create("wheel.mdl",vector(168,-230,17),NULL);
  ENTITY* BLwheel = ent_create("wheel.mdl",vector(39,-170,17),NULL);
  ENTITY* BRwheel = ent_create("wheel.mdl",vector(39,-230,17),NULL);
  pXcon_add ( PH_WHEEL, FLwheel, car, 0 );
  pXcon_add ( PH_WHEEL, FRwheel, car, 0 );
  pXcon_add ( PH_WHEEL, BLwheel, car, 0 );
  pXcon_add ( PH_WHEEL, BRwheel, car, 0 );//drive the car          while(1)  {
    pXcon_setwheel (FLwheel,-5,0,0);
    pXcon_setwheel (FRwheel,-5,0,0); // steer to the right
    pXcon_setwheel (BLwheel,0,500,0);    pXcon_setwheel (BRwheel,0,500,0);
    wait(1);  }}



My problem is, that the car does not stick to the ground and "falls" on the side quite often so that I can't continue driving. Any ideas how to avoid that?
Posted By: muffel

Re: Make car stick to ground - 08/15/13 09:23

For the problem of falling on the side you can try to lower the center of mass and you can also try to mess around with the interia via pXent_setmassoffset (ENTITY* entity , VECTOR* vOffset, VECTOR* vInertia).
With the "does not stick to ground"- problem I think you mean that the wheels dont touch the ground, thats probably due to the fact that PhysX does not update the wheel position as stated in the manual.
Quote:
PhysX does not return the position and angles of the wheel, thus leaving its calculation from the car orientation, suspension parameters, contact points, and axle speed as an excercise to the reader. Unfortunately, the axle speed returned by PhysX is wrong - it does not take wheel slip into account. It is not possible to calculate the 'real' axle speed from the wheel parameters, thus some approximations and educated guesses must be used.
Posted By: PadMalcom

Re: Make car stick to ground - 08/16/13 07:30

Thanks muffel, I'll try that!
© 2024 lite-C Forums