|
|
@ -70,7 +70,8 @@ namespace Game { |
|
|
|
|
|
|
|
|
|
|
|
// TODO solution for balls outside of border |
|
|
|
// TODO solution for balls outside of border |
|
|
|
// TODO Also must include fact that players have a height, maybe check the incoming angle |
|
|
|
// TODO Also must include fact that players have a height, maybe check the incoming angle |
|
|
|
private bool IsPositionReachableInTime(float futurePosition, float seconds) { |
|
|
|
// angle: 0 -> perpendicular, from -90 to 90 |
|
|
|
|
|
|
|
private bool IsPositionReachableInTime(float futurePosition, float seconds, float angle) { |
|
|
|
float requiredDistance = Mathf.Abs(futurePosition - X()) - Width / 2; |
|
|
|
float requiredDistance = Mathf.Abs(futurePosition - X()) - Width / 2; |
|
|
|
if (requiredDistance < 0) |
|
|
|
if (requiredDistance < 0) |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -97,7 +98,7 @@ namespace Game { |
|
|
|
// Horizontal line (player line) -> stop simulating |
|
|
|
// Horizontal line (player line) -> stop simulating |
|
|
|
if (Intersect(origin, end, playerLeft, playerRight, out Vector2 point, out Vector2 rs)) { |
|
|
|
if (Intersect(origin, end, playerLeft, playerRight, out Vector2 point, out Vector2 rs)) { |
|
|
|
secondsUsed += secondsLeft * rs.x; |
|
|
|
secondsUsed += secondsLeft * rs.x; |
|
|
|
if (!IsPositionReachableInTime(point.x, secondsUsed)) |
|
|
|
if (!IsPositionReachableInTime(point.x, secondsUsed, Vector2.Angle(velocity, transform.up))) |
|
|
|
impossible = true; |
|
|
|
impossible = true; |
|
|
|
return point.x; |
|
|
|
return point.x; |
|
|
|
} |
|
|
|
} |
|
|
|