Esempio n. 1
0
        public float seekWeight = 0.2f;         // weight of the seek behaviour

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

            SteeringOutput result = FlockingAround.GetSteering(this.ownKS, attractor, seekWeight, idTag, cohesionThreshold, repulsionThreshold, wanderRate,
                                                               vmWeight, rpWeight, coWeight, wdWeight);

            base.applyRotationalPolicy(rotationalPolicy, result, attractor);
            return(result);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public static SteeringOutput GetSteering(KinematicState ownKS, GameObject attractor, float seekWeight, string idTag,
                                                 float cohesionThreshold, float repulsionThreshold,
                                                 float wanderRate,
                                                 float vmWeight, float rpWeight, float coWeight, float wdWeight,
                                                 float distance, float angle, ref bool previous, GameObject self, float tooClose, float safe)
        {
            if (previous)
            {
                if (SensingUtils.DistanceToTarget(self, attractor) >= safe)
                {
                    previous = false;

                    //Vector3 pepe = Utils.OrientationToVector(attractor.GetComponent<KinematicState>().orientation + angle).normalized * distance;
                    //SURROGATE_TARGET.transform.position = attractor.transform.position + pepe;
                    return(FlockingAround.GetSteering(ownKS, attractor, seekWeight, idTag, cohesionThreshold, repulsionThreshold, wanderRate, vmWeight,
                                                      rpWeight, coWeight, wdWeight));
                }
                else
                {
                    return(Flee.GetSteering(ownKS, attractor));
                }
            }
            else
            {
                if (SensingUtils.DistanceToTarget(self, attractor) < tooClose)
                {
                    previous = true;
                    return(Flee.GetSteering(ownKS, attractor));
                }
                else
                {
                    //Vector3 pepe = Utils.OrientationToVector(attractor.GetComponent<KinematicState>().orientation + angle).normalized * distance;
                    //SURROGATE_TARGET.transform.position = attractor.transform.position + pepe;
                    return(FlockingAround.GetSteering(ownKS, attractor, seekWeight, idTag, cohesionThreshold, repulsionThreshold, wanderRate, vmWeight,
                                                      rpWeight, coWeight, wdWeight));
                }
            }
        }