Understanding Orthographic Size in Unity

Поделиться
HTML-код
  • Опубликовано: 11 ноя 2024

Комментарии • 148

  • @pressstart6864
    @pressstart6864  5 лет назад +13

    Copy & Paste Source Code: pressstart.vip/tutorials/2018/06/14/37/understanding-orthographic-size.html

    • @JD3DGAMER
      @JD3DGAMER 5 лет назад

      for 9:19 Aspect Ratio, it is not working

    • @mopto7833
      @mopto7833 3 года назад

      Hi
      What resolution of rink you had? My rink is cropping on top and bottom
      My resolution is 1242x2208 (WxH)

    • @brayanlucca7437
      @brayanlucca7437 3 года назад

      I dont mean to be so offtopic but does anyone know a trick to get back into an instagram account??
      I was stupid forgot the password. I appreciate any tips you can give me.

    • @axelaldo4363
      @axelaldo4363 3 года назад

      @Brayan Lucca instablaster ;)

    • @brayanlucca7437
      @brayanlucca7437 3 года назад

      @Axel Aldo i really appreciate your reply. I found the site on google and I'm in the hacking process now.
      Seems to take a while so I will reply here later with my results.

  • @tikebkaatar
    @tikebkaatar 4 года назад +37

    Thank you, this is the first video that actually addresses the problem and most scenarios to do with aspect ratio

    • @willh69
      @willh69 4 года назад

      I'm pretty new to C# coding, super grateful that we have resources like this for free on the internet. It all seems so complicated but when you break it down logically like this it all makes sense
      Thanks Press Start

  • @mivuh
    @mivuh 2 года назад +3

    That was by far the most efficient way to solve my problem with my first game.
    That was the last part i was missing, thank you so much.

  • @christianschuster4171
    @christianschuster4171 5 лет назад +26

    Fantastic! This is the best explanation I’ve seen so far. The examples help a lot.
    Thank you for putting in the effort!

    • @fenix3752
      @fenix3752 4 года назад +1

      What is the rink?

    • @DracoGrim
      @DracoGrim 4 года назад

      @@fenix3752 RInk is the image/sprite he uses, which is a hockey field (ring/rink)

    • @fenix3752
      @fenix3752 4 года назад

      @@DracoGrim thanks man

  • @thesolitaryowl
    @thesolitaryowl 3 года назад

    Wow. This is the first video that actually explains this problem really well. I've been searching for an hour trying to solve this issue.

  • @alexlik4197
    @alexlik4197 Год назад

    Thank you so much! You have no idea how long I've been looking for something like this! Even though this video is 4 years old at this point, it helped me a ton!

  • @mitul1294
    @mitul1294 3 года назад

    Thank you for explaining one of the major and common problem in such a simplistic manner

  • @javierfernandez6030
    @javierfernandez6030 2 года назад

    This is the best explanation I've found so far.. crazy it was made 4 years ago! Thanks a lot!

  • @DanielLeightonArt
    @DanielLeightonArt 10 месяцев назад

    This and your edge collider hack video really helped solve a problem that had me stuck. Thank you!

  • @Aereton
    @Aereton 2 года назад

    You've helped me understand how camera sizes and screen resolutions work together. Thank you so much, great video short and concise!

  • @jakubneska1694
    @jakubneska1694 3 года назад

    Thanks a lot! I struggled for a while trying to find something explaining how orthographic size relates to objects positioning! And your video explained everything perfectly! Couldn't do minimap for my game without it!

  • @Ghatos
    @Ghatos 3 года назад +1

    My god, THANK YOU!
    I've been trying to code something simillar and your video made me realise why Screen.width / Screen.height was giving me back the wrong values, I had to write it like this:
    *(float)* Screen.width / *(float)* Screen.height
    Thank you a lot for this video, that issue was driving me nuts.

  • @GrosssDude
    @GrosssDude 3 года назад

    Absolutely amazing. I have spent HOURS trying to figure this out. Thank you, thank you, thank you.

  • @wimbo_learn_music
    @wimbo_learn_music 2 года назад

    Exactly what I needed. Perfectly explained. Thanks!

  • @skiesquiggles7319
    @skiesquiggles7319 5 лет назад +3

    Literally exactly what I needed, many thanks to you, friend!

  • @MadOliveGaming
    @MadOliveGaming 10 месяцев назад

    I was very confused why this worked for everyone but me. Guess what... my script was not check marked so it was disabled all the time xD. Great video, i have a phone with a weird resolution so i needed this to be able to play my own game lmao

  • @pedroduran8927
    @pedroduran8927 2 года назад

    I have to thank you very much for this simple and effective solution!
    it worked great for me for my board game with both Phone and Tablet support!

  • @FortbloxNET
    @FortbloxNET 2 года назад

    this is exactly what i was searching for, for years. thank you!!!!!!!!!!!!!!!!!!!!!

  • @denn501
    @denn501 Год назад

    TYSM!! This is exactly what I was looking for!!!

  • @mmdjn
    @mmdjn 2 года назад

    Thank you for explaining and example

  • @alleyesonme1432
    @alleyesonme1432 4 года назад +1

    Good Job! Nice explanations suited for beginners. Waiting for next videos, subscribed!
    BTW, what is rink?)

  • @lathspell2885
    @lathspell2885 3 года назад

    Thanks, I haven't tried it yet but I'm sure it will work. You explained it very well.

  • @murlocsenpai9727
    @murlocsenpai9727 3 года назад

    Very well explained, thanks for the video.

  • @alexbukin982
    @alexbukin982 5 лет назад +2

    Thank you very much! Video and sound is awesome, speech is great and it is easy to understand you! Even I am from Russia I did it and it works, thanks again!

  • @xliquid1400
    @xliquid1400 4 года назад +1

    Damn u are so so helpful, you are truly underrated

  • @GurmeetSingh-ui8fd
    @GurmeetSingh-ui8fd 3 года назад +2

    Hello, good tutorial but what if you are not using spriteRenderer but instead the game object? i created a plane out of the game object and i want to fit the camera to the game object x and y axis. I tried modifying your code where instead of the sprite renderer, i used the transform of the plane where it calculates the x axis and the z axis but still does not work. Do you have any idea for this?

  • @IndeedJoe
    @IndeedJoe 5 лет назад +2

    Great tutorial man!

  • @mikulashoblik8039
    @mikulashoblik8039 4 года назад +1

    Thank you very much for this solution. It worked really well for me :)

  • @sparttenomega45
    @sparttenomega45 4 года назад

    This worked for me. Thanks!

  • @inori5138
    @inori5138 5 лет назад

    It workeddddddd... I was looking for 1 month oooooloohohhohohohh...

  • @dand4604
    @dand4604 5 лет назад +11

    How are you so calm? I'm struggling to keep my brain from revving to 12k rpm. Don't know what it's like to be normal anymore

  • @kebalbadal4224
    @kebalbadal4224 3 года назад

    Fantastic bro
    Helped a lot
    Thank you bro

  • @therightpic
    @therightpic 4 года назад

    Excellent explanation. I have been trying to figure out these kinds of things for a long time and you do a great job on your videos. Are you still making videos? It doesn't seem like you have anything for a while.

  • @LuyoYoo
    @LuyoYoo 5 лет назад +1

    This was so useful! Thank you!

  • @raingame_
    @raingame_ 5 лет назад +3

    Thanks! U got my subscription!

  • @intrer8601
    @intrer8601 4 года назад

    Thanks! This was exactly what I was looking for!

    • @fenix3752
      @fenix3752 4 года назад

      What is the rink

    • @intrer8601
      @intrer8601 4 года назад +2

      @@fenix3752 What do you mean?

    • @fenix3752
      @fenix3752 4 года назад

      @@intrer8601 what is the rink thing he is using in the tut

    • @intrer8601
      @intrer8601 4 года назад

      @@fenix3752 Oh, I used it for my own project, I didn't use the rink thing in the tutorial.

    • @fenix3752
      @fenix3752 4 года назад

      @@intrer8601 than what did you used plz tell me help needed

  • @violentgamer5910
    @violentgamer5910 4 года назад +1

    Thank you for this Great Tutorial I really Liked it!!

  • @greggiles8725
    @greggiles8725 6 лет назад +1

    This tutorial is
    🔥
    🔥
    🔥
    🔥

  • @ShironatsuKun
    @ShironatsuKun Год назад

    Wow I've been looking for a solution for this issue for weeks. I was using Cinemachine's TargetGroup Camera to replicate this behavior but the TargetGroup feature doesn't work with the PlayerMovement Claming that I'm using so this simple method saved me.

  • @Me-jy6cd
    @Me-jy6cd Год назад

    Great tutorial! After a long search finally a good explanation. Does the formula for calculating the orthographic size have a general mathematical reference or name?

  • @xkyfal18
    @xkyfal18 5 лет назад +2

    Good job, it helped a lot, thanks for posting ;)

  • @olegfrolovdesign
    @olegfrolovdesign 6 лет назад +2

    Well explained 👌

  • @ВладимирИванов-ы5щ
    @ВладимирИванов-ы5щ 3 месяца назад

    Man, you are best!

  •  2 года назад

    You are a legend!

  • @АлександрЕрёменко-е5б

    Thanks for the video, it helped a lot!

  • @hyperactiveguy3583
    @hyperactiveguy3583 Год назад

    Thanks, it helped me a lot!

  • @franchisethebull
    @franchisethebull 2 года назад

    Brilliant dude

  • @NiclasGleesborg0
    @NiclasGleesborg0 5 лет назад +1

    Great explanation :)

  • @ShacharOz
    @ShacharOz 3 года назад

    wonderful stuff!
    thanks a lot.
    have any idea how to do the Fit to Fill? so there will be no black borders from either portrait or landscape?

  • @Ashkan-yf8eu
    @Ashkan-yf8eu 2 года назад

    Thank you!

  • @amazinggamers356
    @amazinggamers356 Год назад

    Great Work

  • @kevinkoolen
    @kevinkoolen Год назад

    Legend video

  • @sudeepacharya1492
    @sudeepacharya1492 2 года назад

    Hi, thank you for the tutorial.
    But this doesn't work when the orthographics camera is rotated 90 on x-axis.
    Please help! ANd also please make tutorial for Perspective view as well!

  • @matronator
    @matronator 2 года назад

    Amazing video! After searching so many tutorials, this is finally the one that actually does what I want! Thank you!
    One question though:
    Now it scales based on the screen size only. But on devices like iPhone X that have the weird display with the cut out and round corners it's not really desired. Is there some way to make it scale not to screen size, but the safe area of the screen only?

  • @sumitcutevil9260
    @sumitcutevil9260 2 года назад

    this video is a life saver tysm....

  • @carlososuna1194
    @carlososuna1194 4 года назад

    you're the best, excellent bro!!

  • @risingdagger5416
    @risingdagger5416 4 года назад

    thx u made it so ez now

  • @xamretssam
    @xamretssam 4 года назад

    Thanks, very helpful!!!

  • @PeterMilko
    @PeterMilko 4 года назад

    For virtual cameras, public CinemachineVirtualCamera CinemachineVirtualCamera;
    public SpriteRenderer ScreenSizeSprite;
    void Start()
    {
    float orthagraphicSize = ScreenSizeSprite.bounds.size.x *Screen.height / Screen.width *0.5f;
    CinemachineVirtualCamera.m_Lens.OrthographicSize = orthagraphicSize;
    }

    • @lI-tm4qx
      @lI-tm4qx 2 года назад

      Hello , Peter
      I think this is exactly what I'm looking for. I'm using cinemachine virtual camera on my game and I cant get it to work properly, here's my script attached to my main camera
      public SpriteRenderer screenAdapt;
      public CinemachineVirtualCamera CinemachineVirtualCamera;
      void Start()
      {
      float screenRatio = (float)Screen.width / (float)Screen.height;
      float targetRatio = screenAdapt.bounds.size.x / screenAdapt.bounds.size.y;
      CinemachineVirtualCamera.m_Lens.OrthographicSize = targetRatio;
      if (screenRatio >= targetRatio)
      {
      Camera.main.orthographicSize = screenAdapt.bounds.size.y / 2;
      }
      else
      {
      float differenceInSize = targetRatio / screenRatio;
      Camera.main.orthographicSize = screenAdapt.bounds.size.y / 2 * differenceInSize;
      }
      }

    • @PeterMilko
      @PeterMilko 2 года назад

      @@lI-tm4qx You didn't set it up right. Watch a tutorial.

  • @rmajumdar82
    @rmajumdar82 3 года назад

    Thanks a lot!

  • @zeebigz2498
    @zeebigz2498 5 лет назад +1

    how do you fit both width and height of the playground edge to the screen size at same time. you have shown weight and height edge fit on screen edge . but how to you do at same time???

    • @pressstart6864
      @pressstart6864  5 лет назад +1

      Unfortunately that's not how screen's work. It would be impossible to factor in all screen aspect ratios to have a screen fit both height and width of an object. You could instead alter your object to fit the width and height of the screen, but that's a whole different video.

  • @danieljayne8623
    @danieljayne8623 4 года назад

    You sir have saved my ass in LD 47 :D

  • @Ferenc-Racz
    @Ferenc-Racz 10 месяцев назад

    Huge thank you! :)

  • @mahmoudshaddad7411
    @mahmoudshaddad7411 2 года назад

    thank you

  • @gaborbocskai5420
    @gaborbocskai5420 3 года назад

    Super helpful!!!

  • @서리-v3f
    @서리-v3f 5 лет назад

    thanks for the video, very helpful !! :D

  • @sanketjadhav9981
    @sanketjadhav9981 3 года назад

    how cam we do this for perspective camera?

  • @diegosuarez5473
    @diegosuarez5473 5 лет назад +2

    your amaziiiiing Brooooo! i am new suscriber!! Thanks!!!!!!!!!!!!!!

  • @kieranpont7899
    @kieranpont7899 4 года назад

    Life saver.

  • @mananmehta2320
    @mananmehta2320 4 года назад

    What if I'm not have sprite background, instead a skybox colour???

  • @et9277
    @et9277 4 года назад

    Thank you thank you thank you!

  • @hiepuc6315
    @hiepuc6315 4 года назад

    thank you so much

  • @microexpresionblog
    @microexpresionblog 4 года назад

    Thanks so much man!!!

  • @emilkronholm6246
    @emilkronholm6246 5 лет назад +2

    10/10 thank u! :D

  • @mohansaiteki8012
    @mohansaiteki8012 4 года назад

    Your charm mate

  • @keremaslan1988
    @keremaslan1988 4 года назад

    what should i use instead of rink since my game is more like a normal game

  • @serpaolo7413
    @serpaolo7413 4 года назад

    Does this work for Platformer games (Mario Style) where the character is constantly moving and the camera must follow him?

  • @plasmapig1356
    @plasmapig1356 3 года назад

    Is there a way to make the view orthographic on one axis and perspective on another so if you move closer and further away, things would only get bigger/smaller on one axis? I’m talking about 3D not 2D games.

  • @sudarshan4433
    @sudarshan4433 5 лет назад

    Very helpful.
    can we use same with canvas?
    i have problem when screen resolution changes my sprite images which are not part of canvas are get cut off.

  • @watercat1248
    @watercat1248 Год назад

    Cool what happened if do that in not orthographic camer ?

  • @EremesNG
    @EremesNG 4 года назад

    Ty a lot bro

  • @Origined
    @Origined 4 года назад

    How to get rink???

  • @gabrielulate1212
    @gabrielulate1212 4 года назад

    THANK YOU SO MUCH!!!!!

  • @MagotizilaBr
    @MagotizilaBr 5 лет назад +2

    Hey guys how do i set a start camera position, i'm making a 2d game and i want the camera to stay in the left border where start the game but if the user changes the resolution the camera goes further and swallow a little piece of the scene what should i do to fix this?
    How do i make the camera stay in the start left border without swallow in it?

    • @pressstart6864
      @pressstart6864  5 лет назад +1

      If you know where the edge of your game is, just set the cameras position to the position of the edge plus half screen width.

    • @MagotizilaBr
      @MagotizilaBr 5 лет назад +2

      @@pressstart6864 ooh thanks man it worked ;) thanks for helping me from the bottom of my heart ;)

    • @EnderElectrics
      @EnderElectrics 4 года назад

      @@pressstart6864 I tried that. What if it doesn't work?

  • @random_precision_software
    @random_precision_software 5 лет назад

    I'm looking for how to have different screen aspects for different scenes. It seems of you have landscape on the menu scene it does that for all other scene..where I want portrait. How world I do this?

  • @bhushanrocks412
    @bhushanrocks412 5 лет назад +1

    thanks

  • @robbeldevelopmentstudio9888
    @robbeldevelopmentstudio9888 5 лет назад

    Thanks!

  • @flakylyte4811
    @flakylyte4811 6 лет назад +1

    Hey, nice video!!

  • @mauricepickartz797
    @mauricepickartz797 4 года назад

    what does the "rink" is?

  • @ayoubnachit145
    @ayoubnachit145 4 года назад

    What is Rink

  • @christinedelire3974
    @christinedelire3974 2 года назад

    So what is Rink actually ?

  • @user-pw5do6tu7i
    @user-pw5do6tu7i 4 года назад

    Make sure to tag the camera as "MainCamera" otherwise you get a nullObject refference

  • @MuhammadZeeshan-gm3uq
    @MuhammadZeeshan-gm3uq 4 года назад

    what about UI canvas image can we set the camera size according to UI image on canvas??

    • @bstrouble
      @bstrouble 3 года назад

      Thats what I wanna know

  • @gildas7200
    @gildas7200 3 года назад +1

    Why is mine so zoomed in?

  • @simonk5361
    @simonk5361 6 лет назад +1

    Hello Press Start, it is a nice Video, but useless for me because i dont have an Orthograpic camera. I have a Perspective Camera and the script dont work with this type of camera. So, do you want to make a whole new Video about the zooming from a Perspective cam? Would be nice!

    • @pressstart6864
      @pressstart6864  6 лет назад

      I might make a more in-depth video down the road, but I covered this topic in one of the more recent videos. Here's the link: ruclips.net/video/4_HUlAFlxwU/видео.html

  • @chenariana3482
    @chenariana3482 5 лет назад +1

    why it shows " camera does not contain main"....?

  • @littlerogue4788
    @littlerogue4788 2 года назад

    Why do these formulas work?

  • @rodrigopereiramelo
    @rodrigopereiramelo 4 года назад

    love you dude, but does not work with cinemachine

  • @klemenremec
    @klemenremec 4 года назад

    Great video, but as I implemented it in my game of pong for android, it gets cut off at 18:9 screen ratio... works with every other screen size or ratio

    • @marufm8195
      @marufm8195 4 года назад

      if your issue is with the border wall colliders this video might help ruclips.net/video/rlLMwNI53Oo/видео.html

  • @aniketkanhekar9071
    @aniketkanhekar9071 5 лет назад +1

    I am confused what is rink

    • @abwuds7208
      @abwuds7208 5 лет назад +1

      www.google.com/search?q=rink&rlz=1C5CHFA_enFR739FR739&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjR2tHa8M3jAhUyzYUKHZmyD0UQ_AUIESgB&cshid=1563982469301000&biw=1440&bih=766&dpr=2

    • @bhushanrocks412
      @bhushanrocks412 5 лет назад

      its a background image