Camera Zoom in Unity with Cinemachine {Keyboard & Mouse}

Поділитися
Вставка
  • Опубліковано 28 сер 2021
  • In this video I will show fellow Unity Developers or aspiring Game Developers how to zoom in and out with cinemachine.
    💖 Support my videos on Patreon ► / obsessivegames
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    🙋 LINKS TO CHECK OUT 💗
    If you need any assets and would like to see what the Unity asset store has to offer, then head right to the Unity store here ► bit.ly/39bxPvy
    💗 50% off selected Unity Asset Store special ► bit.ly/39hri2t
    Learn more with unity premium, go check it out!
    📚 Unity Learn Premium ► bit.ly/3xBfKkh
    If you want to take your game development career to the next level, make sure to look at Unity Pro or Unity Plus:
    🔗 Unity Pro ► bit.ly/3O06wTP
    🔗 Unity Plus ► bit.ly/3mHfdad
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    ✨Connect on more platforms ✨
    📷 Instagram ► / obsessive_games
    🐦 Twitter ► / gamesobsessive
    🥶 Facebook ► / obsessivegames
    💬 Discord ► / discord
    💨 Wishlist ► bit.ly/3kvM7Jn
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    Welcome to Obsessive Games and on this channel, I show you how to create games and show you tips and tricks with Unity.
    The current indie game in progress is an Action Role-Playing game called Guild Hall Adventures, I will show you what unity game development methods I use to complete games with Unity 3D.
    Consider subscribing for game development tutorials and devlog videos with everything GameDev related, create your own indie games with the help I provide.
    👍 Like and Subscribe! 💖
    ♥ Subscribe - bit.ly/2WkqqE4
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    ✨Other Tutorials ✨
    📷 How to make a Singleplayer FPS Game ► bit.ly/3aEPWud
    📷 How to shoot in an FPS Game ► • How to shoot in my FPS...
    📷 How to gather a tree in Unity ► • How to gather a TREE i...
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    #unity #gamedevelopment #cinemachine
    #obsessivegames
    Camera Zoom in Unity with Cinemachine
    indie games,indie game,unity3d,low poly,game dev,gamedev,computer science,game development,unity game development,unity game dev,indie game development,cinemachine unity,cinemachine,cinemachine tutorial,cinemachine follow,unity tutorial,indie game dev,unity,game developer,indie gamedev,unity cinemachine,unity 3d tutorial,unity 3d,obsessive games,unity tips,virtual camera

КОМЕНТАРІ • 45

  • @MinhocaMortifera
    @MinhocaMortifera 2 роки тому +2

    Nice tutorial, exactly what I was looking for, thanks! :)
    (Remember to uncheck "Save during play", my Cinemachines camera by default has it enabled).

  • @ronaldinhodev
    @ronaldinhodev 10 місяців тому +1

    Thanks a lot! You're the best, man. 🚀

  • @hawkgamedev
    @hawkgamedev Рік тому

    Great videos just subbed keep up the good work!

  • @johnspivey8960
    @johnspivey8960 Рік тому +2

    Thank you. The hell I went through trying to code my own camera controller then I found Cinamachine. I am so new to coding its not even funny. Thank you again.

  • @karazou1
    @karazou1 Рік тому

    Thanks for the tutorial. Really helped me a lot. Thank you!

  • @SimplyLuke94
    @SimplyLuke94 Рік тому

    Thanks a bunch for this tutorial, no nonsense and straight to the point.
    After looking around a little I've come back to ask; How would one code a limit to the zoom effect? (Say the Camera distance in the body section having a minimum zoom of 35 and a maximum of 15?) Hope this makes sense, many thanks Obsessive Games.

    • @ObsessiveGames
      @ObsessiveGames  Рік тому +1

      Super happy you enjoyed it!
      I actually did answer this before and I think this comment helped, also if the below doesn't help, come hop into discord and I'll personally assist you:
      Here is the link to the pastebin, there is an "if (cameraDistance < 0) which does the check and the there is a float variable maxCameraDistance which is also SerializeField to be seen in the inspector to be set, but you can set it at the top as well. If you do have questions regarding any of this, please do let me know.
      Pastebin link: pastebin.com/QqEYmqbX

  • @LuqmanHidayat00
    @LuqmanHidayat00 2 роки тому

    wow this is it what i've been looking for, changing the distance, thanks man.
    but for my purpose i need it simple by pressing button, do you know how to implement it with keyboard? i mean i want to implement it with gesture touchscreen, but for now i want to bypass it first with keyboard input.

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому +1

      You could use the new input system and see how to send event like keys to do a zoom.
      This video will show how to send the events: ua-cam.com/video/Yjee_e4fICc/v-deo.html

  • @andredias5061
    @andredias5061 2 роки тому

    thx for the video, but how could I change the camera rotation too?

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому

      Hey! thanks for watching the video, I have another video which is the First Person Movement video, it specifies from around 6min with the mouse look at script where you can adjust the gameobject transform.rotation with euler and how I did it to look left and right, if you still need more help, I am more than happy to assist in the Discord group as well.

  • @kaloshabuthapa3284
    @kaloshabuthapa3284 2 роки тому

    i love the video. How do you switch multiple cinemachine virtual cameras???

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому +1

      You can use the depth filter and raise the value as far as I know, I am more than happy to assist over discord if needed.

    • @kaloshabuthapa3284
      @kaloshabuthapa3284 2 роки тому

      ​ @Obsessive Games Thank you for replying. would that. could you share your discord server link?

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому

      @@kaloshabuthapa3284 here you go: discord.com/invite/QybEbjm

  • @ObsessiveGames
    @ObsessiveGames  2 роки тому

    Finally can see what the NPCs looks like by scrolling closer, want to see more Unity Tutorials that I made? Check out this playlist: bit.ly/3CcDAC8

  • @Gijs9114
    @Gijs9114 2 роки тому +1

    what plug in(s) do you use in VS code to get intellisense for unity? (if thats the right word. i mean the key word prediction)

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому

      So all the extensions I have in VS code that are unity related are:
      Debugger for Unity
      Unity Code Snippets
      Unity Snippets
      Unity Tools
      I hope that helps :)

    • @Gijs9114
      @Gijs9114 2 роки тому +1

      @@ObsessiveGames super awesome, i installed all of them and now have exactly what i was hoping to find!!! Thank you very very much

  • @robelso5646
    @robelso5646 2 роки тому +1

    My script dosent recognize the 'Using Cinemachine' referance, even after I restarted Unity

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому

      And it is installed? more to happy to help over discord as well

  • @Az555
    @Az555 2 роки тому

    I tried to implement this using the Input Actions (Input System), but it doesn't work.
    The debug shows that it is reading the mouse scroll up and down, but your code doesn't affect the camera.
    Any help would be great, thank you!

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому +1

      Hey Az, have you made sure that you did indeed drag and drop the virtual camera into the slot? if you did then I am not 100% sure what is going on, but you could always hop on discord and when I am online you can always pop me a message and I can have a look at what is actually going on :)

    • @Az555
      @Az555 2 роки тому

      @@ObsessiveGames I see the problem now. I am using 3rd Person Follow and not Framing Transposer. Does this only work with Framing Transposer? Or can I modify the code to work with 3rd Person Follow?

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому +2

      @@Az555 There should be a way, I saw you joined the discord, so we will chat on that side. ;)
      *edit: @ if (componentBase is CinemachineFramingTransposer) if you use a different camera style, then you need to change each of this statement to is Cinemachine3rdPersonFollow and as Cinemachine3rdPersonFollow.

  • @sydipopcorn939
    @sydipopcorn939 2 роки тому

    so how to set min and max for the zoom distance?

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому +1

      Here is the link to the pastebin, there is an "if (cameraDistance < 0) which does the check and the there is a float variable maxCameraDistance which is also SerializeField to be seen in the inspector to be set, but you can set it at the top as well. If you do have questions regarding any of this, please do let me know.
      Pastebin link: pastebin.com/QqEYmqbX

    • @sydipopcorn939
      @sydipopcorn939 2 роки тому +1

      @@ObsessiveGames yes it work… thx brooooo

  • @SpaceMango
    @SpaceMango 2 роки тому

    How do i set a max camera distance when i'm too far away, and when i'm too close?

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому

      Let me send a pastebin for the max camera distance on what could be done for this script and ill add some comments as well. Will send in a sec.

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому

      Here is the link to the pastebin, there is an "if (cameraDistance < 0) which does the check and the there is a float variable maxCameraDistance which is also SerializeField to be seen in the inspector to be set, but you can set it at the top as well. If you do have questions regarding any of this, please do let me know.
      Pastebin link: pastebin.com/QqEYmqbX

    • @bymsec
      @bymsec 2 роки тому

      @@ObsessiveGames bro thats not working :(((

    • @AlexanderSama
      @AlexanderSama Рік тому

      @@ObsessiveGames just what i needed, thx!

  • @blockido2151
    @blockido2151 Рік тому

    I have a promblem with this, my character cant move anymore becuase of the script

    • @ObsessiveGames
      @ObsessiveGames  Рік тому

      If you do require more assistance with this then I am more than happy to hop on discord to assist :)

  • @nemanjasekulic711
    @nemanjasekulic711 2 роки тому

    how to do it with touch?

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому

      I will look into that and create a new episode regarding that! Thanks for the idea

  • @farhanmaulidan3306
    @farhanmaulidan3306 2 роки тому

    is it work with screen space- camera canvas?

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому

      This is only for cinemachine, it would work for anything that is using cinemachine, the componentbase can just be changed to let the others work 😀

    • @farhanmaulidan3306
      @farhanmaulidan3306 2 роки тому

      @@ObsessiveGames ok so if i changed it to mobile then its only change the input.getaxis right?

    • @ObsessiveGames
      @ObsessiveGames  2 роки тому

      @@farhanmaulidan3306 not sure for mobile, you could always join the discord and show a bit more of what you are trying to do :)

  • @ieretsumi
    @ieretsumi Рік тому

    this method only works with one type of camera. and is not universal. not easier to use ADD Extension => CinemachineCameraOffset?

    • @ObsessiveGames
      @ObsessiveGames  Рік тому

      Not 100% sure about "not easier to use ADD Extension". Is this something to be added to make it universal?

    • @ieretsumi
      @ieretsumi Рік тому

      @@ObsessiveGames Add Extension => CinemashineCameraOffset.
      during the experiment, I noticed that when using offset, the camera collision does not work
      perhaps this is still not the best solution.
      and for each camera you need to look for your own approach.
      good luck!