Simple Car Demo 1.
This is a simple car with six hinges (4 for the wheels,2 for the steer). No suspension. The model is the half-life 2 buggy (it seems quite 'rigid', like this car is). The archive includes two map: 1) a flat box with a ramp and some crates. 2) a bsp terrain. Note that I haven't optimized anything. Consider also that this a starting point to modify the source and avoid all the calls out the physics script. now there are 3 useless pawns required to track the wheels rotation. In the terrain level you will see the "fall through the floor bug". It's an annoying bug caused by the slowness of genesis that causes a missing collision for tokamak. Probably when all the issues about extra pawns are fixed this doesn't happen anymore. Use 'J' to make car fly over the bad collision zone.
For the dust effect I used the standard RF smoke, but it has to be optimized (when the car flies, it hasn't to do any smoke naturally) but i don't know how to tell to the script that the car is flying. Maybe a sensor but I don't know how to make it work yet. Also here there are external script calls for a SetEventState to activate the spout trigger, that has to be eliminated. In my old Realityracer I used another trick, attaching a weapon that leaves a skidding decal on the ground. I think that can be made also for this car (implementing the appropriate firing script command). There are some bug in this rf release so please exit and start again the app if you want to reset the scene. If you go in the option / video menu you can enable stencil shadows for the car chassis (slowing down together...). You can break the wheels joints using '6' and re-glue them using '7' (thanks to the Nout special effects!) probably in the future will be implemented the SetBreakCriteria command (read the Nout's docs).
Installation
Simply download RF073withPhysics7Jan2006.zip from http://realityfactory.altervista.org/download/ then patch the workfolder with the simple_car1.zip archive that you found here: http://realitychess.altervista.org/physics/
Controls
Left / Right Mouse Buttons: Accelerate / Decelerate
Left / Right arrow keys : turn left - right
J : Jump
SPACE : handbrake (buggy)
'8': change camera (follow / backward / lateral)
'6-7': break - glue wheel joints
Quick Hack Tutorial
In the Init order (executed once) of the scripts/car/rigid_car1.p script you will find the car creation commands. Body[0] is the chassis. it calls for an existing pawn ('CHASSIS'). you can modify the mass of the car (Mass parameter). Modify also the mass of ExtendRigidBody object that you find under Body[0]. These are the extended geometries of the car chassis.
The wheels are Body[1] / Body[2] (rear wheels) and Body[5] / Body[6] (front wheels). You can change the mass as above and the dimension of the wheel. The first triplet after the .act extension filename is the XYZ scale of the actor.
Body[3] and Body[4] are invisible geometries that are the fulcrum of the steer. you can affect the car steer changing the variable declaration MAX_STEAR_ANGLE [33] (in degrees).
You can change the friction of the wheels changing the 2nd parameter in the DefineMaterial(1, 6, 0.5); command. Now is 6, a high value, but remember that the wheel bounding geometry is a sphere. The third parameter is the Restitution. You can also change the world friction and restitution in the PhysicsSystem entity in the level using the world editor (3dt included).
In the Start order (executed every frame) you can uncomment
to have a 4wd car, and after, eventually, comment the above two lines to have a rear-driven car.//SetTorque(Body[1], X_FINAL_TORQUE, 0, Z_FINAL_TORQUE, true); //uncomment for 4wd
//SetTorque(Body[2], X_FINAL_TORQUE, 0, Z_FINAL_TORQUE, true);
Changing the TORQUE_REAR value in this if/else block, you will change the engine force:
I hope that this can help you. And I hope that we can finally have a stable RF with physics in the near future thanks to a new Tokamak release. Please give an enormous credit to Nout for the Physics Development. It has really changed the RF face! Many thanks, master.if(((self.leftmousekey_pressed=true)and((self.key_pressed=46)=false)and((self.key_pressed=33)=false))and(((self.key_pressed=58)=true)or((self.key_pressed=58)=false))and(((self.key_pressed=57)=true)or((self.key_pressed=57)=false)))
{
TORQUE_REAR=260;
X_FINAL_TORQUE = TORQUE_REAR*(B_PERC/100);
Z_FINAL_TORQUE = TORQUE_REAR*(A_PERC/100);
}
else
{
X_FINAL_TORQUE = -TORQUE_REAR*(B_PERC/100);
Z_FINAL_TORQUE = -TORQUE_REAR*(A_PERC/100);
if(((self.rightmousekey_pressed)and((self.key_pressed=46)=false)and((self.key_pressed=33)=false))and(((self.key_pressed=58)=true)or((self.key_pressed=58)=false))and(((self.key_pressed=57)=true)or((self.key_pressed=57)=false)))
{
TORQUE_REAR=260;
}
else
{
TORQUE_REAR=TORQUE_REAR*0.4;
if(TORQUE_REAR<2)
{
TORQUE_REAR=1;
}
}
}
Screens.