Lojemiru/Another-Mediocre-2D-Engine

PlayerPool GetClosest and GetClosestOnSide incorrect behaviour

Closed this issue · 1 comments

The GetClosest function uses an incorrect algorithm to calculate the closest player.
Situation:
2 players at equivalent y coordinates, but 1 player is closer on the x coordinate.
Expected result:
Player who is closer on x coordinate gets chosen.
Actual Result:
Arbitrary based on which player is first in the pool.

GetClosestOnSide seems to not take into account y coordinates for left and right sides, and doesn't take into account x coordinates for up and down sides but depending on their intended use case this might not be a bug.

Definitely unintended behavior. Reviewing the methods, the code I wrote for these is exceptionally dumb... should be fixed now, pushing shortly. Thanks for the report!