private void InitializeSecondaryCharacter(DynamicCharacter character, GameObject[] obstacles) { var priority = new PriorityMovement { Character = character.KinematicData }; foreach (var obstacle in obstacles) { var avoidObstacleMovement = new DynamicAvoidObstacle(obstacle) { MaxAcceleration = MAX_ACCELERATION, avoidDistance = AVOID_MARGIN, lookAhead = MAX_LOOK_AHEAD, Character = this.RedCharacter.KinematicData, whiskersLookAhead = WHISKER_LOOK_AHEAD, MovementDebugColor = Color.magenta }; priority.Movements.Add(avoidObstacleMovement); } foreach (var otherCharacter in this.Characters) { if (otherCharacter != character) { //TODO: add your avoidCharacter movement here var avoidCharacter = new DynamicAvoidCharacter(otherCharacter.KinematicData) { Character = character.KinematicData, MaxAcceleration = MAX_ACCELERATION, AvoidMargin = AVOID_MARGIN, MaximumTimeLookAhead = MAX_TIME_AHEAD, MovementDebugColor = Color.cyan }; priority.Movements.Add(avoidCharacter); } } var straightAhead = new DynamicStraightAhead { Character = character.KinematicData, MaxAcceleration = MAX_ACCELERATION, MovementDebugColor = Color.yellow }; priority.Movements.Add(straightAhead); character.Movement = priority; }
private void InitializeMainCharacter(GameObject[] obstacles) { this.Priority = new PriorityMovement { Character = this.RedCharacter.KinematicData }; this.Blended = new BlendedMovement { Character = this.RedCharacter.KinematicData }; foreach (var obstacle in obstacles) { //TODO: add your AvoidObstacle movement here DynamicAvoidObstacle avoidObstacleMovement = new DynamicAvoidObstacle(obstacle) { MaxAcceleration = MAX_ACCELERATION, AvoidMargin = AVOID_MARGIN, MaxLookAhead = MAX_LOOK_AHEAD, WhiskerLookAhead = WHISKER_LOOK_AHEAD, Character = this.RedCharacter.KinematicData, whiskersLookAhead = WHISKER_LOOK_AHEAD, MovementDebugColor = Color.magenta }; this.Blended.Movements.Add(new MovementWithWeight(avoidObstacleMovement, obstacles.Length + this.Characters.Count)); this.Priority.Movements.Add(avoidObstacleMovement); } foreach (var otherCharacter in this.Characters) { if (otherCharacter != this.RedCharacter) { var avoidCharacter = new DynamicAvoidCharacter(otherCharacter.KinematicData) { Character = this.RedCharacter.KinematicData, MaxAcceleration = MAX_ACCELERATION, MaximumTimeLookAhead = MAX_TIME_AHEAD, MovementDebugColor = Color.cyan }; this.Priority.Movements.Add(avoidCharacter); } } /* * TODO: add your wander behaviour here! */ var wander = new DynamicWander { Character = this.RedCharacter.KinematicData, MaxAcceleration = MAX_ACCELERATION, MovementDebugColor = Color.yellow }; this.Priority.Movements.Add(wander); this.Blended.Movements.Add(new MovementWithWeight(wander,5.0f)); this.RedCharacter.Movement = this.Blended; }
private void InitializeMainCharacter(GameObject[] obstacles) { this.Priority = new PriorityMovement { Character = this.RedCharacter.KinematicData }; this.Blended = new BlendedMovement { Character = this.RedCharacter.KinematicData }; foreach (var obstacle in obstacles) { DynamicAvoidObstacle avoidObstacleMovement = new DynamicAvoidObstacle (obstacle, true) { MaxAcceleration = MAX_ACCELERATION, AvoidMargin = AVOID_MARGIN, MaxLookAhead = MAX_LOOK_AHEAD, Character = this.RedCharacter.KinematicData, MaxWhiskersLookAhead = 5f, WhiskersAngle = MathConstants.MATH_PI_4 * 0.75f, MovementDebugColor = Color.magenta }; this.Blended.Movements.Add (new MovementWithWeight (avoidObstacleMovement, 5.0f)); this.Priority.Movements.Add (avoidObstacleMovement); } foreach (var otherCharacter in this.Characters) { if (otherCharacter != this.RedCharacter) { var avoidCharacter = new DynamicAvoidCharacter (otherCharacter.KinematicData) { Character = this.RedCharacter.KinematicData, MaxAcceleration = MAX_ACCELERATION, AvoidMargin = AVOID_MARGIN, MaxTimeLookAhead = MAX_TIME_LOOK_AHEAD, MovementDebugColor = Color.cyan }; this.Priority.Movements.Add (avoidCharacter); } } var wander = new DynamicWander { MaxAcceleration = MAX_ACCELERATION, Character = this.RedCharacter.KinematicData, MovementDebugColor = Color.yellow }; this.Priority.Movements.Add (wander); this.Blended.Movements.Add (new MovementWithWeight (wander, obstacles.Length + this.Characters.Count)); this.RedCharacter.Movement = this.Blended; }