3 Comments for this entry

  • Rafael

    Very good post! 🙂

  • Soviet Bear

    I have two issues with this script. 1. to get the correct margin on the right, I had to take out the /2 from the else if statement:
    else if (playerPosScreen.x > Screen.width / 2 – screenX)
    {
    transform.position = Camera.main.ScreenToWorldPoint(new Vector3(
    Screen.width / 2 – screenX,
    playerPosScreen.y,
    playerPosScreen.z));
    }

    Secondly, If you got to the side margin, keep pressing into it, and go down/up, you can get passed the bottom and top margin, I can’t figure out how to fix this, I’ll look at the code more, if I figure it out, I’ll post the code here.

  • aeonphyxius

    I actually improved more this code to work with different screen aspect ratios (sometimes we use a black line on the left & right margins).

    Will try to post an updated version of this code.

Leave a Reply