pXcon_setmotor (void* constraint_ID, VECTOR* SteerAngle, VECTOR* MotorTorque, VECTOR* undefined ); |
This turns a static joint into a motorized one. For wheels the motor tries to rotate the entities with a given angular velocity. In order to reach the velocity specified by the user a certain amount of force or torque is required. Therefore the maximum amount of force/torque available also needs to be specified. If this value is very low objects might not start moving at all.
Parameters: |
constraint_id |
entity or unique identifier of the constraint to be configured |
SteerAngle |
X = rotate the Wheel for steering. Y = limit rotation Z = not used yet |
MotorTorque |
X = addTorque, Y = maximumTorque, Z = brakeTorque |
undefined |
not used yet - set to nullvector |
Returns: |
1 if successful, 0 otherwise.
Speed: |
Fast
... ENTITY* wheel; phcon_semotor(wheel, vector(steering,90,0), vector(direction*torque, MaxTorque, 0), nullvector);} ... function car_test() { ENTITY* car = ent_create("car.mdl",vector(100,-200,40),NULL); 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); FRwheel.pan=BRwheel.pan=180; pXent_settype(car,1,PH_CONVEX); pXcon_add ( PH_WHEEL, car, FLwheel, 0 ); pXcon_add ( PH_WHEEL, car, FRwheel, 0 ); pXcon_add ( PH_WHEEL, car, BLwheel, 0 ); pXcon_add ( PH_WHEEL, car, BRwheel, 0 ); pXent_movelocal(car,1,nullvector,vector(90,0,0)); pXent_movelocal(car,2,nullvector,vector(90,0,0)); pXent_movelocal(car,3,nullvector,vector(90,0,0)); pXent_movelocal(car,4,nullvector,vector(90,0,0)); //pXent_moveglobal(car,car.x,vector(car.pan+90,car.tilt,car.roll)); pXent_setmassoffset(car, vector(0,0,-20)); pXent_setmass(car,400); while(1) { pXcon_setmotor (FLwheel, vector(-1,-20,0), nullvector, nullvector ); pXcon_setmotor (FRwheel, vector(-1,-20,0), nullvector, nullvector ); pXcon_setmotor (BLwheel, nullvector, vector(-50,1200,0), nullvector ); pXcon_setmotor (BRwheel, nullvector, vector(50,1200,0), nullvector ); wait(1); } }