Game Development Community

Using handbrake with AIWheeledVehicle

by Tim Hutcheson · in Torque Game Engine · 10/14/2005 (1:10 pm) · 3 replies

Can anyone explain how to apply the handbrake to bring an AIWheeledVehicle to a stop? When I explored the handbrake as used by the keyboard space bar, I notice that it seems to require that the w or s key needs to be applied at the same time. Pressing the space bar while a vehicle is coasting, for example, has no effect. So in drilling down into the C++ code, I'm getting lost trying to find the relationships so that I can setup the state and triggers, etc, so that the brake can be applied with AI. Anyone help?

#1
10/14/2005 (3:27 pm)
Tim,

movePtr holds information for steering, gas, and brakes

bool AIWheeledVehicle::getAIMove(Move *movePtr)
{
...
movePtr->y = 0.0; //Don't apply throttle
movePtr->trigger[2] = true; //Apply hand brake
}

Hope this helps,

Brian
#2
10/14/2005 (3:33 pm)
Brian, yeh, I know. But....


Actually trying those simple things doesn't seem to get the job done. In fact it's counterintuitive. The only time the handbrake works in the keyboard mode is when the throttle is applied. You have to have the w-key depressed and be tooling along for the space-bar to actuate the handbrake! So I'm trying to figure out if it's a MoveState related kind of thing. Just setting trigger[2] by itself didn't seem to work for me.
#3
10/14/2005 (3:38 pm)
Tim,

try setting a breakpoint in the WheeledVehicle::updateForces(F32 dt) function. You might have a wrong setting for one of the variables related
to braking.