AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
AirControl.AC_Airplane_Engine Class Reference

Engine controls More...

Inheritance diagram for AirControl.AC_Airplane_Engine:
Collaboration diagram for AirControl.AC_Airplane_Engine:

Public Member Functions

void getAngularVelocityPro ()
 
Vector3 CalculateForce (float throttle)
 Calculate the force created by engine Calculate Engine RPM Calculate fuel consumption More...
 

Public Attributes

float maxForce = 3000f
 
float maxRPM = 3500f
 
AnimationCurve powerCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f)
 
AnimationCurve liftOff = AnimationCurve.Linear(0f, 0f, 1000f, 1000f)
 
AC_Airplane_Propeller propeller
 

Properties

bool ShutEngineOff [set]
 
float CurrentRPM [get]
 

Detailed Description

Engine controls

Definition at line 22 of file AC_Airplane_Engine.cs.

Member Function Documentation

◆ CalculateForce()

Vector3 AirControl.AC_Airplane_Engine.CalculateForce ( float  throttle)
inline

Calculate the force created by engine Calculate Engine RPM Calculate fuel consumption

Parameters
throttleInput throttle value
Returns
Final Engine force

Definition at line 110 of file AC_Airplane_Engine.cs.

111  {
112  //Calcualte Power
113  float finalThrottle = Mathf.Clamp01(throttle);
114  // angular velocity
115  getAngularVelocityPro();
116 
117  if(!isShutOff)
118  {
119  finalThrottle = powerCurve.Evaluate(finalThrottle);
120  //keep eye on last throttle value, In case of engine cutoff we can use this value to slowly decrease the engine power
121  lastThrottleValue = finalThrottle;
122  }
123  else
124  {
125  lastThrottleValue -= Time.deltaTime * shutOffSpeed;
126  lastThrottleValue = Mathf.Clamp01(lastThrottleValue);
127  finalThrottle = powerCurve.Evaluate(lastThrottleValue);
128  }
129 
130 
131  //Calculate RPM's
132  currentRPM = finalThrottle * maxRPM;
133  if(propeller)
134  {
135  propeller.HandlePropeller(currentRPM);
136  }
137 
138 
139  // Process the Fuel
140  HandleFuel(finalThrottle);
141 
142 
143  //Create Force
144  float finalPower = finalThrottle * maxForce;
145  Vector3 finalForce = transform.forward * finalPower;
146 
147  #region DBArea
148  //Setting Current engine paramters to DB
149  // DB_Functions.SetEngineVariables(connection, maxForce, finalPower, maxRPM, CurrentRPM);
150  StaticOutputSchema.MaxPower = maxForce; // can be moved to start
151  StaticOutputSchema.CurrentPower = finalPower;
152  StaticOutputSchema.MaxRPM = maxRPM; // can be moved to start
153  StaticOutputSchema.CurrentRPM = currentRPM;
154  #endregion
155 
156  return finalForce;
157  }

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