Moved throttle adj to Instrument manager and made altimeter

This commit is contained in:
2026-02-18 12:19:50 +00:00
parent 5d353cf5fa
commit 344cb5009b
5 changed files with 141 additions and 77 deletions

View File

@@ -1,7 +1,27 @@
using Unity.VisualScripting;
using UnityEngine;
public class Altimeter : MonoBehaviour
{
void Start() { }
void Update() { }
[Header("References")]
public Rigidbody rocketRigidbody; // Reference to the rocket's Rigidbody
[Header("Data")]
public double altitude = 0; // Current altitude
public double gh = 9.81f; // Gravitational acceleration
[Header("Settings")]
[SerializeField] private double G = 6.67408f * Mathf.Pow(10, -11); // Gravitational constant
[SerializeField] private double M = 5.972f * Mathf.Pow(10, 24); // Mass of Earth
[SerializeField] private double RE = 6.372f * Mathf.Pow(10, 6); // Radius of Earth
private double GM; // Gravitational parameter (G * M)
void Start()
{
GM = G * M; // Calculate the gravitational parameter
}
void Update()
{
altitude = rocketRigidbody.position.y; // Update altitude based on the rocket's vertical position
gh = (double)(GM / Mathf.Pow((float)(RE + altitude), 2)); // Calculate gravitational acceleration at current altitude
}
}