public bool KeepPlayerInCameraView(out Vector2 newPos)
    {
        Vector2 playerPosScreen = Camera.main.WorldToScreenPoint(transform.position);
        if (playerPosScreen.x + screenEdgeHorizontal > Mathf.Abs(Screen.width) && (playerPosScreen.y - screenEdgeVertical < 0))
        {
            newPos = Camera.main.ScreenToWorldPoint(new Vector3(Mathf.Abs(Screen.width) - screenEdgeHorizontal, screenEdgeVertical, transform.position.z - Camera.main.transform.position.z));
            return true;
        }
        else if (playerPosScreen.x + screenEdgeHorizontal > Mathf.Abs(Screen.width))
        {
            newPos = Camera.main.ScreenToWorldPoint(new Vector3(Mathf.Abs(Screen.width) - screenEdgeHorizontal, playerPosScreen.y, transform.position.z - Camera.main.transform.position.z));
            return true;
        }
        else if (playerPosScreen.x - screenEdgeHorizontal < 0f && (playerPosScreen.y - screenEdgeVertical < 0))
        {
            newPos = Camera.main.ScreenToWorldPoint(new Vector3(screenEdgeHorizontal, screenEdgeVertical, transform.position.z - Camera.main.transform.position.z));
            return true;
        }
        else if (playerPosScreen.x - screenEdgeHorizontal < 0f)
        {
            newPos = Camera.main.ScreenToWorldPoint(new Vector3(screenEdgeHorizontal, playerPosScreen.y, transform.position.z - Camera.main.transform.position.z));
            return true;
        }
        else if ((playerPosScreen.y - screenEdgeVertical < 0) && (playerPosScreen.x + screenEdgeHorizontal > Mathf.Abs(Screen.width)))
        {
            newPos = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width - screenEdgeHorizontal, screenEdgeVertical, transform.position.z - Camera.main.transform.position.z));
            return true;
        }
        else if ((playerPosScreen.y - screenEdgeVertical < 0) && (playerPosScreen.x - screenEdgeHorizontal < 0f))
        {
            newPos = Camera.main.ScreenToWorldPoint(new Vector3(screenEdgeHorizontal, screenEdgeVertical, transform.position.z - Camera.main.transform.position.z));
            return true;
        }
        else if (playerPosScreen.y - screenEdgeVertical < 0)
        {
            newPos = Camera.main.ScreenToWorldPoint(new Vector3(playerPosScreen.x, screenEdgeVertical, transform.position.z - Camera.main.transform.position.z));
            return true;
        }
        newPos = Vector2.zero;
        return false;
    }