public StarlingWander(Bird bird, string[] _enemyTags, Bounds bbox) : base(bird) { var blended = new BlendedSteering[2]; blended[0] = new BlendedSteering(bird, new BehaviorAndWeight(new ObstacleAvoidance (bird, LOOKAHEAD_DISTANCE, new string[]{"Ground"}), 1f)); blended[1] = new BlendedSteering(bird, new BehaviorAndWeight(new SteeringBehaviors.Wander(bird, bird.maxSpeed, 5f, 5f, bbox), 1f)); behavior = new PrioritySteering(1f, blended); enemyTags = _enemyTags; t = UnityEngine.Random.Range(MIN_TIME_CHANGE_DIRECTION, MAX_TIME_CHANGE_DIRECTION); }
Steering getDefaultSteering2(Entry e) { e.bird.maxSpeed = 30f; (e.bird as Starling).transform.Find("Sphere").gameObject.SetActive(false); var separation = new Separation(e.bird, flock, 5f, -0.5f); var cohesion = new Cohesion(e.bird, flock, 30f, -0.5f); var velMatch = new VelocityMatch(e.bird, flock, 20f, -0.5f); var seek = new Cohesion(e.bird, anchorFlock, float.MaxValue, -1f); // move towards the anchor var flee = new Separation(e.bird, anchorFlock, 10f, -1f); // move towards the anchor separation.aknnApproxVal = 1.0; cohesion.aknnApproxVal = 1.0; velMatch.aknnApproxVal = 25.0; separation.maxNeighborhoodSize = 5; cohesion.maxNeighborhoodSize = 10; velMatch.maxNeighborhoodSize = 5; var obstacleAvoidance = new ObstacleAvoidance(e.bird, 20f, new string[]{"Ground"}); var blended = new BlendedSteering[2]; blended[0] = new BlendedSteering(e.bird, new BehaviorAndWeight(obstacleAvoidance, 1f)); blended[1] = new BlendedSteering(e.bird, new BehaviorAndWeight(separation, 2f), // 0 new BehaviorAndWeight(cohesion, 1f), // 1 new BehaviorAndWeight(velMatch, 0.5f), // 2 new BehaviorAndWeight(seek, 1.25f), // 3 new BehaviorAndWeight(flee, 2f) ); return new PrioritySteering(1f, blended); }
Steering getDefaultSteering(Entry e) { e.bird.maxSpeed = 7.5f; (e.bird as Starling).transform.Find("Sphere").gameObject.SetActive(true); var obstacleAvoidance = new ObstacleAvoidance(e.bird, 20f, new string[]{"Ground"}); var separation = new Separation(e.bird, flock, 5f, 0f); var cohesion = new Cohesion(e.bird, flock, 75f, 0f); cohesion.aknnApproxVal = 25f; cohesion.maxNeighborhoodSize = 15; var velMatch = new VelocityMatch(e.bird, flock, 20f, 0.0f); velMatch.aknnApproxVal = 50f; var bbox = new Bounds(new Vector3(1162, 113, 770), new Vector3(500, 150, 500)); var wander = new SteeringBehaviors.Wander(e.bird, e.bird.maxSpeed, 30f, 50f, bbox); wander.theta = UnityEngine.Random.Range(0f, 360f); var blended = new BlendedSteering[3]; blended[0] = new BlendedSteering(e.bird, new BehaviorAndWeight(obstacleAvoidance, 1f)); blended[1] = new BlendedSteering(e.bird, new BehaviorAndWeight(separation, 1f)); blended[2] = new BlendedSteering(e.bird, new BehaviorAndWeight(wander, 0.85f), // 0 new BehaviorAndWeight(cohesion, 0.90f), new BehaviorAndWeight(velMatch, 0.50f)); return new PrioritySteering(1f, blended); }
Steering getDefaultSteering(Entry e, FormationManager generalManager, Flock flock) { var pattSteering = new PatternSteering(e.bird, generalManager); var separation = new Separation(e.bird, flock, 5.0f, -1f); separation.aknnApproxVal = 1.0; var obstacleAvoidance = new ObstacleAvoidance(e.bird, 20f, new string[]{"Ground"}); var blended = new BlendedSteering[3]; blended[0] = new BlendedSteering(e.bird, new BehaviorAndWeight(obstacleAvoidance, 1f)); blended[1] = new BlendedSteering(e.bird, new BehaviorAndWeight(separation, 1f)); blended[2] = new BlendedSteering(e.bird, new BehaviorAndWeight(pattSteering, 1f)); return new PrioritySteering(1f, blended); }
Steering getDefaultSteering(Entry e, Flock flock) { var separation = new Separation(e.bird, flock, _separationDistance, -0.5f); var cohesion = new Cohesion(e.bird, flock, _cohesionDistance, -0.5f); var velMatch = new VelocityMatch(e.bird, flock, _velocityMatchDistance, -0.5f); var anchorCohesion = new Cohesion(e.bird, anchorFlock, float.MaxValue, -1f); // move towards the anchor var anchorSeparation = new Separation(e.bird, anchorFlock, 25f, -1f); var anchorVelocityMatch = new VelocityMatch(e.bird, anchorFlock, float.MaxValue, -1f); separation.aknnApproxVal = _separationAknnVal; cohesion.aknnApproxVal = _cohesionAknnVal; velMatch.aknnApproxVal = _velocityMatchAknnVal; separation.maxNeighborhoodSize = separationK; cohesion.maxNeighborhoodSize = cohesionK; velMatch.maxNeighborhoodSize = velocityMatchK; var obstacleAvoidance = new ObstacleAvoidance(e.bird, 20f, new string[]{"Ground"}); var blended = new BlendedSteering[2]; blended[0] = new BlendedSteering(e.bird, new BehaviorAndWeight(obstacleAvoidance, 1f)); blended[1] = new BlendedSteering(e.bird, new BehaviorAndWeight(separation, _separationWeight), // 0 new BehaviorAndWeight(cohesion, _cohesionWeight), // 1 new BehaviorAndWeight(velMatch, _velocityMatchWeight), // 2 new BehaviorAndWeight(anchorCohesion, _cohesionToAnchorWeight), // 3 new BehaviorAndWeight(anchorSeparation, _separationFromAnchorWeight), // 4 new BehaviorAndWeight(anchorVelocityMatch, _velMatchToAnchorWeight) // 5 ); return new PrioritySteering(1f, blended); }