Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
VehicleTransmission Class Reference

Runtime data for transmission. More...

#include <VehicleTransmission.h>

Inheritance diagram for VehicleTransmission:
VehicleTransmissionSettings

Public Member Functions

void Set (int inCurrentGear, float inClutchFriction)
 
void Update (float inDeltaTime, float inCurrentRPM, float inForwardInput, bool inCanShiftUp)
 
int GetCurrentGear () const
 Current gear, -1 = reverse, 0 = neutral, 1 = 1st gear etc. More...
 
float GetClutchFriction () const
 Value between 0 and 1 indicating how much friction the clutch gives (0 = no friction, 1 = full friction) More...
 
bool IsSwitchingGear () const
 If the auto box is currently switching gears. More...
 
float GetCurrentRatio () const
 Return the transmission ratio based on the current gear (ratio between engine and differential) More...
 
bool AllowSleep () const
 Only allow sleeping when the transmission is idle. More...
 
void SaveState (StateRecorder &inStream) const
 Saving state for replay. More...
 
void RestoreState (StateRecorder &inStream)
 
- Public Member Functions inherited from VehicleTransmissionSettings
void SaveBinaryState (StreamOut &inStream) const
 Saves the contents in binary form to inStream. More...
 
void RestoreBinaryState (StreamIn &inStream)
 Restores the contents in binary form to inStream. More...
 

Additional Inherited Members

- Public Attributes inherited from VehicleTransmissionSettings
ETransmissionMode mMode = ETransmissionMode::Auto
 How to switch gears. More...
 
Array< float > mGearRatios { 2.66f, 1.78f, 1.3f, 1.0f, 0.74f }
 Ratio in rotation rate between engine and gear box, first element is 1st gear, 2nd element 2nd gear etc. More...
 
Array< float > mReverseGearRatios { -2.90f }
 Ratio in rotation rate between engine and gear box when driving in reverse. More...
 
float mSwitchTime = 0.5f
 How long it takes to switch gears (s), only used in auto mode. More...
 
float mClutchReleaseTime = 0.3f
 How long it takes to release the clutch (go to full friction), only used in auto mode. More...
 
float mSwitchLatency = 0.5f
 How long to wait after releasing the clutch before another switch is attempted (s), only used in auto mode. More...
 
float mShiftUpRPM = 4000.0f
 If RPM of engine is bigger then this we will shift a gear up, only used in auto mode. More...
 
float mShiftDownRPM = 2000.0f
 If RPM of engine is smaller then this we will shift a gear down, only used in auto mode. More...
 
float mClutchStrength = 10.0f
 Strength of the clutch when fully engaged. Total torque a clutch applies is Torque = ClutchStrength * (Velocity Engine - Avg Velocity Wheels At Clutch) (units: k m^2 s^-1) More...
 

Detailed Description

Runtime data for transmission.

Member Function Documentation

◆ AllowSleep()

bool VehicleTransmission::AllowSleep ( ) const
inline

Only allow sleeping when the transmission is idle.

◆ GetClutchFriction()

float VehicleTransmission::GetClutchFriction ( ) const
inline

Value between 0 and 1 indicating how much friction the clutch gives (0 = no friction, 1 = full friction)

◆ GetCurrentGear()

int VehicleTransmission::GetCurrentGear ( ) const
inline

Current gear, -1 = reverse, 0 = neutral, 1 = 1st gear etc.

◆ GetCurrentRatio()

float VehicleTransmission::GetCurrentRatio ( ) const

Return the transmission ratio based on the current gear (ratio between engine and differential)

◆ IsSwitchingGear()

bool VehicleTransmission::IsSwitchingGear ( ) const
inline

If the auto box is currently switching gears.

◆ RestoreState()

void VehicleTransmission::RestoreState ( StateRecorder inStream)

◆ SaveState()

void VehicleTransmission::SaveState ( StateRecorder inStream) const

Saving state for replay.

◆ Set()

void VehicleTransmission::Set ( int  inCurrentGear,
float  inClutchFriction 
)
inline

Set input from driver regarding the transmission (only relevant when transmission is set to manual mode)

Parameters
inCurrentGearCurrent gear, -1 = reverse, 0 = neutral, 1 = 1st gear etc.
inClutchFrictionValue between 0 and 1 indicating how much friction the clutch gives (0 = no friction, 1 = full friction)

◆ Update()

void VehicleTransmission::Update ( float  inDeltaTime,
float  inCurrentRPM,
float  inForwardInput,
bool  inCanShiftUp 
)

Update the current gear and clutch friction if the transmission is in auto mode

Parameters
inDeltaTimeTime step delta time in s
inCurrentRPMCurrent RPM for engine
inForwardInputHint if the user wants to drive forward (> 0) or backwards (< 0)
inCanShiftUpIndicates if we want to allow the transmission to shift up (e.g. pass false if wheels are slipping)

The documentation for this class was generated from the following files: