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);
            }
        }
Esempio n. 2
0
        protected override SteeringOutput GetSteering()
        {
            SteeringOutput result = Wander.GetSteering(m_ownKS, ref m_info);

            base.ApplyFacingPolicy(m_info.m_facingPolicy, result);

            return(result);
        }
Esempio n. 3
0
        public static SteeringOutput GetSteering(KinematicState ownKS, float seekWeight, ref SWander wanderInfo, SSeek seekInfo)
        {
            SteeringOutput seekSteering = Seek.GetSteering(ownKS, seekInfo.m_target);
            SteeringOutput result       = Wander.GetSteering(ownKS, ref wanderInfo);

            result.m_linearAcceleration = result.m_linearAcceleration * (1f - seekWeight) + seekSteering.m_linearAcceleration * seekWeight;

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

            return(Wander.GetSteering(ownKS, ref targetOrientation, wanderRate, wanderRadius, wanderOffset));
        }
Esempio n. 5
0
        public static SteeringOutput GetSteering(KinematicState ownKS, GameObject attractor, float seekWeight,
                                                 ref float targetOrientation, float wanderRate = 30f,
                                                 float wanderRadius = 10f, float wanderOffset = 20f)
        {
            SteeringOutput seekOutput = Seek.GetSteering(ownKS, attractor);
            SteeringOutput result     = Wander.GetSteering(ownKS, ref targetOrientation, wanderRate, wanderRadius, wanderOffset);

            result.linearAcceleration = result.linearAcceleration * (1 - seekWeight) + seekOutput.linearAcceleration * seekWeight;
            // result.angularAcceleration = result.angularAcceleration * (1 - seekWeight) + seekOutput.angularAcceleration * seekWeight;

            return(result);
        }
        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 = Wander.GetSteering(ownKS, ref targetOrientation, wanderRate, wanderRadius, wanderOffset);

            base.applyRotationalPolicy(rotationalPolicy, result, SURROGATE_TARGET);
            return(result);
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        public override SteeringOutput GetSteering()
        {
            SteeringOutput result = Wander.GetSteering(ownKS, ref targetOrientation, wanderRate, wanderRadius, wanderOffset);

            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);
        }