|
5 registered members (vince, Quad, clint000, TipmyPip, 1 invisible),
28,434
guests, and 4
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Car racing - Physics
[Re: HeelX]
#382575
09/09/11 15:20
09/09/11 15:20
|
Joined: Mar 2005
Posts: 514 Brazil
Carloos
OP
User
|
OP
User
Joined: Mar 2005
Posts: 514
Brazil
|
Yeah, It doesnt looks realistic. And also, it doesnt have much grip.
I made a mistake in the track modelling. I tryed to make the center of the track a little higher then the part closer to the grass.
This is making the physics react strange. When the car goes into the turns, and even in the straight part, It changes direction a lot.
Only for fun, I will model another track, completely flat from side to side, to see what happens.
I Think the next step will be what Ventilator said : c-lite for the movement, physics for the collisions.
If I could manage the speed, turns and skkiding with Lite-c and, the PhysX for the collisions, I would get something nice.
I have a nice car behaviour wrote in c-script that I can port to c-lite easily.
My dount is : I know that we cant c_move a physics active object. Apart of this, I think... when the car collide with something, or another car... what could happen ? How to manage it ? Any ideas ?
Questions, too much questions.
|
|
|
Re: Car racing - Physics
[Re: Carloos]
#383123
09/16/11 02:33
09/16/11 02:33
|
Joined: Mar 2005
Posts: 514 Brazil
Carloos
OP
User
|
OP
User
Joined: Mar 2005
Posts: 514
Brazil
|
This is being very difficult to understand / implement.
I´m using this code I found somewhere in the forums, and changed a few things to my convenience, but nothing that could break its functionallity :
______________________________________________________________
function simple_car() { vecGravity.x = 0; vecGravity.y = 0; vecGravity.z = -9.81; pX_setgravity (vecGravity); ENTITY* car = ent_create("F3.mdl",vector(6700,25500,5),NULL); pXent_settype(car,PH_RIGID,PH_CONVEX); pXent_setmass(car,1); car.material = mtl_envmirror; car.shadow = ON; pXent_setmassoffset(car,vector(NULL,NULL,-3),vector(1,0.1,1)); //moves the center of mass 10 quants down. ENTITY* BLwheel = ent_create("tyre.mdl",vector(car.x - 60,car.y - 20,car.z + 8 ),mass); ENTITY* BRwheel = ent_create("tyre.mdl",vector(car.x - 60,car.y + 20,car.z + 8),mass); ENTITY* FLwheel = ent_create("tyre.mdl",vector(car.x + 46 ,car.y - 25,car.z + 8),mass); ENTITY* FRwheel = ent_create("tyre.mdl",vector(car.x + 46,car.y + 25,car.z + 8),mass); 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 ); pXcon_setparams2(BRwheel, NULL,vecBRwheel, vecBRwheel2); pXcon_setparams2(BLwheel, NULL,vecBLwheel, vecBLwheel2); pXcon_setparams2(FRwheel, NULL,vecFRwheel, vecFRwheel2); pXcon_setparams2(FLwheel, NULL,vecFLwheel, vecFLwheel2);
while(1) {
if(key_a) { speed += (1 * time_step); } else { if ( speed > 0 { speed -= (1 * time_step); } }
if(key_z) { speed -= (1 * time_step); }
if(key_n) { tyreAngle -= ( 2 * time_step) ; } else { if (tyreAngle < 0) { tyreAngle += ( 1 * time_step) ; } }
if(key_m) { tyreAngle +=( 2 * time_step); } else { if (tyreAngle > 0) { tyreAngle -= ( 1 * time_step) ; } }
pXcon_setwheel (FLwheel,tyreAngle,0,0); pXcon_setwheel (FRwheel,tyreAngle,0,0); // steer to the right //pXcon_setwheel (BLwheel,0,speed,0); //pXcon_setwheel (BRwheel,0,speed,0); var max_speed = 300; var ang_force = speed * 100;
//pXcon_setmotor(car,vector(-ang_force, max_speed, 0), nullvector); //pXcon_setmotor(car,vector(-ang_force, max_speed, 0), nullvector);
pXent_addvelcentral(car,vector(((speed) * time_step),0,0)); pXent_addvelcentral(car,vector(0,0,-10)); pXent_addvelcentral(FLwheel,vector(0,0,-50)); pXent_addvelcentral(FRwheel,vector(0,0,-50)); pXent_addvelcentral(BLwheel,vector((speed),0,0)); pXent_addvelcentral(BRwheel,vector((speed),0,0));
var temp[1]; var camTilt; var camPan; var cam_dist=0; var CamFromWheel = 10; var CamFromGround = 5; var x_cam;
camera.arc = 72; camera.clip_near = 0; camera.clip_far = 100000; camTilt = car.tilt ; camPan = car.pan - 180 ; cam_dist = clamp(0,CamFromWheel,20); camera.x = ((((car.x))+ cos(camPan)*(cam_dist*cos(camTilt)))) + x_cam ; camera.y = ((car.y + sin(camPan)*((cam_dist*cos(camTilt))))); camera.z = car.z + 20 ; vec_set(temp,car.x); vec_sub(temp,camera.x); vec_to_angle(camera.pan,temp); camera.tilt = -3; wait(1); } }
______________________________________________________________
but... an interesting thing is happening :
When the car is pointint to positive x vector, and I´m pressing the "a" key, it accelerates ok. then I turn 180 degrees in the track, and the orientation of the car is the opposite.
Then the car slows very fast, and it start to go in reverse !
It´s very disappointing, I know I´m very nooby in the PhisX thing, maybe also in coding, but this is so... weird...
Ipm really interested in learning and maybe applying what Ventilator said, but, if I can´t even manage to understand well this code above...
Well, any help or tips will be HIGHLY appreciated.
Cya
|
|
|
Re: Car racing - Physics
[Re: Carloos]
#383137
09/16/11 10:21
09/16/11 10:21
|
Joined: Aug 2009
Posts: 1,438 Spain
painkiller
Serious User
|
Serious User
Joined: Aug 2009
Posts: 1,438
Spain
|
take a look at my PhysX car script in Aum 101
3D Gamestudio A8 Pro AMD FX 8350 4.00 Ghz 16GB RAM Gigabyte GeForce GTX 960 4GB
|
|
|
|