Ejemplo n.º 1
0
        /// <summary>
        /// Default settings.
        /// </summary>
        public static AIViewSettings Default()
        {
            var result = new AIViewSettings();

            result.FieldOfView           = 160;
            result.CalmSightDistance     = 20;
            result.AlertedSightDistance  = 30;
            result.CommunicationDistance = 12;

            return(result);
        }
        /// <summary>
        /// Default settings.
        /// </summary>
        public static AIViewSettings Default()
        {
            var result = new AIViewSettings();

            result.FieldOfView           = 160;
            result.SightDistance         = 20;
            result.CommunicationDistance = 12;
            result.SightSustainTime      = 3;
            result.EnemySustainTime      = 8;

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns true if a given position is in sight.
        /// </summary>
        public static bool IsInSight(CharacterMotor motor, AIViewSettings view, bool isAlerted, Vector3 origin, Vector3 target)
        {
            var motorTop = origin + Vector3.up * motor.StandingHeight;
            var vector   = target - motorTop;
            var distance = vector.magnitude;

            if (distance > view.SightDistance(isAlerted))
            {
                return(false);
            }

            var angle = Mathf.Abs(Mathf.DeltaAngle(0, Mathf.Acos(Vector3.Dot(vector / distance, motor.HeadForward)) * Mathf.Rad2Deg));

            if (angle > view.FieldOfView * 0.5f)
            {
                return(false);
            }

            return(!IsObstructed(motorTop, target, view.SightDistance(isAlerted)));
        }