Engine Component

The engine generates torque based on throttle input, RPM, and power curves. Supports both Internal Combustion Engine (ICE) and electric motor simulation.
Engine Types
ICE (Internal Combustion Engine)
- Requires starter motor to start
- Can stall at low RPM (below
stallRPM) - Uses idle control to maintain minimum RPM
- Supports rev limiter and forced induction
Electric
- Instant torque, no starter needed
- Cannot stall, operates at any RPM including zero
- No idle control or forced induction
- Bidirectional operation for reverse
- Recommended to bypass clutch and connect directly to transmission
Properties
Inertia
Engine rotational inertia affects stall resistance and spin-up time.
Typical values:
- Sports car: 0.2
- Average car: 0.3-0.5
- Semi truck: 1-1.5
Max Power
Maximum power output in kilowatts (kW). Typical values:
- Small car: 60-100 kW
- Mid-size car: 120-180 kW
- Sports car: 200-400 kW
- Truck/SUV: 150-300 kW
Power Curve
Defines power output across RPM range. Both axes normalized (0 to 1):
- X-axis: RPM as percentage of
Rev Limiter RPM - Y-axis: Power coefficient as percentage of
Max Power
Power and torque curves represent the same data. Power curves are used because they're easier to find in real-world specifications.

Engine Loss Percent
Parasitic losses (friction, pumping, accessories) as percentage of max power. Affects engine braking and deceleration.
Typical values:
- High-efficiency: 0.15-0.20
- Average: 0.20-0.30
- Older engines: 0.30-0.40
Idle RPM
Target RPM that idle control maintains with no throttle input. ICE engines only.
Typical values:
- Modern fuel-injected: 600-800 RPM
- Older/performance: 800-1000 RPM
- High-performance: 1000-1200 RPM
Must be significantly higher than stallRPM to prevent stalling during normal operation.
Stall RPM
Minimum RPM below which ICE engine stalls. Set to 0 to disable stalling. Typical values:
- Modern engines: 300-400 RPM
- Older engines: 400-500 RPM
- Arcade mode: 0 RPM (disabled)
Starter
Start Duration
How long the starter motor cranks the engine (ICE only). Typical values:
- Quick-starting modern: 0.2-0.4 seconds
- Average: 0.4-0.6 seconds
- Heavy engines: 0.6-1.0 seconds
Starter torque is automatically calculated from engine inertia and this duration.
Auto Start On Throttle
Automatically engages starter when throttle is applied (ICE only). Enable for arcade-style games, disable for realistic simulation.
Flying Start
Engine starts instantly at idle RPM when vehicle is enabled. Useful for vehicles that spawn already running.
Rev Limiter
Rev Limiter RPM
Maximum engine RPM. When exceeded, fuel is cut for Rev Limiter Cutoff Duration.
Rev Limiter Cutoff Duration
How long throttle is cut when rev limiter activates. Higher values make hitting the limiter more rough and choppy.
Forced Induction
Turbocharger or supercharger system. See Engine Component - Forced Induction for details.
Scripting
Power Modifiers
Callbacks that modify engine power output. Each returns a multiplier:
< 1.0: Reduces power (e.g., traction control)= 1.0: No change> 1.0: Increases power (e.g., forced induction)
Final multiplier is product of all modifiers.
Example:
public float BoostModifier(float dt)
{
return boostActive ? 1.5f : 1.0f; // 50% power increase
}
vehicleController.powertrain.engine.powerModifiers.Add(BoostModifier);
See TCS Module for real-world usage limiting power during wheel spin.
Run Modifiers
Callbacks that determine if engine can run. All must return true for engine to operate. Used by modules to enforce conditions (e.g., fuel system).
Example:
public bool HasFuel()
{
return fuelLevel > 0;
}
vehicleController.powertrain.engine.runModifiers.Add(HasFuel);
Methods
StartEngine()
Starts the engine. For ICE: engages starter motor unless flyingStartEnabled is true. Electric motors start instantly.
StopEngine()
Stops the engine, cuts ignition, and resets all operating parameters.
StartStopEngine()
Toggles engine between running and stopped states.
UpdatePeakPowerAndTorque()
Recalculates peak power/torque from current power curve. Call after modifying powerCurve, maxPower, or revLimiterRPM at runtime.
UnityEvents
onStart
Invoked when engine starts. Parameter indicates if using starter (ICE only).
onStop
Invoked when engine stops. Parameter indicates if stopped by request vs. stalling.
onRevLimiter
Invoked when engine hits rev limiter.