Example #1
0
 void ComputeForces()
 {
     // SET force Vector3.zero
     force = Vector3.zero;
     // FOR i := 0 < behaviours.Count
     for (int i = 0; i < behaviours.Count; i++)
     {
         // LET behaviour = behaviours[i]
         SteeringBehaviours behaviour = behaviours[i];
         // IF behaviour.isActiveAndEnabled == false
         if (behaviour.isActiveAndEnabled == false)
         {
             // continue
             continue;
         }
         // SET force = force + behaviour.GetForce() * behaviour.weighting
         force = force + behaviour.GetForce() * behaviour.weight;
         // IF force > maxVelocity
         if (force.magnitude > maxVelocity)
         {
             // SET force = force.normalized * maxVelocity
             force = force.normalized * maxVelocity;
             // break
             break;
         }
     }
 }
Example #2
0
        public void addFlee(Vector3 targetPosition, float range = 999999)
        {
            Vector3 flee = SteeringBehaviours.flee(this, targetPosition, range);

            desired += flee;
        }
Example #3
0
        public void addArrive(Vector3 targetPosition, float arriveRange, float range = 999999)
        {
            Vector3 arrive = SteeringBehaviours.arrive(this, targetPosition, range);

            desired += arrive;
        }
Example #4
0
        public void addSeek(Vector3 targetPosition, float range = 999999)
        {
            Vector3 seek = SteeringBehaviours.seek(this, targetPosition, range);

            desired += seek;
        }
Example #5
0
 public void addAlign(List <BaseAgent> agents, float range, float power = 1)
 {
     desiredVector += SteeringBehaviours.Align(this, agents, range) * power;
 }
Example #6
0
 public void addWander(float wanderDistance, float wanderRadius, float angleDelta, float maxAngle, float power = 1)
 {
     desiredVector += SteeringBehaviours.Wander2D(this, wanderDistance, wanderRadius, Mathf.Deg2Rad * angleDelta, Mathf.Deg2Rad * maxAngle) * power;
 }
Example #7
0
 public void addRandom2D(Vector3 referencePosition, float changeTargetCD = .1f, float randomRadius = 4, float power = 1)
 {
     desiredVector += SteeringBehaviours.Random2D(this, referencePosition, changeTargetCD, randomRadius, power);
 }
Example #8
0
 public void addFlee(Vector3 target, float range, float power = 1)
 {
     desiredVector += SteeringBehaviours.Flee(this, target, range) * power;
 }
Example #9
0
 public void addSeek(Vector3 target, float power = 1)
 {
     desiredVector += SteeringBehaviours.Seek(this, target) * power;
 }