ULTIMATE Camera System in Unity! (Move, Rotate, Zoom, Edge Scrolling, 3D and 2D)

Поделиться
HTML-код
  • Опубликовано: 30 июл 2024
  • ✅ Get the Project files unitycodemonkey.com/video.php...
    🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses
    🎮 Get the Ancient Empires Asset pack cmonkey.co/synty_ancientempir...
    🎮 Get my Steam Games unitycodemonkey.com/gamebundle
    🔴 RELATED VIDEOS 🔴
    Easily Control Cameras with Cinemachine in Unity! • Easily Control Cameras...
    How to use NEW Input System Package! (Unity Tutorial - Keyboard, Mouse, Touch, Gamepad) • How to use NEW Input S...
    SMOOTH with LERP! (Move, Rotate, Float) • SMOOTH with LERP! (Mov...
    💬 Here's a pretty big video but it's the only one you need for a COMPLETE Camera System
    Let's learn how to make a Camera we can Move around (with input and also with Edge Scrolling and Pan Drag), Rotate, Zoom (3 methods) and in 3D and 2D.
    With this you have a perfect Camera System for any game where you want the Player to control the camera, works for Strategy games, Tycoons, Management, Top Down Action, etc.
    00:00 Intro COMPLETE Camera System
    01:40 CinemachineVirtualCamera Basic Setup
    04:00 CameraSystem Script, Movement
    07:27 Camera Smoothing, Damping
    08:24 Camera Rotation
    10:55 Edge Scrolling
    13:55 Click Drag to Pan Camera
    17:28 Code Refactoring
    20:00 Camera Zoom
    21:22 How to modify Cinemachine through Code
    24:05 Camera Zoom, Field of View method
    27:40 Camera Zoom, Move Forward method
    34:16 Camera Zoom, Move Down Y method
    36:14 COMPLETE Camera System
    36:45 2D COMPLETE Camera System
    📝 Some Links are Affiliate links which means it costs the same to you and I get a nice commission.
    🌍 Get Code Monkey on Steam!
    👍 Interactive Tutorials, Complete Games and More!
    ✅ store.steampowered.com/app/12...
    If you have any questions post them in the comments and I'll do my best to answer them.
    🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
    See you next time!
    📍 Support on Patreon / unitycodemonkey
    🎮 Grab the Game Bundle at unitycodemonkey.com/gameBundl...
    📝 Get the Code Monkey Utilities at unitycodemonkey.com/utils.php
    #unitytutorial #unity3d #gamedev
    --------------------------------------------------------------------
    Hello and Welcome!
    I'm your Code Monkey and here you will learn everything about Game Development in Unity using C#.
    I've been developing games for several years with 8 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
    I do Unity Tutorials on just about every topic, Unity Tutorials for Beginners and Unity Tutorials for Advanced users.
    You can see my games at www.endlessloopstudios.com
    --------------------------------------------------------------------
    - Other great Unity channels:
    Unity - / unity3d
    Brackeys - / brackeys
    Dani - / @danidev
    Jabrils - / @jabrils
    BlackthornProd - / @blackthornprod
    Sykoo - / sykootv
    Jason Weimann - / @unity3dcollege
    Jonas Tyroller - / @jonastyroller
    --------------------------------------------------------------------
    - Website: unitycodemonkey.com/
    - Twitter: / unitycodemonkey
    - Steam: store.steampowered.com/develo...

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

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  2 года назад +12

    ✅ Get the Project files unitycodemonkey.com/video.php?v=pJQndtJ2rk0
    🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses
    💬 Here's a pretty big video but it's the only one you need for a COMPLETE Camera System
    Let's learn how to make a Camera we can Move around (with input and also with Edge Scrolling and Pan Drag), Rotate, Zoom (3 methods) and in 3D and 2D.
    With this you have a perfect Camera System for any game where you want the Player to control the camera, works for Strategy games, Tycoons, Management, Top Down Action, etc.
    00:00 Intro COMPLETE Camera System
    01:40 CinemachineVirtualCamera Basic Setup
    04:00 CameraSystem Script, Movement
    07:27 Camera Smoothing, Damping
    08:24 Camera Rotation
    10:55 Edge Scrolling
    13:55 Click Drag to Pan Camera
    17:28 Code Refactoring
    20:00 Camera Zoom
    21:22 How to modify Cinemachine through Code
    24:05 Camera Zoom, Field of View method
    27:40 Camera Zoom, Move Forward method
    34:16 Camera Zoom, Move Down Y method
    36:14 COMPLETE Camera System
    36:45 2D COMPLETE Camera System
    🔴 RELATED VIDEOS 🔴
    Easily Control Cameras with Cinemachine in Unity! ruclips.net/video/Ml8ptNeezsU/видео.html
    How to use NEW Input System Package! (Unity Tutorial - Keyboard, Mouse, Touch, Gamepad) ruclips.net/video/Yjee_e4fICc/видео.html
    SMOOTH with LERP! (Move, Rotate, Float) ruclips.net/user/shortsjAN2IoWdPzM
    🎮 Get the Ancient Empires Asset pack cmonkey.co/synty_ancientempires_completecamerasystem
    🎮 Get my Steam Games unitycodemonkey.com/gamebundle

  • @antijulius
    @antijulius 2 года назад +48

    I'm seriously impressed by both the rate and quality of content you put out.

  • @abdou2247
    @abdou2247 2 года назад +7

    Awesome! You’ve been doing an amazing job with your videos lately. Especially the character swap and the backstab videos! Looking forward for more content.

  • @cpu_UP
    @cpu_UP 2 года назад +2

    Excellent video. Totally a definitive guide for Cinemachine and all you may need to know for a Camera control.

  • @alir8zana635
    @alir8zana635 2 года назад +2

    thank you so much for making more videos lately
    your channel is an archive of experience and knowledge, aspiring programmers could look into
    thanks for updating and making great video tutorials

  • @RancorSnp
    @RancorSnp 2 года назад +7

    Oh, this sounds like it's going to be a vrry good addition to your turn based strategy course, the camera controls were driving me crazy during testing ^^'

  • @vazzius
    @vazzius 2 года назад +1

    Great video as usual! You content is always so well done and informative. When using Cinemachine i always like to use the framing transposer to handle zoom, because of the camera distance property it has.

  • @lastkings_games
    @lastkings_games 2 года назад +1

    Nice! I remember learning Cinemachine from your old video and this looks very useful too!

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

    Thank you so much for this detailed tutorial. For sake of time, I just skipped to the rotation part to solve my problem. It worked like a charm. I'm definitely saving this video in a playlist to reference later. I'm sure there's tons I can use because I suck with everything that has to do with the transform component lol

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

    Great as always, even if I'm not interested in the subject of the video I have to watch it because there is always something to learn.

  • @alicivrilify
    @alicivrilify Год назад +2

    You are doing wonderful work. It tremendously helps and fastens my work. Keep it up. It seems like you know everything about Unity.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Год назад +1

      Heh I know a lot but not everything, there is always room to learn more! I'm glad the videos have helped you! Thanks!

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

    Very complete camera tutorial! Thank you for sharing! 🙂

  • @kken8766
    @kken8766 2 года назад +1

    Great content! Thank you for sharing.
    always looking for more~

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

    This was so good and so helpful! I put the LowerY to R and F keys similar to Cities: Skylines controls, exactly how I wanted it!

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

    Just what I needed! 😁 👍 Thank you, Hugo!

  • @arcday4281
    @arcday4281 2 года назад +1

    The Synty package looks amazing !

  • @jean-michel.houbre
    @jean-michel.houbre Год назад +1

    And another great video from Code Monkey, still as efficient as ever. Thanks !

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

    This is so incredibly helpful, thank you.

  • @Ax2themax
    @Ax2themax 5 месяцев назад

    This is a wicked awesome tutorial! I was able to modify this to work with my orthographic lens flawlessly following your tips and guide! TY!

  • @bezimienny5
    @bezimienny5 Год назад +1

    Great, now I just need to look into fading objects obstructed by the camera. Thank you!

  • @shore2k6
    @shore2k6 8 месяцев назад

    Great tutorial, really helped, well done!

  • @clarathulin4294
    @clarathulin4294 10 дней назад

    thanks for the amazing tutorial! so nicely explained and all bases covered :]

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

    My favorite way is to do linear regression for the minimum and maximum points of camera position and rotation, then you will get straight lines that go from the minimum point to the maximum of the camera, then you use the mouse scroll to decrease or increase a float which will define the x and then you calculate the Y midpoints of the camera and define the current position for it, this method gives a more dynamic effect, at the same time that the camera lowers or raises it rotates together, it is wonderful!

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

    Ótimo vídeo como sempre!

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

    I really enjoyed. Piece of art. 🙏🙏🙏

  • @prod.jakekarno1765
    @prod.jakekarno1765 Год назад

    Top notch tutorial as always!

  • @pebkaclive
    @pebkaclive 8 месяцев назад

    Awesome video, thank you. First time picking up Unity and learning to create a game and I managed to follow this (just). ran in to a couple of issues and managed to resolve them too.

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

    Is so helpful, your information is gold ;P Thank you!!

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

    Realy good video, thanks!

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

    Greate Video and Camera System. 😍
    You mentioned that one could also use the new input system for controlling the camera. I‘ve got this to work with keyboard inputs. But how to listen for touch gestures like pinch to zoom or two finger scroll instead of wasd keys? 🤔
    Would appreciate if you can make a video about touch gestures.

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

    Thank you so much! you are a life saver!

  • @accioollie9710
    @accioollie9710 Год назад +1

    Some tips:
    1. If you tap both W and A, S and D, etc., you get a speed boost to the camera which can be a bit strange. Use this code to fix that:
    float inputMagnitude = inputDir.magnitude;
    if (inputMagnitude > 1f)
    {
    inputDir /= inputMagnitude;
    }
    inputDir.z *= (1f + inputMagnitude);
    inputDir.x *= (1f + inputMagnitude);
    Basically, it divides z and x by a certain amount to cancel the extra-speed effects.
    2. You can change those 4 (or 8 if you use two line if statements, or even 16 if you also add braces) GetKey movement lines to something much more compact like this:
    inputDir.z = Input.GetAxis("Vertical");
    inputDir.x = Input.GetAxis("Horizontal");
    Also, it is better to use an GetAxis approach if using the old input system anyway.

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

    Greaaaaaat video, thank you!

  • @omaralromaithi8078
    @omaralromaithi8078 2 года назад +1

    Just on time, I'm trying to make a combination between RPG camera and FPS camera using cinimachine brain. This could cover alot in my game. Thanks

  • @slygamer01
    @slygamer01 2 года назад +1

    It is interesting to combine LowerY with a bit of FOV for a curved zoom. As you get lower to the ground, it tightens up on the target point.

  • @cosmicrenegade
    @cosmicrenegade 8 месяцев назад +2

    Incredible video as always! One issue I ran into with my 2D top-down game was that when I rotated the camera, my health bars in world space would also rotate. To keep the health bars (and other world space UI elements) aligned with my camera, I added a script component to my world space canvases with this Update() function:
    private void Update() {
    Camera camera = Camera.main;
    transform.LookAt(transform.position + camera.transform.rotation * Vector3.forward, camera.transform.rotation * Vector3.up);
    }
    This makes sure that canvases that are children of my game objects would remain aligned with the camera.
    There may be a better solution, but I hope this helps anyone else with world space canvas rotation issues!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  8 месяцев назад

      Yup that's a great way to do it, alternatively you can do
      transform.forward = -camera.transform.forward;
      if you don't want any skewed rotations.

  • @Abdulwahab-vb6he
    @Abdulwahab-vb6he Год назад

    Amazing bother love it....

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

    YES YES AND YES! eres una leyenda!

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

    Thank you so much!

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

    Wow he's really good at what he does. I really appreciate him sharing his coding knowledge. Thank you Code Monkey!

  • @unohhhjjdd6716
    @unohhhjjdd6716 2 года назад +1

    400k, you're almost there :)

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

    Oh this is an interesting one after the crap I recently tried to do with the normal camera :D, forgot all about cinema machine to begin with

  • @NitinChodvadiya-ro3ks
    @NitinChodvadiya-ro3ks Год назад

    It's very helpful video, Thanks
    I'm looking for the mobile device is there any tutorial available?

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

    Thank you!

  • @dexter_hacks
    @dexter_hacks Год назад +2

    Any idea how to go about resetting the camera position? For eg: If I click on the player or press a default key, the camera needs to be behind the player and pointing at its default angle and height, etc.

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

    The script and the scene both are looks awfully good

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

    Outstanding!!!!!!!!...how can you add this camera system ability to a Camera Model so the character can record videos...also can you create a lighting system, is it the same method as the camera system.

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

    Thanks!

  • @Andrei_Kozlov
    @Andrei_Kozlov 9 месяцев назад

    Thanks for the video, we need the same guide only for mobile devices.

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

    damn, your video game graphics is insane.

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

    Wow! Great thanks, i'll definitely make this and put on my git for further usage in projects. And emmm Hugo! It'll be helpfull if you make some explaining video about zenject/extenjext and that dependency inversion principle =). I'm looking for a job and many companies have that on their list of must-have skills. Can you help figure it out.. with more understandable words?)

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад +1

      I've never used it myself but I remember the channel Infallible Code had some great tutorials on Zenject.
      Unity also has some built-in testing tools "Test Runner" but also never used them myself

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

    As always just amazing content! One thing I've always seen is in Update() you capture the input and calculate moveDir, rotations, etc., then in LateUpdate is when you actually apply it to the transforms. Do you find that unnecessary?

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

      There's no need to do that unless you have some very weird code architecture where you depend on some object's position on Update but it breaks if you move it right away.
      If that is the case then it sounds like you need to refactor some logic rather than move the object code to LateUpdate

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

    Great tutorial but can we use Move, Rotate, Zoom from Mobile phones through touch input? I want these settings and need to export to webgl so will the camera will work in mobile phones. touch system too?

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

    Nice video

  • @nightcorebrothers6527
    @nightcorebrothers6527 Год назад +1

    I have a question could you please also add orbit controls to the example 🙏. I am trying to add it but it doesn't work quite right.

  • @user-em8if4tu1l
    @user-em8if4tu1l 3 месяца назад

    Thank you very much, I would like to ask, if I have an already standalone built that does not have camera motion, how can I add camera motion to it?

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

    Awesome

  • @djcarryout27
    @djcarryout27 9 месяцев назад

    Could you expand on this series by demonstrating how to have UI elements (health bars, unit nameplates with unit name text, etc) move about in world space, with their size scaling as the camera zooms in and out?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  9 месяцев назад

      You can just use a World Space Canvas unitycodemonkey.com/video.php?v=Zwgj3mwOVlg
      It will automatically scale as you move in/out
      I used the same thing for the health bars in my TBS game unitycodemonkey.com/video.php?v=QDr_pjzedv0

  • @foxfurystudio4860
    @foxfurystudio4860 2 года назад +1

    Amazing video, Thanks you!

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

    Is there a way to implement edge scrolling in the editor with the new input system? I know how to implement wasd keys but not the mouse.

  • @gertsameys622
    @gertsameys622 3 месяца назад

    Love your channel! Is there a possebility that you add a little segment to this video with Orbit Camera movement?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 месяца назад

      That one involves a bit of math that I'm really not very familiar with, I'm sure there's an equation for it but I don't know it.
      If I had to do it I would probably use a workaround like placing an invisible empty game object on the target orbit, then placing the camera or an empty point inside it with the same offset position and rotate that game object to find the orbit position

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

    Is there an updated version of this video for the new input system?

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

    legend

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

    how can i make the mouse stop moving when inside the game, so an i use its movement, like on the pan option without needing to keep it clicked? i`m studding some things using the StarterAssets as an base, and this is one thing that i could not understand by now.

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

    I'm new to Unity and am about to begin taking your Turn-Based strategy game course. I was curious how using the camera functions from this tutorial would be possible in the scenario that a Ceiling/Roof/Wall gets in-between the player and the camera. Is there a way to accomplish something like that? Thank you for your time.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Год назад +2

      You can use the Cinemachine Component - Cinemachine Collider which will prevent the camera from going through walls, however that would probably end up with the camera way too zoomed in.
      So the better option would be to visually fade out the ceiling if there's a ceiling between the camera and the camera target. Or use some kind of Cutout shader.
      I hope you're enjoying the course!

  • @indiandev1588
    @indiandev1588 2 года назад +1

    I want to create level and i have created. My problem is this that (think that i created 50 levels, i completed 35 levels but i want move camera for changing a level) means i my camera move back to its position when i complete level.
    Can anyone help me...

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

    Thank for your sharing! Good tutorial.
    BTW, how can I limit moving the island out of camera view? Could you please give me some hint?

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

      You can use a Cinemachine confiner unitycodemonkey.com/video.php?v=_B8ljGktBtg
      Or just some basic math, validate the new position before using it

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

      @@CodeMonkeyUnity It weird behaviour with 3D Orthor Camera + Cinemachine confinder 3D.
      1. the camera has height limit base on box collider
      2. when camera collide to "box wall", it stops & rotates around instead of standing as 2D
      Can you make a short tutorial on this topic: Cinemachine confinder 3D.? Thank you

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

    When the camerasystem object is rotated on the Y axis by 180 or -180 the WASD stops corresponding to the correct directions, Have i missed something ?

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

    Hey @Code Monkey, I'm Hudson from Tin Edge Productions. I have a game that I was wondering if you could test play. Thanks for the amazing content, please keep it up!

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

      Sorry I'm already insanely busy so don't have time to do playtesting

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

      @@CodeMonkeyUnity Thanks anyway, I really appreciate you getting back to me. Can't wait for the next video! (P.S. I used your CCTV mod for my FPS game)

  • @JohnnyThousand605
    @JohnnyThousand605 11 месяцев назад

    This is a great reference video =)
    One thing I'm trying to figure out; how would you handle obstructions between the camera and the player?
    I'm currently doing a RayCastAll and then using GetComponent to make obstructions fade to transparent but this feels hacky. Is there a better / best practice way?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  11 месяцев назад +1

      That is indeed one perfectly valid way to do it, technically it's not the most performant but if it works then it works
      One alternative is use a shader or play around with the Render Pipeline - Render Objects feature to render the player differently when occluded

    • @JohnnyThousand605
      @JohnnyThousand605 11 месяцев назад

      Thanks man, I'll keep that in mind if I'm looking for some performance headroom 🙂

  • @nileshkumawat6730
    @nileshkumawat6730 11 месяцев назад

    This script doing this ? When mouse left side of screen then that mouse point zoom and in any where we put mouse pointer zoom or this script zoom at mid point ?
    I want to zoom like coc

  • @SHIFU....
    @SHIFU.... Год назад

    IT WOULD BE GREAT IF YOU MAKE SOMETHING LIKE THIS FOR PLAYER MOVEMENTS(3D!)

  • @syntaxsafety
    @syntaxsafety 9 месяцев назад

    Thank you, for supplying my dumb brain with knowledge.

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

    Can you explain in how you included Rigidbody in the First Person Controller Form Unity?

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

      It doesn't have a rigidbody, it has a CharacterController, I didn't touch that at all it's exactly like in the original asset

  • @DannyOnateArt
    @DannyOnateArt 9 месяцев назад

    great video! how i can change the follow of the cinemachine in circunstancies?, example in the intro the camera follow a game object with an animated movement in the position and change the follow target to the character to play the game..

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  9 месяцев назад +1

      I'm not sure I understand the question, sounds like you just want multiple virtual cameras with different priorities and enable them based on some logic. The highest priority one will be the active one

    • @DannyOnateArt
      @DannyOnateArt 9 месяцев назад

      @@CodeMonkeyUnity yes! How change between múltiple cameras with diferent follow target.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  9 месяцев назад +1

      Either modify the priority through code to make that camera active, or set them as higher priority by default and enable/disable the game object

    • @DannyOnateArt
      @DannyOnateArt 9 месяцев назад

      @@CodeMonkeyUnity 🙌

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

    Here is an issue I've been having...when my play window is maximized my deltatime works as expected. But when the game view is docked, my camera moves slower. Why is that when deltatime is framerate independent?

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

      Are you using Free aspect ratio? It might just seem faster because you're using a thinner aspect ratio with a different fov.
      In terms of actual speed on the transform it should always move at the same speed regardless of aspect ratio.
      Or maybe you're applying multiple movement methods together? Maybe you're doing both key movement and edge scrolling and adding both movements? Maybe the edge definition is triggering too much when docked.
      You can make a quick test to verify. Start counting a timer while the move button is held down, count the time and the distance moved. It should be exactly the same regardless of docked or undocked.

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

    Sir I have a question. I have made cutscene in blender can i import those in unity 3d as a cutscene. Bcoz it easy to make cutscene in blender thats why i made it in blender. I hope you'll clear my doubt 😊❤️

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

      You could render a video from Blender and play that video in Unity with the VideoPlayer component

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

    You should publish this in the asset store

  • @Hazzel31337
    @Hazzel31337 Год назад +1

    the code from the download is verry different from the one in the video, so far i dont understand a lot, should all the camera... scripts be placed on the virtual camera ? so far i managed to make it follow the camera object and follow its rotation, but i think most of it is was cinemachine does anyways , zoom option is only for the 2d method ? because it references orthographic size ?

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

      How is it different? The code is exactly the same, I create the package after recording the video. The only difference is it does not have the visual assets. Maybe you're looking at a different script? The project files include a lot of things that aren't related to this particular video.

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

      @@CodeMonkeyUnity oh jesus i looked in the wrong folder, i looked under the CodeMonkey namespace and there was CameraFollow Scripts, i already wrote down everything from the video myself xD my bad sry xD

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

    I follow along and my Unity doesn't do what yours does. If I start a new project Cinemachine is missing and its not anywhere in the plugins, but if I open an example project the example projects have it.
    If I try to repurpose an example project I get "Display 1 no cameras rendering" if I try to add a cinemachine camera and don't know how to fix it.
    I also cannot make any changes to the camera, in the "Body" section, changing the offset does nothing. The camera dethatches from the cinemachine icon if I try to move it too. Whenever I try to learn any software I end up encountering lots of bugs that seem to be unique to me, googling this problem found no results, I want to give up already after 3 hours of just trying to do step 1. Make a camera.

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

      Cinemachine is not a plugin, it's a package in the package manager, it's intentionally not installed by default on brand new projects because not every project uses it.
      "No cameras rendering" means all your cameras are disabled, you should have at least one Main Camera enabled.
      If you're using cinemachine then you need to modify the settings on the Virtual Camera and not the regular Camera object (since those are replaced by wahtever is on the virtual camera)

  • @legogurkan5297
    @legogurkan5297 2 года назад +2

    O my god i littererally made my own yesterday. How the world works😀

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад +1

      Now you can compare your own system with this one and mix and match the features to get the best of both!

  • @TheBeLuvdTRex
    @TheBeLuvdTRex 3 месяца назад

    For some reason when I do the drag which is the sole reason I watched this video it doesnt work. Im using the new input system by adding InputActions that I assign in the inspector. The value for mouseMoveDelta is always returning zero. Heres the code:
    if (dragPanBoolActive) {
    mouseMoveDelta = mousePos.ReadValue() - lastMousePos;
    float dragPanSpeed = 20f;
    inputDir.x = mouseMoveDelta.x * dragPanSpeed;
    inputDir.z = mouseMoveDelta.y * dragPanSpeed;
    lastMousePos = mousePos.ReadValue();
    }
    Anything you can spot im doing wrong to cause this?
    It works fine with all the other camera setups you described here.
    Edit: Nevermind I figured out what it is. Youre using button down which only detects the initial press. My code always assigns the lastmouse position when the button is down. I need to add a bool that will make it so it wont run through the button press after its initial press.

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

    How would you make a camera follow a player object smoothly whilst also being able to rotate the camera with Q and E ?

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

      This camera system has the camera looking at that invisible game object, so just make that game object follow whatever object you want

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

      @@CodeMonkeyUnity what if I wanted to rotate the camera separately from the player

  • @Unity_Helper
    @Unity_Helper 9 месяцев назад

    How to make it work with the new input system using the Touchscreen? Need a new video instruction =)

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

    How do you add the dynamic depth of field ?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Год назад +1

      It's just the Depth of Field effect on the Volume, it isn't dynamic

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

    Hi. Thank you so much for this video. Followed the steps and everything is working fine. However, I have a problem. My buildings are on a terrain and I want a situation where when I pan to the edge of my terrain, i won't pan further. Kind of like setting boundaries to it, so the user does not pan outside the terrain.
    I'd really appreciate your help on this as I've tried a lot of things and they don't seem to work efficiently for me

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

      You can use a Cinemachine confiner unitycodemonkey.com/video.php?v=_B8ljGktBtg
      Or just some basic logic, test the camera follow point position, if the X/Z is above/blow certain values, don't move it

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

      @@CodeMonkeyUnity Thank you, but it turns out that the Cinemachine confiner only confines screen edge in orthographic view

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

      @@CodeMonkeyUnity Hi, I'm really sorry to bother you, i've been trying to come up with different solutions to this problem but i haven't been able to. I've tried to clamp the camera position but it's refusing to work. i might be doing it wrong. can you please help me out? i'm really getting frustrated about it

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

      @@Sandra_Chijioke What exactly isn't working? The script moves the invisible camera target, after moving it check the X position, if it goes beyond some predefined max-X value then move the object back to the max.

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

      ​@@Sandra_Chijioke ​ I have same problem, cinemachine confiner don't work well with 3d collider, have you solve the problem, please can you help me?

  • @Robert-rh8dh
    @Robert-rh8dh 11 месяцев назад

    Hey I'm using the move forward method but for some reason the camera is acting like it's on ice or something like it zooms in and out but kinda glides even after you stop using the scroll wheel. If anyone knows what might be up I would love to hear.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  11 месяцев назад

      How does it glide? It should be changing the zoom target and it should constantly modify the values towards that target, it shouldn't overshoot and keep going

    • @Robert-rh8dh
      @Robert-rh8dh 11 месяцев назад

      ​@@CodeMonkeyUnityI used the move forward method and i don't know how to explain it is looked over it like 6 times its all the same code. Seriously just stumped I really don't want to but I might have to scratch it and restart.

  • @_Cazot
    @_Cazot 6 месяцев назад

    Hey there! Im having a provlem seeing the box thing (sorry i dont know what its called) in unity at 21:46 . It looks like I did everything as you did, but after saving, it doesnt show up. Do you know anything about this or have you done it before? Thanks

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  6 месяцев назад

      Hmm by box thing you mean the field on the script? You just need to make sure to make it "[SerializeField] private" and it will show up in the editor, it's just a cleaner way of exposing it in the editor instead of making it public unitycodemonkey.com/video.php?v=pD27YuJG3L8

    • @_Cazot
      @_Cazot 6 месяцев назад

      @@CodeMonkeyUnity thanks, I'll try that later

    • @_Cazot
      @_Cazot 6 месяцев назад

      @@CodeMonkeyUnity I just opened unity and it was working, also, the tutorial is great and great job keeping up with all of the comments!

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

    Awesome and timely tutorial, but why must I register on your site to download files for a free video? Not a fan of that.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад +2

      Feel free to just follow along with the video and write it yourself, the project files are just for convenience, there's no hidden secret code.
      As for the register requirement, I didn't want random bots to find direct links and start randomly downloading things and spending bandwidth making the website slow.

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

    Great Asset, but how I can define a limit movement of my camera to x,z dimension

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

      Not sure what you mean, the movement script in the video is already only moving on XZ 4:39

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

      @@CodeMonkeyUnity I would like to define an area that cannot be crossed, I tried with the c confiner extension but it doesn't work well

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

      ​@@mimoxfao Oh you mean limit how far it can move. Yes the camera confiner would be one approach. Another would just be some simple checks in the camera movement script.
      if (newCameraPosition.x > MAX_X) // Don't move
      Alternatively for a more designer friendly method you can use a Collider and check if the current camera position is inside the valid collider.

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

      @@CodeMonkeyUnity I've already used confiner and collider but when the camera collides with the box it produces strange effects, I think it would be better to give a limit to the x,z axes or use a trigger with an action that would stop the camera, even better if I could write a cinemacine extension :), unfortunately I don't have the knowledge to do it, thanks again for your patience

  • @StickyLabDev
    @StickyLabDev 11 месяцев назад +1

    needit for mobile

  • @karthik-vq2rj
    @karthik-vq2rj Год назад

    how to give all these features for touch in mobile.

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

      You could make onscreen buttons or a onscreen joystick, that would be the simplest option

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

    Camera shouldn't be on LateUpdate instead of Update ?

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

      Depends on what you're following. In this case the camera is manually driven by the player so either one works fine

  • @sashacontu
    @sashacontu 3 месяца назад

    Cinemachine virtual camera is obsolete now! how can i make the zoom with just using cinemachinecamera?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 месяца назад +1

      Uh? What makes you say that? Cinemachine is not obsolete. Are you using Cinemachine 3? From what I heard that was a big upgrade but I haven't looked into it yet

    • @sashacontu
      @sashacontu 3 месяца назад

      @@CodeMonkeyUnity Not cinemachine, one of the code components u used in c# says is obsolete

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

    Why do you use Transposer ?

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

      To make it follow the target object

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

      @@CodeMonkeyUnity But you can also with 3rd person mode

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

    or i guess you could do edge panning with an invisible canvas, no ?

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

      Not sure exactly what you mean, are you saying add 4 invisible images on all 4 edges and test for mouse over on that? Sure that would work but sounds like a needlessly complex approach.

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

      @@CodeMonkeyUnity yeah that's what I meant, with hover event haha

  • @doubled4683
    @doubled4683 Месяц назад

    Good for an RTS. Not very good when you want the camera to follow the player (unless you put in on a child object of the player).

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Месяц назад

      Why not? That method works perfectly fine, if the camera target is a child of the character it will move along the character, in that case you would just use the rotation/zoom logic and not the move/pan

  • @watercat1248
    @watercat1248 3 месяца назад

    i personally dont use cinemachine because mest up with all my cameras for in my game
    on the game I'm working i have 4 camera's 1 for each player and have system split the screen on half wean the 2 player on 3 wean the 4 player the split the on 4 part's wean the are 4 player's
    because my game need 4 camera's to work perfectly all the time and cinemachine mest everything waen i have more the one camera that moves all the time i don't use cinemachine

  • @SlothHuntOnYou
    @SlothHuntOnYou 11 месяцев назад

    why are you using 60fps for tutorial videos? all peoples watch it on speed = 2x.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  11 месяцев назад

      Because I personally prefer it, it looks smoother. What does the framerate have to do with playback speed?

    • @SlothHuntOnYou
      @SlothHuntOnYou 11 месяцев назад

      @@CodeMonkeyUnity It is much better to use 30fps for tutorial videos because they give less load on Internet traffic and power consumption on servers and every client who will ever watch this video(let’s take care of nature and not waste extra electricity). 30fps on monitors with 60hz look smooth also + it's give faster download time for that video

  • @user-sw1cq6ds3x
    @user-sw1cq6ds3x Месяц назад

    can anyone send camera script ?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Месяц назад

      There's a link in the description

    • @user-sw1cq6ds3x
      @user-sw1cq6ds3x Месяц назад

      @@CodeMonkeyUnity Thanks. one more thing how i can limit the movement of camera so that camera should not go outside from specific area?