OP
User
Joined: Feb 2010
Posts: 886
|
Hy again. I have a little problem with my car... I looked for a long time for the reason, why the car is not driving. There are no warnings, errors or other stuff. The problem I am having is that the car just not react when I press W,S,A or D. Could somebody please tell me were the problem is? Code; var constr_front_left; var constr_front_right;
var constr_back_left; var constr_back_right;
VECTOR mom_speed; var max_angle; var stear_contr;
var max_speed = 1500; var ang_force; var speed_contr;
function mass() { pXent_setmass(my,60); pXent_setfriction (my, 100); pXent_setdamping (my, 20, 20); pXent_setelasticity (my,20); }
action warthdog() { pXent_settype(my,PH_RIGID,PH_CONVEX); pXent_setmass (my, 15);
pXent_setfriction (my, 20); pXent_setdamping (my, 5, 5); pXent_setelasticity (my, 10);
ENTITY* constr_front_left = ent_create("tire.mdl",vector(my.x+75,my.y-45,my.z-10),mass); ENTITY* constr_front_right = ent_create("tire.mdl",vector(my.x+75,my.y+45,my.z-10),mass); ENTITY* constr_back_left = ent_create("tire.mdl",vector(my.x-70,my.y-45,my.z-10),mass); ENTITY* constr_back_right = ent_create("tire.mdl",vector(my.x-70,my.y+45,my.z-10),mass); pXcon_add ( PH_WHEEL, constr_front_left, my, 0 ); pXcon_add ( PH_WHEEL, constr_front_right, my, 0 ); pXcon_add ( PH_WHEEL, constr_back_left, my, 0 ); pXcon_add ( PH_WHEEL, constr_back_right, my, 0 ); while(1) { stear_contr = (key_d - key_a); max_angle += stear_contr * 3 * time_step; max_angle = clamp (max_angle, -30, 30); if (stear_contr != 0) { pXcon_setparams2 (constr_front_left, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0)); pXcon_setparams2 (constr_front_right, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0)); } else { max_angle = max_angle * (1 - (0.25 * time_step)); if (abs(max_angle) < 1) max_angle = 0; pXcon_setparams2 (constr_front_left, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0)); pXcon_setparams2 (constr_front_right, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0)); } speed_contr = (key_w - key_s); ang_force = speed_contr * 1000 * time_step;
pXcon_setmotor(constr_back_left, vector(-ang_force, max_speed, 0), nullvector); pXcon_setmotor(constr_back_right, vector(-ang_force, max_speed, 0), nullvector); wait(1); } } } Thank you future more.
Last edited by Random; 12/11/11 23:37.
|