public static SteeringOutput GetSteering(KinematicState ownKS,
                                                 float WanderRate, float wanderRadius, float wanderOffset, ref float targetOrientation,
                                                 bool showWhishker, float lookAheadLength, float avoidDistance, float secondaryWhiskerAngle, float secondaryWhiskerRatio,
                                                 ref bool avoidActive)
        {
            // give priority to obstacle avoidance
            SteeringOutput so = ObstacleAvoidance.GetSteering(ownKS, showWhishker, lookAheadLength,
                                                              avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio);

            if (so == NULL_STEERING)
            {
                if (avoidActive)
                {
                    // if avoidance was active last frame, update target orientation (otherwise the object would tend to regain
                    // the orientation it had before avoiding a collision which would make it face the obstacle again)
                    targetOrientation = ownKS.orientation;
                }
                avoidActive = false;
                return(Wander.GetSteering(ownKS, ref targetOrientation, WanderRate, wanderRadius, wanderOffset));
            }
            else
            {
                avoidActive = true;
                return(so);
            }
        }
        protected override SteeringOutput GetSteering()
        {
            SteeringOutput result = ObstacleAvoidance.GetSteering(m_ownKS, m_info);

            base.ApplyFacingPolicy(m_info.m_facingPolicy, result);

            return(result);
        }
        public override SteeringOutput GetSteering()
        {
            // no KS? get it
            if (this.ownKS == null)
            {
                this.ownKS = GetComponent <KinematicState>();
            }

            return(ObstacleAvoidance.GetSteering(this.ownKS, showWhisker, lookAheadLength,
                                                 avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio));
        }
        public override SteeringOutput GetSteering()
        {
            SteeringOutput avoidance = ObstacleAvoidance.GetSteering(ownKS, showWhisker, lookAheadLength,
                                                                     avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio);

            if (avoidance != null)
            {
                return(avoidance);
            }

            return(base.GetSteering());
        }
        public static SteeringOutput GetSteering(KinematicState ownKS)
        {
            // give priority to obstacle avoidance
            SteeringOutput so = ObstacleAvoidance.GetSteering(ownKS, true, 30f, 30f);

            if (so == null)
            {
                return(KBDSteer01.GetSteering(ownKS));
            }

            return(so);
        }
        public static SteeringOutput GetSteering(KinematicState ownKS, ref SWander wanderInfo, SObstacleAvoidance obstacleInfo, ref bool obstacleAvoided)
        {
            SteeringOutput obstacleAvoidSteering = ObstacleAvoidance.GetSteering(ownKS, obstacleInfo);

            if (obstacleAvoidSteering != NULL_STEERING)
            {
                obstacleAvoided = true;
                return(obstacleAvoidSteering);
            }

            obstacleAvoided = false;
            return(Wander.GetSteering(ownKS, ref wanderInfo));
        }
        public override SteeringOutput GetSteering()
        {
            // no KS? get it
            if (this.ownKS == null)
            {
                this.ownKS = GetComponent <KinematicState>();
            }

            SteeringOutput result = ObstacleAvoidance.GetSteering(this.ownKS, showWhisker, lookAheadLength,
                                                                  avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio);

            base.applyRotationalPolicy(rotationalPolicy, result, null);
            return(result);
        }
Example #8
0
        public static SteeringOutput GetSteering(KinematicState ownKS, GameObject target, float closeEnoughRadius, float slowDownRadius, float timeToDesiredSpeed, float lookAheadLength, float avoidDistance, float secondaryWhiskerAngle, float secondaryWhiskerRatio, LayerMask avoidLayers, SphereCollider scanner, string repulsionTag, float repulsionThreshold, float arriveWeight)
        {
            SteeringOutput steeringOutput = ObstacleAvoidance.GetSteering(ownKS, lookAheadLength, avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio, avoidLayers, scanner);

            if (steeringOutput == nullSteering)
            {
                SteeringOutput arrive          = Arrive.GetSteering(ownKS, target, closeEnoughRadius, slowDownRadius, timeToDesiredSpeed);
                SteeringOutput linearRepulsion = LinearRepulsion.GetSteering(ownKS, repulsionTag, repulsionThreshold);
                arrive.linearAcceleration = arrive.linearAcceleration * arriveWeight + linearRepulsion.linearAcceleration * (1 - arriveWeight);
                return(arrive);
            }

            return(steeringOutput);
        }
Example #9
0
        public static SteeringOutput GetSteering(KinematicState ownKS,
                                                 float WanderRate, float wanderRadius, float wanderOffset, ref float targetOrientation,
                                                 bool showWhishker, float lookAheadLength, float avoidDistance, float secondaryWhiskerAngle, float secondaryWhiskerRatio)
        {
            // give priority to obstacle avoidance
            SteeringOutput so = ObstacleAvoidance.GetSteering(ownKS, showWhishker, lookAheadLength,
                                                              avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio);

            if (so == null)
            {
                return(Wander.GetSteering(ownKS, ref targetOrientation, WanderRate, wanderRadius, wanderOffset));
            }

            return(so);
        }
        public static SteeringOutput GetSteering(KinematicState ownKS,
                                                 string idTag, float cohesionsThreshold, float repulsionThreshold, float wanderRate,
                                                 bool showWhishker, float lookAheadLength, float avoidDistance, float secondaryWhiskerAngle, float secondaryWhiskerRatio)
        {
            // give priority to obstacle avoidance
            SteeringOutput so = ObstacleAvoidance.GetSteering(ownKS, showWhishker, lookAheadLength,
                                                              avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio);

            if (so == null)
            {
                return(Flocking.GetSteering(ownKS, idTag, cohesionsThreshold, repulsionThreshold, wanderRate));
            }

            return(so);
        }
Example #11
0
        public static SteeringOutput GetSteering(KinematicState ownKS,
                                                 GameObject target, float closeEnoughRadius = 5f, float slowDownRadius = 20f, float timeToDesiredSpeed = 0.1f,
                                                 bool showWhishker = true, float lookAheadLength = 10f, float avoidDistance = 10f, float secondaryWhiskerAngle = 30f, float secondaryWhiskerRatio = 0.7f)
        {
            // give priority to obstacle avoidance
            SteeringOutput so = ObstacleAvoidance.GetSteering(ownKS, showWhishker, lookAheadLength,
                                                              avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio);

            if (so == null)
            {
                return(Arrive.GetSteering(ownKS, target, closeEnoughRadius, slowDownRadius, timeToDesiredSpeed));
            }

            return(so);
        }
        public static SteeringOutput GetSteering(KinematicState ownKS,
                                                 GameObject target,
                                                 bool showWhishker = true, float lookAheadLength = 10f, float avoidDistance = 10f, float secondaryWhiskerAngle = 30f, float secondaryWhiskerRatio = 0.7f)
        {
            // give priority to obstacle avoidance
            SteeringOutput so = ObstacleAvoidance.GetSteering(ownKS, showWhishker, lookAheadLength,
                                                              avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio);

            if (so == NULL_STEERING)
            {
                return(Flee.GetSteering(ownKS, target));
            }

            return(so);
        }
Example #13
0
        public static SteeringOutput GetSteering(KinematicState ownKS,
                                                 GameObject target, float maxPredictionTime = 3f,
                                                 bool showWhishker = true, float lookAheadLength = 10f, float avoidDistance = 10f, float secondaryWhiskerAngle = 30f, float secondaryWhiskerRatio = 0.7f)
        {
            // give priority to obstacle avoidance
            SteeringOutput so = ObstacleAvoidance.GetSteering(ownKS, showWhishker, lookAheadLength,
                                                              avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio);

            if (so == null)
            {
                return(Evade.GetSteering(ownKS, target, maxPredictionTime));
            }

            return(so);
        }
Example #14
0
        public static SteeringOutput GetSteering(KinematicState ownKS,
                                                 GameObject attractor, float seekWeight,
                                                 string idTag      = "BOID", float cohesionsThreshold = 40f, float repulsionThreshold = 10f, float wanderRate = 10f,
                                                 float vmWeight    = 0.08f, float rpWeight            = 0.46f, float coWeight    = 0.23f, float wdWeight = 023f,
                                                 bool showWhishker = true, float lookAheadLength      = 10f, float avoidDistance = 10f, float secondaryWhiskerAngle = 30f, float secondaryWhiskerRatio = 0.7f)
        {
            // give priority to obstacle avoidance
            SteeringOutput so = ObstacleAvoidance.GetSteering(ownKS, showWhishker, lookAheadLength,
                                                              avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio);

            if (so == NULL_STEERING)
            {
                return(FlockingAround.GetSteering(ownKS, attractor, seekWeight, idTag, cohesionsThreshold, repulsionThreshold, wanderRate));
            }

            return(so);
        }
Example #15
0
        public static SteeringOutput GetSteering(KinematicState ownKS, float WanderRate, float wanderRadius, float wanderOffset, ref float targetOrientation, float lookAheadLength, float avoidDistance, float secondaryWhiskerAngle, float secondaryWhiskerRatio, ref bool avoidActive, LayerMask avoidLayers, SphereCollider scanner)
        {
            SteeringOutput so = ObstacleAvoidance.GetSteering(ownKS, lookAheadLength, avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio, avoidLayers, scanner);

            if (so == nullSteering)
            {
                if (avoidActive)
                {
                    targetOrientation = ownKS.orientation;
                }

                avoidActive = false;

                return(Wander.GetSteering(ownKS, ref targetOrientation, WanderRate, wanderRadius, wanderOffset));
            }
            else
            {
                avoidActive = true;
                return(so);
            }
        }
Example #16
0
        public override SteeringOutput GetSteering()
        {
            SteeringOutput result = ObstacleAvoidance.GetSteering(ownKS, lookAheadLength, avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio, avoidLayers, scanner);

            if (!surrogateTarget)
            {
                return(null);
            }

            if (ownKS.linearVelocity.magnitude > 0.001f)
            {
                surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, VectorToOrientation(ownKS.linearVelocity));
                SteeringOutput st = Align.GetSteering(ownKS, surrogateTarget);
                result.angularAcceleration = st.angularAcceleration;
                result.angularActive       = st.angularActive;
            }
            else
            {
                result.angularActive = false;
            }

            return(result);
        }