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; } } }
public void addFlee(Vector3 targetPosition, float range = 999999) { Vector3 flee = SteeringBehaviours.flee(this, targetPosition, range); desired += flee; }
public void addArrive(Vector3 targetPosition, float arriveRange, float range = 999999) { Vector3 arrive = SteeringBehaviours.arrive(this, targetPosition, range); desired += arrive; }
public void addSeek(Vector3 targetPosition, float range = 999999) { Vector3 seek = SteeringBehaviours.seek(this, targetPosition, range); desired += seek; }
public void addAlign(List <BaseAgent> agents, float range, float power = 1) { desiredVector += SteeringBehaviours.Align(this, agents, range) * power; }
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; }
public void addRandom2D(Vector3 referencePosition, float changeTargetCD = .1f, float randomRadius = 4, float power = 1) { desiredVector += SteeringBehaviours.Random2D(this, referencePosition, changeTargetCD, randomRadius, power); }
public void addFlee(Vector3 target, float range, float power = 1) { desiredVector += SteeringBehaviours.Flee(this, target, range) * power; }
public void addSeek(Vector3 target, float power = 1) { desiredVector += SteeringBehaviours.Seek(this, target) * power; }