From 10bdd5db16f76903e9d92c1504721de9d6c726f3 Mon Sep 17 00:00:00 2001 From: Titan Yuan Date: Thu, 12 Sep 2024 20:02:41 -0700 Subject: [PATCH] Use defined gravity constant --- Assets/Scripts/Constants.cs | 8 ++++---- Assets/Scripts/Interceptors/Micromissile.cs | 2 +- Assets/Scripts/Missile.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Assets/Scripts/Constants.cs b/Assets/Scripts/Constants.cs index 6ccb3a9..4256044 100644 --- a/Assets/Scripts/Constants.cs +++ b/Assets/Scripts/Constants.cs @@ -3,10 +3,10 @@ using System; public static class Constants { // Constants (these should be defined with appropriate values) - private const double kAirDensity = 1.204; // Sea level air density in kg/m^3 - private const double kAirDensityScaleHeight = 10.4; // Scale height in km - private const double kGravity = 9.80665; // Standard gravity in m/s^2 - private const double kEarthMeanRadius = 6378137; // Earth's mean radius in meters + public const double kAirDensity = 1.204; // Sea level air density in kg/m^3 + public const double kAirDensityScaleHeight = 10.4; // Scale height in km + public const double kGravity = 9.80665; // Standard gravity in m/s^2 + public const double kEarthMeanRadius = 6378137; // Earth's mean radius in meters public static double CalculateAirDensityAtAltitude(double altitude) { diff --git a/Assets/Scripts/Interceptors/Micromissile.cs b/Assets/Scripts/Interceptors/Micromissile.cs index 9062ab6..b69acf8 100644 --- a/Assets/Scripts/Interceptors/Micromissile.cs +++ b/Assets/Scripts/Interceptors/Micromissile.cs @@ -4,7 +4,7 @@ using UnityEngine; public class Micromissile : Missile { - [SerializeField] private float _navigationGain = 5f; // Typically 3-5 + [SerializeField] private float _navigationGain = 3f; // Typically 3-5 private Vector3 _previousLOS; private Vector3 _accelerationCommand; diff --git a/Assets/Scripts/Missile.cs b/Assets/Scripts/Missile.cs index 8e1b68b..7905cf4 100644 --- a/Assets/Scripts/Missile.cs +++ b/Assets/Scripts/Missile.cs @@ -112,7 +112,7 @@ public class Missile : Agent protected float CalculateMaxAcceleration() { - float maxReferenceAcceleration = StaticConfig.accelerationConfig.maxReferenceAcceleration * Physics.gravity.magnitude; + float maxReferenceAcceleration = (float)(StaticConfig.accelerationConfig.maxReferenceAcceleration * Constants.kGravity); float referenceSpeed = StaticConfig.accelerationConfig.referenceSpeed; return Mathf.Pow(GetComponent().velocity.magnitude / referenceSpeed, 2) * maxReferenceAcceleration; }