Class AircraftEngineBase
Base class for all aircraft engine types (piston, turbine, etc.).
Handles engine state management, RPM, torque generation, and propulsor connections.
Inheritance
AircraftEngineBase
Assembly: NWH.Aerodynamics.dll
Syntax
public abstract class AircraftEngineBase : AircraftMonoBehaviour
Fields
|
Edit this page
View Source
_atmosphere
Declaration
protected Atmosphere _atmosphere
Field Value
|
Edit this page
View Source
_parentRigidbody
Declaration
protected Rigidbody _parentRigidbody
Field Value
|
Edit this page
View Source
angularVelocity
Current angular velocity of the engine in radians per second.
Declaration
public float angularVelocity
Field Value
|
Edit this page
View Source
generatedPower
Power generated by the engine in kW
Declaration
[Tooltip("Power generated by the engine in kW")]
public float generatedPower
Field Value
|
Edit this page
View Source
generatedTorque
Torque currently generated by the engine in Newton-meters.
Declaration
public float generatedTorque
Field Value
|
Edit this page
View Source
inertia
Rotational inertia of the engine in kg*m^2.
Higher values result in slower RPM changes.
Declaration
[Tooltip("Rotational inertia of the engine in kg*m^2.\r\nHigher values result in slower RPM changes.")]
public float inertia
Field Value
|
Edit this page
View Source
internalDragTorque
Torque representing losses in the engine.
Higher value will result in engine slowing down faster.
Declaration
[Tooltip(" Torque representing losses in the engine.\r\n Higher value will result in engine slowing down faster.")]
public float internalDragTorque
Field Value
|
Edit this page
View Source
isStalling
Is the engine stalling? Stalling will happen if engine RPM is lower than stall RPM.
Declaration
[Tooltip("Is the engine stalling? Stalling will happen if engine RPM is lower than stall RPM.")]
public bool isStalling
Field Value
|
Edit this page
View Source
maxAngularVelocity
Declaration
protected float maxAngularVelocity
Field Value
|
Edit this page
View Source
maxPower
Maximum engine power in [kW].
Declaration
[Tooltip("Maximum engine power in [kW].")]
public float maxPower
Field Value
|
Edit this page
View Source
maxRPM
Maximum engine RPM. This is a hard limit set in solver that the engine will never be able to go over.
Differs from rev limiter RPM and should always be higher than rev limiter.
Declaration
[Tooltip("Maximum engine RPM. This is a hard limit set in solver that the engine will never be able to go over.\r\nDiffers from rev limiter RPM and should always be higher than rev limiter.")]
public float maxRPM
Field Value
|
Edit this page
View Source
maxThrottle
Declaration
Field Value
|
Edit this page
View Source
minAngularVelocity
Declaration
protected float minAngularVelocity
Field Value
|
Edit this page
View Source
minRPM
Minimum engine RPM. Hard limit set in solver that the engine will never go under.
It is recommended to set it to a negative value as otherwise the engine will always have RPM >0.
Declaration
[Tooltip("Minimum engine RPM. Hard limit set in solver that the engine will never go under.\r\nIt is recommended to set it to a negative value as otherwise the engine will always have RPM >0.")]
public float minRPM
Field Value
|
Edit this page
View Source
minThrottle
Declaration
Field Value
|
Edit this page
View Source
powerCurve
Power curve with RPM range [0,1] on the X axis and power coefficient [0,1] on Y axis.
Both values are represented as percentages and should be in 0 to 1 range.
Power coefficient is multiplied by maxPower to get the final power at given RPM.
Declaration
[Tooltip("Power curve with RPM range [0,1] on the X axis and power coefficient [0,1] on Y axis.\r\nBoth values are represented as percentages and should be in 0 to 1 range.\r\nPower coefficient is multiplied by maxPower to get the final power at given RPM.")]
public AnimationCurve powerCurve
Field Value
|
Edit this page
View Source
propulsors
List of propulsors (propellers, jets) driven by this engine.
Declaration
public List<PropulsorBase> propulsors
Field Value
|
Edit this page
View Source
returnTorque
Declaration
protected float returnTorque
Field Value
|
Edit this page
View Source
rpm
Current engine RPM (revolutions per minute).
Declaration
Field Value
|
Edit this page
View Source
stallAngularVelocity
Declaration
protected float stallAngularVelocity
Field Value
|
Edit this page
View Source
stallRPM
Engine RPM under which the engine stalls.
Declaration
[Tooltip("Engine RPM under which the engine stalls.")]
public float stallRPM
Field Value
|
Edit this page
View Source
stallingEnabled
Can the vehicle be stalled?
If disabled engine will run no matter the RPM. Automatically disabled when electric engine type is used.
Declaration
[Tooltip("Can the vehicle be stalled?\r\nIf disabled engine will run no matter the RPM. Automatically disabled when electric engine type is used.")]
public bool stallingEnabled
Field Value
|
Edit this page
View Source
startOnWake
If true the engine will attempt to start once the vehicle is woken up.
Declaration
[Tooltip("If true the engine will attempt to start once the vehicle is woken up.")]
public bool startOnWake
Field Value
|
Edit this page
View Source
starterTorque
Torque starter motor can put out. Make sure that this torque is more than loss torque
at the starter RPM limit. If too low the engine will fail to start.
Declaration
[Tooltip("Torque starter motor can put out. Make sure that this torque is more than loss torque\r\nat the starter RPM limit. If too low the engine will fail to start.")]
public float starterTorque
Field Value
|
Edit this page
View Source
state
Declaration
public AircraftEngineBase.EngineState state
Field Value
|
Edit this page
View Source
stopOnSleep
If true the engine will be shut off when vehicle is put to sleep.
Declaration
[Tooltip("If true the engine will be shut off when vehicle is put to sleep.")]
public bool stopOnSleep
Field Value
|
Edit this page
View Source
throttleAdjustmentSpeed
Throttle adjustment speed in percent per second.
Declaration
[Tooltip("Throttle adjustment speed in percent per second.")]
public float throttleAdjustmentSpeed
Field Value
|
Edit this page
View Source
throttlePosition
Current throttle position from 0 (idle) to 1 (full throttle).
Declaration
public float throttlePosition
Field Value
Properties
|
Edit this page
View Source
GeneratedTorque
Gets the torque currently generated by the engine in Newton-meters.
Declaration
public float GeneratedTorque { get; }
Property Value
|
Edit this page
View Source
IsRunning
Gets whether the engine is currently running or starting.
Declaration
public bool IsRunning { get; }
Property Value
|
Edit this page
View Source
MaxAngularVelocity
Maximum angular velocity the engine can physically achieve.
Declaration
public float MaxAngularVelocity { get; }
Property Value
|
Edit this page
View Source
MinAngularVelocity
Minimum angular velocity the engine can physically achieve.
Declaration
public float MinAngularVelocity { get; }
Property Value
|
Edit this page
View Source
RPM
Declaration
public float RPM { get; }
Property Value
|
Edit this page
View Source
RPMPercent
RPM as a percentage of maximum RPM.
Declaration
public float RPMPercent { get; }
Property Value
|
Edit this page
View Source
StallAngularVelocity
Angular velocity at which the engine stalls.
Declaration
public float StallAngularVelocity { get; }
Property Value
|
Edit this page
View Source
ThrottlePosition
Engine throttle position. 0 for no throttle and 1 for full throttle.
Declaration
public float ThrottlePosition { get; set; }
Property Value
Methods
|
Edit this page
View Source
CalculateTorque(float, float)
Calculates the engine torque output for the current simulation step.
Must be implemented by derived engine types (piston, turbine, etc.).
Declaration
public abstract float CalculateTorque(float t, float dt)
Parameters
| Type |
Name |
Description |
| float |
t |
Current simulation time in seconds.
|
| float |
dt |
Time step duration in seconds.
|
Returns
| Type |
Description |
| float |
Generated torque in Newton-meters.
|
|
Edit this page
View Source
Disable()
Declaration
|
Edit this page
View Source
FixedUpdate()
Declaration
public void FixedUpdate()
|
Edit this page
View Source
GetLoad()
Calculates the current engine load as a percentage.
Combines power output and RPM to determine overall engine stress.
Declaration
Returns
| Type |
Description |
| float |
Engine load from 0 to 1, where 1 is maximum load.
|
|
Edit this page
View Source
HasFuel()
Checks if the aircraft has fuel available.
Declaration
Returns
| Type |
Description |
| bool |
True if fuel is available or no fuel manager is present, false if out of fuel.
|
|
Edit this page
View Source
Start()
Declaration
|
Edit this page
View Source
StartEngine()
Starts the aircraft engine.
Sets engine state to Starting, which will engage the starter motor.
Declaration
public void StartEngine()
|
Edit this page
View Source
StartStop()
Toggles the engine between running and stopped states.
Declaration
|
Edit this page
View Source
StopEngine()
Stops the aircraft engine.
Sets engine state to Stopping, which will cut power and allow the engine to spin down.
Declaration