コード例 #1
0
        private bool CheckIfTerminal(double altitude, Vector3 targetPosition, Vector3 upDirection)
        {
            Vector3 surfacePos = this._missile.vessel.transform.position +
                                 Vector3.Project(targetPosition - this._missile.vessel.transform.position, -upDirection);

            float distanceToTarget = Vector3.Distance(surfacePos, targetPosition);

            _missile.debugString.Append($"Distance to target" + distanceToTarget);
            _missile.debugString.Append(Environment.NewLine);
            double freefallTime = CalculateFreeFallTime(altitude);

            _missile.debugString.Append($"freefallTime" + freefallTime);
            _missile.debugString.Append(Environment.NewLine);

            if (distanceToTarget < (freefallTime * _missile.vessel.horizontalSrfSpeed))
            {
                GuidanceState = GuidanceState.Terminal;
                return(true);
            }
            return(false);
        }