private Vector3 CruiseGuidance() { Vector3 cruiseTarget = Vector3.zero; float distance = Vector3.Distance(TargetPosition, vessel.CoM); if (distance < 4500) { cruiseTarget = MissileGuidance.GetTerminalManeuveringTarget(TargetPosition, vessel, CruiseAltitude); debugString += "\nTerminal Maneuvers"; } else { float agmThreshDist = 2500; if (distance < agmThreshDist) { if (!MissileGuidance.GetBallisticGuidanceTarget(TargetPosition, vessel, true, out cruiseTarget)) { cruiseTarget = MissileGuidance.GetAirToGroundTarget(TargetPosition, vessel, 1.85f); } debugString += "\nDescending On Target"; } else { cruiseTarget = MissileGuidance.GetCruiseTarget(TargetPosition, vessel, CruiseAltitude); debugString += "\nCruising"; } } debugString += "\nRadarAlt: " + MissileGuidance.GetRadarAltitude(vessel); return(cruiseTarget); }
private Vector3 BallisticGuidance() { Vector3 agmTarget; bool validSolution = MissileGuidance.GetBallisticGuidanceTarget(TargetPosition, vessel, false, out agmTarget); if (!validSolution || Vector3.Angle(TargetPosition - this.vessel.CoM, agmTarget - this.vessel.CoM) > Mathf.Clamp(maxOffBoresight, 0, 65)) { Vector3 dToTarget = TargetPosition - this.vessel.CoM; Vector3 direction = Quaternion.AngleAxis(Mathf.Clamp(maxOffBoresight * 0.9f, 0, 45f), Vector3.Cross(dToTarget, VectorUtils.GetUpDirection(this.vessel.transform.position))) * dToTarget; agmTarget = this.vessel.CoM + direction; } return(agmTarget); }