Configured engine to use altimeter
This commit is contained in:
@@ -1702,11 +1702,11 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: '::'
|
m_EditorClassIdentifier: '::'
|
||||||
fuelTank: {fileID: 1437557826}
|
fuelTank: {fileID: 1437557826}
|
||||||
|
altimeter: {fileID: 894314916}
|
||||||
maxThrust: 1000
|
maxThrust: 1000
|
||||||
Isp: 300
|
Isp: 300
|
||||||
throttleRampTime: 2
|
throttleRampTime: 2
|
||||||
minStartupFlow: 0.05
|
minStartupFlow: 0.05
|
||||||
g: 9.81
|
|
||||||
throttleCurve:
|
throttleCurve:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Curve:
|
m_Curve:
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class MainEngine : MonoBehaviour
|
public class MainEngine : MonoBehaviour
|
||||||
{
|
{
|
||||||
[Header("Fuel Source")]
|
[Header("References")]
|
||||||
public FuelTank fuelTank; // Reference to the fuel tank supplying this engine
|
public FuelTank fuelTank; // Reference to the fuel tank supplying this engine
|
||||||
|
public Altimeter altimeter; // Reference to the altimeter for gravity calculations
|
||||||
|
|
||||||
[Header("Engine Settings")]
|
[Header("Engine Settings")]
|
||||||
public float maxThrust = 1000f; // kN
|
public float maxThrust = 1000f; // kN
|
||||||
public float Isp = 300f; // seconds
|
public float Isp = 300f; // seconds
|
||||||
public float throttleRampTime = 2f; // seconds to reach full throttle
|
public float throttleRampTime = 2f; // seconds to reach full throttle
|
||||||
public float minStartupFlow = 0.05f; // minimum fraction of max flow to maintain ignition
|
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);
|
public AnimationCurve throttleCurve = AnimationCurve.Linear(0, 0, 1, 1);
|
||||||
|
|
||||||
[Header("Efficiency Settings")]
|
[Header("Efficiency Settings")]
|
||||||
@@ -29,6 +29,7 @@ public class MainEngine : MonoBehaviour
|
|||||||
private bool everStarted = false; // tracks if engine has ever been started
|
private bool everStarted = false; // tracks if engine has ever been started
|
||||||
private float postIgnitionTimer = 0f; // timer for post-ignition grace period
|
private float postIgnitionTimer = 0f; // timer for post-ignition grace period
|
||||||
private const float postIgnitionGrace = 0.5f; // seconds to allow ramp-up after ignition
|
private const float postIgnitionGrace = 0.5f; // seconds to allow ramp-up after ignition
|
||||||
|
private float g = 9.81f; // local gravity from altimeter
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
@@ -55,6 +56,8 @@ public class MainEngine : MonoBehaviour
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void HandleEngineState()
|
private void HandleEngineState()
|
||||||
{
|
{
|
||||||
|
g = (float)altimeter.gh; // Update local gravity from altimeter each frame
|
||||||
|
|
||||||
// Check if engine is offline and restartable conditions
|
// Check if engine is offline and restartable conditions
|
||||||
|
|
||||||
if (!engineOnline)
|
if (!engineOnline)
|
||||||
|
|||||||
Reference in New Issue
Block a user