car.c how to add a trailer or wagon?

Posted By: Ice2642

car.c how to add a trailer or wagon? - 07/01/22 13:35

Hello,

Has anyone there already added a wagon or trailer in the car.c template for him to drag with physics and wheels?
Or know how do this?

Like the image.

[Linked Image]

https://ibb.co/JvSMr7H

I Appreciate any help.

Thank you in advance.
Posted By: VoroneTZ

Re: car.c how to add a trailer or wagon? - 02/16/23 10:10

I check this with "pXcon_setwheel" example from gamestudio manual, works fine


Code
//create trailer at 370 quants behind the player
ENTITY* car2 = ent_create("truck.mdl",vector(player.x-370,player.y,player.z),NULL);

 // add 2 wheels at 43 quants from center of trailer
ENTITY* tBLwheel = ent_create("buggy_rad1.mdl",vector(car2.x,car2.y+43,car2.z+13),NULL); 
ENTITY* tBRwheel = ent_create("buggy_rad1.mdl",vector(car2.x,car2.y-43,car2.z+13),NULL); 

 //add physx to trailer
pXent_settype(car2,PH_RIGID,PH_BOX);

 //connect trailer to player
pXcon_add ( PH_BALL, player, car2, 1 );

//connect wheels to trailer
pXcon_add ( PH_WHEEL, tBLwheel, car2, 0 ); 
pXcon_add ( PH_WHEEL, tBRwheel, car2, 0 );
Posted By: oncalabo

Re: car.c how to add a trailer or wagon? - 04/24/23 01:53

All things in their being are good for something.Thanks.
virtual phone system service
Posted By: Ice2642

Re: car.c how to add a trailer or wagon? - 05/05/23 18:45

Originally Posted by VoroneTZ
I check this with "pXcon_setwheel" example from gamestudio manual, works fine


Code
//create trailer at 370 quants behind the player
ENTITY* car2 = ent_create("truck.mdl",vector(player.x-370,player.y,player.z),NULL);

 // add 2 wheels at 43 quants from center of trailer
ENTITY* tBLwheel = ent_create("buggy_rad1.mdl",vector(car2.x,car2.y+43,car2.z+13),NULL); 
ENTITY* tBRwheel = ent_create("buggy_rad1.mdl",vector(car2.x,car2.y-43,car2.z+13),NULL); 

 //add physx to trailer
pXent_settype(car2,PH_RIGID,PH_BOX);

 //connect trailer to player
pXcon_add ( PH_BALL, player, car2, 1 );

//connect wheels to trailer
pXcon_add ( PH_WHEEL, tBLwheel, car2, 0 ); 
pXcon_add ( PH_WHEEL, tBRwheel, car2, 0 );


Thank you, I will try laugh

Best Regards,
© 2024 lite-C Forums