public override Vector3 Calculate(SteeringBehaviorState state, Vector3 target) { Vector3 desiredDirect = Vector3.zero; if (desiredDirect.magnitude < movingEntity.maxSpeed) { desiredDirect += Flee(target) * fleeWeight; } List <MovingEntity> neighbors = TagNeighbors(movingEntity, NeighborPredicate); if (desiredDirect.magnitude < movingEntity.maxSpeed) { desiredDirect += Vector3.ClampMagnitude( Cohesion(movingEntity, neighbors) * fleeWeight, movingEntity.maxSpeed - desiredDirect.magnitude); } if (desiredDirect.magnitude < movingEntity.maxSpeed) { desiredDirect += Vector3.ClampMagnitude( Separation(movingEntity, neighbors) * separationWeight, movingEntity.maxSpeed - desiredDirect.magnitude); } return(desiredDirect); }
public virtual Vector3 Calculate(SteeringBehaviorState state, Vector3 target) { switch (state) { case SteeringBehaviorState.Arrive: { return(Arrive(target)); } case SteeringBehaviorState.Flee: { return(Flee(target)); } case SteeringBehaviorState.Seek: { return(Seek(target)); } case SteeringBehaviorState.Pursuit: { return(Pursuit(movingEntity.target)); } case SteeringBehaviorState.Cohesion: { List <MovingEntity> neighbors = TagNeighbors(movingEntity, NeighborPredicate); return(Cohesion(movingEntity, neighbors)); } case SteeringBehaviorState.Separation: { List <MovingEntity> neighbors = TagNeighbors(movingEntity, NeighborPredicate); return(Separation(movingEntity, neighbors)); } default: return(Vector3.zero); } }