Vehicle not driving forward
Posted: Sat Sep 29, 2012 1:03 pm
Hi everyone,
I have a problem with the Vehicles in BepuPhysics. I'm using the Vehicle class from the demos but my vehicle is only driving backwards and not forward.
This is the code for taking input and applying it to the car. ForwardSpeed is 30 and BackwardSpeed -13.
The rest of the code including the steering is directly taken from the VehicleDemo code. Is there anything wrong with this code?
I have a problem with the Vehicles in BepuPhysics. I'm using the Vehicle class from the demos but my vehicle is only driving backwards and not forward.
This is the code for taking input and applying it to the car. ForwardSpeed is 30 and BackwardSpeed -13.
Code: Select all
if (keyboardInput.IsKeyDown(MOIS.KeyCode.KC_UP))
{
//Drive
//Vehicle.Wheels[1].DrivingMotor.MaximumForwardForce = 100000;
//Vehicle.Wheels[3].DrivingMotor.MaximumForwardForce = 100000;
Vehicle.Wheels[1].DrivingMotor.TargetSpeed = ForwardSpeed;
Vehicle.Wheels[3].DrivingMotor.TargetSpeed = ForwardSpeed;
}
if (keyboardInput.IsKeyDown(MOIS.KeyCode.KC_DOWN))
{
//Reverse
//Vehicle.Wheels[1].DrivingMotor.MaximumBackwardForce = 100000;
//Vehicle.Wheels[3].DrivingMotor.MaximumBackwardForce = 100000;
Vehicle.Wheels[1].DrivingMotor.TargetSpeed = BackwardSpeed;
Vehicle.Wheels[3].DrivingMotor.TargetSpeed = BackwardSpeed;
}
else
{
//Idle
Vehicle.Wheels[1].DrivingMotor.TargetSpeed = 0;
Vehicle.Wheels[3].DrivingMotor.TargetSpeed = 0;
}
if (keyboardInput.IsKeyDown(MOIS.KeyCode.KC_SPACE))
{
//Brake
foreach (Wheel wheel in Vehicle.Wheels)
{
wheel.Brake.IsBraking = true;
}
}
else
{
//Release brake
foreach (Wheel wheel in Vehicle.Wheels)
{
wheel.Brake.IsBraking = false;
}
}