Fixed crash if the player touched the edge of the map.