Esempio n. 1
0
        private Vector3 AGMGuidance()
        {
            if (TargetingMode != TargetingModes.Gps)
            {
                if (TargetAcquired)
                {
                    //lose lock if seeker reaches gimbal limit
                    float targetViewAngle = Vector3.Angle(vessel.transform.forward, TargetPosition - vessel.CoM);

                    if (targetViewAngle > maxOffBoresight)
                    {
                        Debug.Log("[BDArmory]: AGM Missile guidance failed - target out of view");
                        guidanceActive = false;
                    }
                }
                else
                {
                    if (TargetingMode == TargetingModes.Laser)
                    {
                        //keep going straight until found laser point
                        TargetPosition = laserStartPosition + (20000 * startDirection);
                    }
                }
            }
            Vector3 agmTarget = MissileGuidance.GetAirToGroundTarget(TargetPosition, vessel, 1.85f);

            return(agmTarget);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void GuidanceSteer(FlightCtrlState s)
        {
            if (guidanceActive && targetVessel != null && vessel != null && vesselTransform != null && velocityTransform != null)
            {
                velocityTransform.rotation = Quaternion.LookRotation(vessel.srf_velocity, -vesselTransform.forward);
                Vector3 targetPosition = targetVessel.CoM;
                Vector3 localAngVel    = vessel.angularVelocity;

                if (guidanceMode == 1)
                {
                    targetPosition = MissileGuidance.GetAirToAirTarget(targetPosition, vessel.srf_velocity, vessel.acceleration, vessel, out timeToImpact);
                }
                else if (guidanceMode == 2)
                {
                    targetPosition = MissileGuidance.GetAirToGroundTarget(targetPosition, vessel, 1.85f);
                }
                else
                {
                    targetPosition = MissileGuidance.GetCruiseTarget(targetPosition, vessel, cruiseAltitude);
                }

                Vector3 targetDirection = velocityTransform.InverseTransformPoint(targetPosition).normalized;
                targetDirection = Vector3.RotateTowards(Vector3.forward, targetDirection, 15 * Mathf.Deg2Rad, 0);



                float steerYaw   = (steerMult * targetDirection.x) - (steerDamping * -localAngVel.z);
                float steerPitch = (steerMult * targetDirection.y) - (steerDamping * -localAngVel.x);

                s.yaw   = Mathf.Clamp(steerYaw, -maxSteer, maxSteer);
                s.pitch = Mathf.Clamp(steerPitch, -maxSteer, maxSteer);

                s.mainThrottle = 1;
            }
        }