tank steering
This commit is contained in:
+2
-1
@@ -248,6 +248,7 @@ void GameWorld::Initialize()
|
|||||||
physics->Static = false;
|
physics->Static = false;
|
||||||
auto vehicle = AddComponent<Components::Vehicle>(tank, "Vehicle");
|
auto vehicle = AddComponent<Components::Vehicle>(tank, "Vehicle");
|
||||||
vehicle->MaxTorque = 5200.f;
|
vehicle->MaxTorque = 5200.f;
|
||||||
|
vehicle->MaxSteeringAngle = 90.f;
|
||||||
AddComponent<Components::TankSteering>(tank, "TankSteering");
|
AddComponent<Components::TankSteering>(tank, "TankSteering");
|
||||||
AddComponent<Components::Input>(tank, "Input");
|
AddComponent<Components::Input>(tank, "Input");
|
||||||
|
|
||||||
@@ -445,7 +446,7 @@ void GameWorld::Initialize()
|
|||||||
Wheel->AxleID = 0;
|
Wheel->AxleID = 0;
|
||||||
Wheel->Mass = 2000;
|
Wheel->Mass = 2000;
|
||||||
Wheel->Radius = 0.6f;
|
Wheel->Radius = 0.6f;
|
||||||
Wheel->Steering = false;
|
Wheel->Steering = true;
|
||||||
Wheel->SuspensionStrength = suspensionStrength;
|
Wheel->SuspensionStrength = suspensionStrength;
|
||||||
Wheel->Friction = 4.f;
|
Wheel->Friction = 4.f;
|
||||||
Wheel->ConnectedToHandbrake = true;
|
Wheel->ConnectedToHandbrake = true;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void VehicleSetup::buildVehicle(World *world, const hkpWorld* physicsWorld, hkpV
|
|||||||
//
|
//
|
||||||
vehicle.m_data = new hkpVehicleData;
|
vehicle.m_data = new hkpVehicleData;
|
||||||
vehicle.m_driverInput = new hkpVehicleDefaultAnalogDriverInput;
|
vehicle.m_driverInput = new hkpVehicleDefaultAnalogDriverInput;
|
||||||
vehicle.m_steering = new hkpVehicleDefaultSteering;
|
vehicle.m_steering = new TankSteering;
|
||||||
vehicle.m_engine = new hkpVehicleDefaultEngine;
|
vehicle.m_engine = new hkpVehicleDefaultEngine;
|
||||||
vehicle.m_transmission = new hkpVehicleDefaultTransmission;
|
vehicle.m_transmission = new hkpVehicleDefaultTransmission;
|
||||||
vehicle.m_brake = new hkpVehicleDefaultBrake;
|
vehicle.m_brake = new hkpVehicleDefaultBrake;
|
||||||
|
|||||||
@@ -33,6 +33,32 @@
|
|||||||
#include "Components/Wheel.h"
|
#include "Components/Wheel.h"
|
||||||
#include "Components/Transform.h"
|
#include "Components/Transform.h"
|
||||||
|
|
||||||
|
|
||||||
|
/// Tank specific steering implementation. Rear wheels steer in opposite direction
|
||||||
|
/// to front wheels.
|
||||||
|
class TankSteering: public hkpVehicleDefaultSteering
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void calcSteering(const hkReal deltaTime, const hkpVehicleInstance* vehicle, const hkpVehicleDriverInput::FilteredDriverInputOutput& filteredInfoOutput, SteeringAnglesOutput& steeringOutput )
|
||||||
|
{
|
||||||
|
hkpVehicleDefaultSteering::calcMainSteeringAngle( deltaTime, vehicle, filteredInfoOutput, steeringOutput );
|
||||||
|
|
||||||
|
// Wheels.
|
||||||
|
for (int w_it = 0; w_it < m_doesWheelSteer.getSize(); w_it++)
|
||||||
|
{
|
||||||
|
if ( m_doesWheelSteer[w_it] )
|
||||||
|
{
|
||||||
|
steeringOutput.m_wheelsSteeringAngle [w_it] = steeringOutput.m_mainSteeringAngle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Steer with front and back wheels to simulate a tank.
|
||||||
|
steeringOutput.m_wheelsSteeringAngle [w_it] = -steeringOutput.m_mainSteeringAngle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class VehicleSetup
|
class VehicleSetup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user