Game Development Community

Steering in Flying Vehicles

by William Todd Scott · in Torque Game Engine · 04/19/2006 (12:20 pm) · 5 replies

Hey all,

In the updateForces() method of the FlyingVehicle class a snippet of the steering code looks like this:

steering.y = mSteering.y / mDataBlock->maxSteeringAngle;
steering.y *= mFabs(steering.y);


Can someone explain why the second line is necessary?


Thanks
Todd

#1
04/19/2006 (1:03 pm)
Looks to me like the idea was to square the value, without loosing the sign. That would reduce the influence of small steering inputs. One is still one, zero is still zero, but 0.4 becomes 0.16, -0.3 becomes -0.09, etc. Perhaps the idea was to prevent the steering from being too twitchy? That would be my guess.
#2
04/19/2006 (6:53 pm)
Yeah,

The interesting thing is that this doesn't seem to be in the code for non-flying vehicles.

Additionally, expanding the code snipped with one more line:

steering.y = mSteering.y / mDataBlock->maxSteeringAngle;
steering.y *= mFabs(steering.y);
torque += xv * steering.y * mDataBlock->steeringForce;

The maxSteeringAngle already scales the values. However, this is a linear scaling vs. the exponential dampening that you pointed out.

Thanks for your help. I don't like to assume what's going on too much when picking apart these physics simulations.

Todd
#3
04/19/2006 (9:47 pm)
Also, note that in Vehicle::updateMove mSteering values are clamped to a range of (-)maxSteeringAngle to (+)maxSteeringAngle. So what we have here is steering.y in a range of -1 to 1. This then represents our steering input as a percentage, which is then multiplied by the vehicle's steeringForce. When the input reaches or exceeds maxSteeringAngle, full steering force should be applied.

The end result being that maxSteeringAngle determines how far one has to move the controller (mouse?) in order to reach the vehicle's maximum turning rate; while steeringForce determines what the turning rate is at maximum steering input.

Or at least that's what I've determined by reading the code. I've done no empirical research to back it up though.
#4
04/20/2006 (10:26 am)
Scott,

Thanks for posting that...I misread how the maxSteeringAngle was working on my first pass through the code.

Todd
#5
04/24/2006 (9:34 pm)
Man, that steering angle stuff makes alot more sense now. I was literally just about to rip it out of my SpaceVehicle.