Resizing non-UI GameObject to fit screen

For my first unity project, I’m trying to re-make doodle jump because well, you gotta start somewhere you know.

Everything was working fine until I decided to adapt my game for different screen size / ratio.

I wanted to make something by myself first, so I code some not that bad little script, problem is, when I change the scale of my object, some things doesn’t work anymore. So I try to see what the people before me have done.

Before you read the following text, if you know a way to resize gameObject (with spriteRenderer, rigidbody and stuff, I mean, not UI element), you can just send me the link of the forum / video / tutorial you have. In the text below I’m just detailing this problem and explaining it to people so they can help me find a solution. Thanks :slight_smile:

!! I’m working with an orthographic camera !!

I made some research on the internet, I found a LOT of different video about resizing canvas with UI elements inside, so I adapted it and right now it work like I want it to work. (with anchor and resizing).

Just so we have the same definition of UI element, some of mine are for examples buttons or score.

Here is my architecture at the moment :

- CanvaGeneral 
     - CanvaGame (son of canvaGeneral)
          - pauseButton (son of canvaGame)
          - scoreText (son of canvaGame)

And inside of CanvaGeneral is a CanvaScaler Component :

- UI Scale mode : Scale With Screen Size
- Reference resolution X 1080 Y 1920 (that's the resolution I'm working on)
- Screen Match Mode "Match Width Or Height" (I also tried with expand but nothing seems to work) 
- Match "Width" (so 0)
- Reference pixels per unit 100

So, when I resize the screen, from 1920*1080 (16:9 ratio) to other 16:9 ratio, everything is alright.

Then, I decided to add my gameObject, so, my character and some platforms.

I made some research about how resizing gameObject and I found this answer :

I obviously tried it, well, I couldn’t make it work.

I found nothing good on YouTube neither the internet in general, maybe I make my research with bad keywords but anyway, I’m stuck here.

Here is my file order right now :

- CanvaGeneral 
     - CanvaGame (son of canvaGeneral)
          - pauseButton (son of canvaGame)
          - scoreText (son of canvaGame)
      - AllObject (with rect transform and canvas renderer)
           - testImage (which is a white square that appear on the Game Screen)
           - testEggs (which is a gameObject with rectTransform and a spriteRenderer)

For a reason that I don’t understand, I can see “testImage” on the gameScreen and I cannot see “testEggs”, their x, y and z position are equivalent, same for their size.

So maybe this technique is not the good one to do, maybe it is, can someone enlighten me on how to resize gameObject for different ratio ? is there a technique that I didn’t thought of or anything ?

Remember, it’s my first project, so maybe I skipped something so easy that everyone knows it but well, I can’t find any kind of working solution.

Thanks in advance for your help !

Well I have to admit, maybe I went a little too far on this one.

I found a really simple solution, changing the size of the orthographic camera.

I just have to do a cross proof calculus and it’s done haha.