/// <summary> /// This behavior creates a force that steers the agent towards the // ball /// </summary> /// <param name="ball"></param> /// <returns></returns> protected Vector2D calculatePursuitVector(SoccerBall ball) { Vector2D toBall = ball.Position - _player.Position; //the lookahead time is proportional to the distance between the ball //and the pursuer; double lookAheadTime = 0.0; if (Math.Abs(ball.Speed) > Geometry.MinPrecision) { lookAheadTime = toBall.Length / ball.Speed; } //calculate where the ball will be at this time in the future _target = ball.CalculateFuturePosition(lookAheadTime); //now seek to the predicted future position of the ball return(calculateArriveVector(_target, DecelerationState.Fast)); }
/// <summary> /// This behavior creates a force that steers the agent towards the // ball /// </summary> /// <param name="ball"></param> /// <returns></returns> protected Vector2D calculatePursuitVector(SoccerBall ball) { Vector2D toBall = ball.Position - _player.Position; //the lookahead time is proportional to the distance between the ball //and the pursuer; double lookAheadTime = 0.0; if (Math.Abs(ball.Speed) > Geometry.MinPrecision) { lookAheadTime = toBall.Length / ball.Speed; } //calculate where the ball will be at this time in the future _target = ball.CalculateFuturePosition(lookAheadTime); //now seek to the predicted future position of the ball return calculateArriveVector(_target, DecelerationState.Fast); }