racer home

Tutorial - Faking motorbikes


Home Next to cars you can do a bit of motorbiking in Racer.

Dolphinity Organiser - free planning, project management and organizing software for all your action lists


Racer (since v0.5.3 beta 2.0) can do a bit of motorbike simulation. Note that this is more of a quirk than a really usable thing, but it's fun anyway. A bit of knowledge about car.ini files is highly recommended. Here's the idea:

Below is an image produced during development, using a cone for a swingarm. ;-) The model is a Ducati, found on the web and created by Matt/Prometheus (it needs work on separating the wheels at least; but this was just a test).

2 Wheels instead of 4

First thing is get a car.ini file from an existing car. Racer is not very good at vehicles with only 2 wheels, so we're going to use 4 wheels and fake where they are painted. Wheels close to the centerline get very jumpy, so moving susp<x>.x to 0 (or near 0) doesn't work well either. A benefit of leaving the wheel locations where they are is that the motor will stay upright magically, since it's actually driving on 4 invisible wheels.

We'll use wheel0 and wheel 2 (the 2 left wheels, see the car.ini reference) and hide the other 2. Set wheel1.model.file to an empty string, as well as wheel3.mode.file (do not comment them out, since they're defined in data/cars/default/car.ini as well). This hides the right wheels (but it will still drive).

To move the wheel models near the body center, offset the models. Here's an example for wheel0:

    ; susp0.x=0.75; undo this so the model is directly in center
    ; of the body model

Do the same for wheel2 and the wheels should now both be in the center (ofcourse the value 0.75 here is dependent on the car in question).

Motorbike lean

When driving the model around, you'll notice that the body will move inverted to what you'd expect from a motorbike; it's leaning outwards when going through a turn (like a car). To reverse this, raise the rollcenters above the CG. An example would be to set susp<x>.roll_center.y to something like 0.5 (depending on where the CG is). Test whether this feels ok. The higher the roll center, the more lean (too much will tip over the bike though).

Adding a swingarm

Racer v053b20+ has the capacity to add generic models next to the known fixed models (wheels/brakes/lights etc). The models are normalized in the sense that they should be exactly 1 meter high (and starting at the origin, the model located on the negative Y side). This enables the simulator to scale the object so it fits between 2 points. More information on generic models is presented in this tutorial. See the following extract from a development car.ini file:

  ; Generic models
from=0 0.3 0
; Bring to centerline
from_offset=-0.75 0 0
; Bring to centerline
to_offset=-0.75 0 0

Notice the use of the from & to properties of the model. This makes a link between a fixed location (0 0.3 0) relative to the nullpoint of the chassis to a moving point (wheelpos0). Scaling and orientation is automatically handled by the graphics engine. In the above example, you could combine from & from_offset to -0.75 0.3 0. As the bikes wheels are handled by the physics engine as being 0.75 meters away from the centerline, the graphics offsets are used to make the swingarm actually appear on the centerline. Remember that susp0.x was 0.75, so from_offset/to_offset correct this to end up at X=0.


All this doesn't bring you a full bike simulator, far from it alas. Notable missing things are:


Dolphinity Organiser - free planning, project management and organizing software for all your action lists

(last updated November 13, 2012 )