Ejemplo n.º 1
0
        void ComputeForces()
        {
            // SET force = Vector3.zero
            force = Vector3.zero;
            //FOR i := 0 to behaviours.count (FOR tab tab)
            for (int i = 0; i < behaviours.Count; i++)
            {
                //LET behaviour = behaviour[i]
                SteeringBehaviour behaviour = behaviours[i];
                // IF behaviour.isActiveAndEnabled == false
                if (behaviour.isActiveAndEnabled == false)
                {
                    //continue
                    continue;
                }
                //SET force = force + behaviour.GetForce() x weighting
                force = force + behaviour.GetForce() * behaviour.weighting;
                //IF force.magnitude > maxVelocity
                if (force.magnitude > maxVelocity)
                {
                    //SET force = force.normalized x maxVelocity
                    force = force.normalized * maxVelocity;

                    // break
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 void ComputeForces()
 {
     // Set force = Vector3.zero
     force = Vector3.zero;
     // For i := 0 < behaviours.Count
     for (int i = 0; i < behaviours; i++)
     {
         // Let behaviour = behaviours[i]
         SteeringBehaviour behaviour = behaviours[i];
         // IF behaviour.isActiveAndEnabled == false
         if (behaviour.isActiveAndEnabled == false)
         {
             // continue
             continue;
         }
         // Set force = force + behaviour.GetForce() * behaviour.weighting
         force += behaviour.GetForce() * behaviour.weight;
         // IF force > maxVelocity
         if (force.magnitude > maxVelocity)
         {
             // Set force = force.normalized * maxVelocity
             force = force.normalized * maxVelocity;
             // break
             break;
         }
     }
 }
Ejemplo n.º 3
0
 void ComputeForces()
 {
     // SET force to zero
     force = Vector3.zero;
     // FOR i = 0 to behaviours count
     for (int i = 0; i < behaviours.Count; i++)
     {
         // LET behaviour = behaviours[i]
         SteeringBehaviour behaviour = behaviours[i];
         // IF behaviour is not enabled
         if (behaviour.isActiveAndEnabled == false)
         {
             // CONTINUE
             continue;
         }
         // SET force = force + behaviour.GetForce() * weighting
         force += behaviour.GetForce();
         // IF force > maxVelocity
         if (force.magnitude > maxSpeed)
         {
             // SET force to force normalized x maxVelocity
             force = force.normalized * maxSpeed;
             // BREAK
             break;
         }
     }
 }
Ejemplo n.º 4
0
        void ComputeForces()
        {
            // SET force = Vector3.zero
            force = Vector3.zero;

            // FOR i := 0 to behaviours.Count
            for (int i = 0; i < behaviours.Count; i++)
            {
                // LET behaviour = behaviours[i]
                SteeringBehaviour behaviour = behaviours[i]; // Elements in the List are of SteeringBehaviour type

                // IF behaviour.isActive == false
                if (behaviour.isActiveAndEnabled == false)
                {
                    // continue skips over to next element
                    continue;
                }

                // SET force = force + behaviour.GetForce() x weighting
                force = force + behaviour.GetForce() * behaviour.weight;

                // IF force.magnitude > maxVelocity
                if (force.magnitude > maxVelocity)
                {
                    // SET force = force.normalized x maxVelocity
                    force = force.normalized * maxVelocity;

                    // break
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        void ComputeForces()
        {
            //set force = vec3.0
            force = new Vector3(0, 0, 0);
            //for i := 0 < behaviours.Count
            for (int i = 0; i < behaviours.Count; i++)
            {
                //let behaviour = behaviours[i]
                SteeringBehaviour behaviour = behaviours[i];
                //if behaviour.isactiveandenabled == false
                if (behaviour.isActiveAndEnabled == false)
                {
                    //continue
                    continue;
                }
                //set force = force + behaviour.GetForce() * behaviour.weighting
                force += behaviour.GetForce();
                //if force > maxVelocity
                if (force.magnitude > maxSpeed)
                {
                    force = force.normalized * maxSpeed;
                    break;
                }

                //set force = force.normalised * maxvel
                //break
            }
        }
Ejemplo n.º 6
0
 void ComputeForces()                                 // Function for Computing the forces
 {
     force = Vector3.zero;                            // sets variable force to 0,0,0
     for (int i = 0; i < behaviours.Count; i++)       // for loop for every behaviour in the list
     {
         SteeringBehaviour behaviour = behaviours[i]; // defines behaviour as behaviours list count
         if (behaviour.isActiveAndEnabled == false)   // checks if the variable is false
         {
             continue;                                // continues onward
         }
         force += behaviour.GetForce();               // sets force to add onto what it currently is, plus the force of behaviour
         if (force.magnitude > maxSpeed)              // if the force magnitude is greater than the max speed
         {
             force = force.normalized * maxSpeed;     // sets the force to be normal times the max speed
             break;                                   // break it
         }
     }
 }