Game Development Reference
In-Depth Information
{
float NewSpeed = Speed - SpeedDelta;
m_MainBody.GetObjectPhysics().SetMaxSpeed(NewSpeed);
}
}
}
The TurnTurret() function turns the tank's turret based on the TurnDelta input parameter.
(See Listing 8-60.)
Listing 8-60. Turning the Tank's Turret
void TurnTurret(float TurnDelta)
{
Vector3 Axis = new Vector3(0,1,0);
m_Turret.m_Orientation.SetRotationAxis(Axis);
m_Turret.m_Orientation.AddRotation(TurnDelta);
}
The ProcessTurret() function turns the tank's turret left or right, depending on the steering input
value for the turret. (See Listing 8-61.)
Listing 8-61. Processing the Tank's Turret Steering
void ProcessTurret()
{
Steering TurretSteering = m_Driver.GetTurretSteering();
HorizontalSteeringValues HorizontalTurn = TurretSteering.GetHorizontalSteering();
float TurnDelta = TurretSteering.GetTurnDelta();
// Process Right/Left Turn
if (HorizontalTurn == HorizontalSteeringValues.Left)
{
TurnTurret(TurnDelta);
}
else if (HorizontalTurn == HorizontalSteeringValues.Right)
{
TurnTurret(-TurnDelta);
}
}
The UpdateVehicle() function (see Listing 8-62) updates the Tank class object. The function does
the following:
1.
If the main tank body is visible, it updates the tank's driver object, processes
the tank's steering, and processes the tank's turret movements.
Updates the tank's physics by calling UpdateObject3dToHeading() , using the
forward vector of the tank's main body in world coordinates as the heading.
2.
 
Search WWH ::




Custom Search