Configured engine to use altimeter

This commit is contained in:
2026-02-18 12:28:36 +00:00
parent 344cb5009b
commit cb4780d0e2
2 changed files with 6 additions and 3 deletions

View File

@@ -1702,11 +1702,11 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: '::'
fuelTank: {fileID: 1437557826}
altimeter: {fileID: 894314916}
maxThrust: 1000
Isp: 300
throttleRampTime: 2
minStartupFlow: 0.05
g: 9.81
throttleCurve:
serializedVersion: 2
m_Curve:

View File

@@ -2,15 +2,15 @@ using UnityEngine;
public class MainEngine : MonoBehaviour
{
[Header("Fuel Source")]
[Header("References")]
public FuelTank fuelTank; // Reference to the fuel tank supplying this engine
public Altimeter altimeter; // Reference to the altimeter for gravity calculations
[Header("Engine Settings")]
public float maxThrust = 1000f; // kN
public float Isp = 300f; // seconds
public float throttleRampTime = 2f; // seconds to reach full throttle
public float minStartupFlow = 0.05f; // minimum fraction of max flow to maintain ignition
public float g = 9.81f; // gravitational acceleration (m/s^2) (to be replaced)
public AnimationCurve throttleCurve = AnimationCurve.Linear(0, 0, 1, 1);
[Header("Efficiency Settings")]
@@ -29,6 +29,7 @@ public class MainEngine : MonoBehaviour
private bool everStarted = false; // tracks if engine has ever been started
private float postIgnitionTimer = 0f; // timer for post-ignition grace period
private const float postIgnitionGrace = 0.5f; // seconds to allow ramp-up after ignition
private float g = 9.81f; // local gravity from altimeter
void Update()
{
@@ -55,6 +56,8 @@ public class MainEngine : MonoBehaviour
/// </summary>
private void HandleEngineState()
{
g = (float)altimeter.gh; // Update local gravity from altimeter each frame
// Check if engine is offline and restartable conditions
if (!engineOnline)