public override void Execute(Steerable steerable) { base.Execute(steerable); steerable.AddWallAvoidanceForce(avoidanceForce, maxViewDistance, obstacleLayer, strengthMultiplier); }
public override void Execute(Steerable steerable) { base.Execute(steerable); steerable.AddWallAvoidanceForce(avoidanceForce, maxViewDistance, obstacleLayer, strengthMultiplier); }
void FixedUpdate() { // If the stopping condition has been met, stop moving if (stoppingCondition.Complete()) { return; } // Cycle through the steering behaviors to apply on this GameObject for (int i = 0; i < steeringBehaviors.Length; i++) { // Stores the steering behavior to apply SteeringBehavior steeringBehavior = steeringBehaviors[i]; // Switch the type of the steering behavior and add it to the GameObject switch (steeringBehavior.type) { case SteeringBehaviorType.Seek: steerable.AddSeekForce(steeringBehavior.targetTransform.position, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Arrival: steerable.AddArrivalForce(steeringBehavior.targetTransform.position, steeringBehavior.slowingRadius, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Pursue: steerable.AddPursueForce(steeringBehavior.targetSteerable, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Flee: steerable.AddFleeForce(steeringBehavior.targetTransform.position, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Evade: steerable.AddEvadeForce(steeringBehavior.targetSteerable, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Wander: steerable.AddWanderForce(steeringBehavior.circleDistance, steeringBehavior.circleRadius, steeringBehavior.angleChange, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.ObstacleAvoidance: steerable.AddObstacleAvoidanceForce(steeringBehavior.obstacleAvoidanceForce, steeringBehavior.maxObstacleViewDistance, steeringBehavior.obstacleLayer, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.WallAvoidance: steerable.AddWallAvoidanceForce(steeringBehavior.obstacleAvoidanceForce, steeringBehavior.maxObstacleViewDistance, steeringBehavior.obstacleLayer, steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Separation: steerable.AddSeparationForce(steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Alignment: steerable.AddAlignmentForce(steeringBehavior.strengthMultiplier); break; case SteeringBehaviorType.Cohesion: steerable.AddCohesionForce(steeringBehavior.strengthMultiplier); break; } } // Apply the forces on the steerable that is performing this action steerable.ApplyForces(Time.fixedDeltaTime); }