Function to get the entity closest to a player's line of sight