Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Screen Resolution

Discussion in 'Editor & General Support' started by Bharat_, Jan 15, 2018.

  1. Bharat_

    Bharat_

    Joined:
    Jan 15, 2018
    Posts:
    14
    How To Setup a game for All Resolutions??? ( not the UI elements)....
     
  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,751
    I'm... not exactly sure what you're asking here. What do you mean?
     
    Bharat_ likes this.
  3. Bharat_

    Bharat_

    Joined:
    Jan 15, 2018
    Posts:
    14
    I have a colliders surrounding the main camera to restrict the play area . Resolution I used is 16 : 9 . But when i changed it to 4 : 3 the colliders are way too away for abvious reason .... So I just wanted to know is it possible to build a game for each resolution.. Script would fix the collider issue but other problems would exist. SO IS THERE ANY SOLUTION .....PLS HELP ANY ASSISTANCE IS APPRECIATED !!!
    THANK U IN ADVANCE FOR SUGGESTIONS....
     
  4. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,605
    To do this, you can use the screen coords to make sure the player doesn't exit them. No colliders needed

    Code (CSharp):
    1. void Update() {
    2.       //declare a temporary variable that holds the current position
    3.       Vector3 playerPos = transform.position;
    4.  
    5.       //clamp the temporary variable's x value
    6.       playerPos.x = Mathf.Clamp(-300,300);
    7.  
    8.       //assign the complete temp variable back to the transform
    9.       transform.position = playerPos;
    10. }
    Along with

    https://docs.unity3d.com/ScriptReference/Camera.WorldToScreenPoint.html
     
  5. Bharat_

    Bharat_

    Joined:
    Jan 15, 2018
    Posts:
    14
    Thanks mate ,
    But what if am designing a level with particular transform.position for a object , The position would actually change
    in other resolutions..
    Do I need a different builds for every resolution ?
    I am newbie in those stuffs...(pls bare me)
    Correct me if I am wrong
    thanks