i started working on developing games one month ago. I really like it, although it isnt easy.

The problem i have now, is with display resolution after i build game. So far i have been working with 2D Space Shooter game (getting help from the tutorial), everything is working smoothly. The only thing that i hardly understand is the resolution, aspect ratio thing. I have made a game that looks like this: enter image description here

I have drawn a gizmos around the allien formation, and written a script with some calculations that everytime formation hits the edge, it goes to the other edge, hits the other edge, and goes to the other edge, and so on and on. In the free aspect movement looks great, but however, then i change the resolution to any other, movement is stuck, or it barely moves. enter image description here

Now here is my question. What should i do, to make the game look and work smoothly on every resolution like it works on the free aspect display? I tried to change formation height and width and so on, but i assume this is not an option. I will add my formation controller script as well(it contains several other things so i printscreened only the code that helps formation to move):

Thank you for your time, and sorry if you can't understand everything or something is unclear to you, i'm beginner at game development and English is not my first language.


2 Answers 2


Shoot-em-ups are a genre where the gameplay is heavily affected by the horizontal and vertical size of the screen. There is a reason why the genre had its apex in the era of home consoles and arcade machines where the developers knew exactly what screen resolution they were targeting.

If you want to have the genre on modern PCs, there are several options, but neither is really satisfying.

  • Decide to only allow your game to be played in a window with a fixed size or in fullscreen mode with a fixed screen resolution (Unity allows you to do that in the build settings)
  • Change your camera size to stretch the playing field to fit the users screen. But the change to the aspect ration might look weird, and when you use 2d assets they will get blurry.
  • Simply accept that your game will play differently with different screen resolutions and design the gameplay with that in mind.

Something come from script must be repaired with script, so also resolution. Something come from size must be repaired with size, this means you must use script to reorder the object location and resize your object based in the resolution.


I have a portable script ( not affecting other script ) that will make you understand easier (but the script still have weakness though, as you'll find out later), and in the script you must scale your object one by one, here is the script:


The How-To-Use The Script Is Explained In The Script 


using UnityEngine;
using System.Collections;

/* change mainmenuresolution with your class name */         

public class mainmenuresolution : MonoBehaviour {

    void CalculateResolution(string ObjectName) {

        /*change desiredWidth to width resolution you use when making the game*/

        float desiredWidth = 1366;

        /*change desiredHeight to height resolution you use when making the game*/

        float desiredHeight = 768;

        float currentWidth = Screen.width;
        float currentHeight = Screen.height;
        GameObject TheObject = GameObject.Find (ObjectName);
        float currentObjectPositionX = TheObject.transform.position.x;
        float currentObjectPositionY = TheObject.transform.position.y;
        float currentObjectPositionZ = TheObject.transform.position.z;
        float currentObjectSizeX = TheObject.transform.localScale.x;
        float currentObjectSizeY = TheObject.transform.localScale.y;
        float currentObjectSizeZ = TheObject.transform.localScale.z;
        float newObjectPositionX = (currentWidth / desiredWidth) * currentObjectPositionX;
        float newObjectPositionY = (currentWidth / desiredWidth) * currentObjectPositionY;

        /* if you want your object coordinate "z" scaled too , use : (currentWidth / desiredWidth) * currentObjectPositionZ */

        float newObjectPositionZ = currentObjectPositionZ;

        float newObjectSizeX = (currentWidth / desiredWidth) * currentObjectSizeX;
        float NewObjectSizeY = (currentWidth / desiredWidth) * currentObjectSizeY;

        /* if you want your object size "z" scaled too , change to : (currentWidth / desiredWidth) * currentObjectSizeZ */

        float NewObjectSizeZ = currentObjectSizeZ;

        // moving to new coord
        TheObject.transform.position = new Vector3(newObjectPositionX,newObjectPositionY,newObjectPositionZ);
        // resizing object
        TheObject.transform.localScale = new Vector3(newObjectSizeX,NewObjectSizeY,NewObjectSizeZ);

    // Use this for initialization
    void Start () {

        /* change " Your Object Name " To The Name Of Your GameObject */

        CalculateResolution ("YourObjectName");


    // Update is called once per frame
    void Update () {

  • \$\begingroup\$ Thank you very much! Will try it out at the weekend then i will dive in back to my project. Cheers! \$\endgroup\$ Nov 8, 2016 at 19:11
  • \$\begingroup\$ no prob :) because sharing is caring :) \$\endgroup\$ Nov 9, 2016 at 9:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .