private BlendedMovement GenerateBlendingMovementFor(DynamicCharacter character) { var blending = new BlendedMovement { MaxAcceleration = this.MaximumAcceleration, Character = character.KinematicData }; var cohesion = new DynamicCohesion(this) { Character = character.KinematicData, MaxAcceleration = this.MaximumAcceleration, MaxSpeed = this.MaximumSpeed, FlockRadius = this.FlockRadius, MovementDebugColor = Color.yellow }; var separation = new DynamicSeparation(this) { Character = character.KinematicData, MaxAcceleration = this.MaximumAcceleration, FlockRadius = this.FlockRadius, SeparationFactor = this.SeparationFactor, MovementDebugColor = Color.red }; var velocityMatch = new DynamicFlockVelocityMatching(this) { Character = character.KinematicData, MaxAcceleration = this.MaximumAcceleration, FlockRadius = this.FlockRadius, MovementDebugColor = Color.green }; var collisionDetection = new PriorityMovement { Character = character.KinematicData, MovementDebugColor = Color.magenta }; foreach (var obstacle in this.Obstacles) { var avoidMovement = new DynamicAvoidObstacle(obstacle) { MaxAcceleration = this.MaximumAcceleration, AvoidMargin = 4.0f, MaxLookAhead = 10.0f, }; collisionDetection.Movements.Add(avoidMovement); } var flockSeek = new DynamicFlockTarget(this) { Character = character.KinematicData, MaxAcceleration = this.MaximumAcceleration, MovementDebugColor = Color.cyan }; blending.Movements.Add(new MovementWithWeight(cohesion)); blending.Movements.Add(new MovementWithWeight(separation,2.0f)); blending.Movements.Add(new MovementWithWeight(velocityMatch)); blending.Movements.Add(new MovementWithWeight(collisionDetection,1000.0f)); blending.Movements.Add(new MovementWithWeight(flockSeek)); return blending; }
private BlendedMovement GenerateBlendingMovementFor(DynamicCharacter character) { var blending = new BlendedMovement { MaxAcceleration = this.MaximumAcceleration, Character = character.KinematicData }; var cohesion = new DynamicCohesion(this) { Character = character.KinematicData, MaxAcceleration = this.MaximumAcceleration, MaxSpeed = this.MaximumSpeed, FlockRadius = this.FlockRadius, MovementDebugColor = Color.yellow }; var separation = new DynamicSeparation(this) { Character = character.KinematicData, MaxAcceleration = this.MaximumAcceleration, FlockRadius = this.FlockRadius, SeparationFactor = this.SeparationFactor, MovementDebugColor = Color.red }; var velocityMatch = new DynamicFlockVelocityMatching(this) { Character = character.KinematicData, MaxAcceleration = this.MaximumAcceleration, FlockRadius = this.FlockRadius, MovementDebugColor = Color.green }; var collisionDetection = new PriorityMovement { Character = character.KinematicData, MovementDebugColor = Color.magenta }; foreach (var obstacle in this.Obstacles) { var avoidMovement = new DynamicAvoidObstacle(obstacle) { MaxAcceleration = this.MaximumAcceleration, AvoidMargin = 4.0f, MaxLookAhead = 10.0f, }; collisionDetection.Movements.Add(avoidMovement); } var flockSeek = new DynamicFlockTarget(this) { Character = character.KinematicData, MaxAcceleration = this.MaximumAcceleration, MovementDebugColor = Color.cyan }; blending.Movements.Add(new MovementWithWeight(cohesion)); blending.Movements.Add(new MovementWithWeight(separation, 2.0f)); blending.Movements.Add(new MovementWithWeight(velocityMatch)); blending.Movements.Add(new MovementWithWeight(collisionDetection, 1000.0f)); blending.Movements.Add(new MovementWithWeight(flockSeek)); return(blending); }