How to Make a Camera System (Like Hollow Knight's) in Unity using Cinemachine | 2D Tutorial

Sdílet
Vložit
  • čas přidán 6. 06. 2024
  • Show your Support & Get Exclusive Benefits on Patreon (Including Access to this project's Source Files + Code) - / sasquatchbgames
    Join our Discord Community! - / discord
    In this Unity tutorial, we'll be re-creating Hollow Knight's camera system using Unity and Cinemachine.
    We're going to cover:
    - how to setup a direction bias
    - interpolation based on your player's vertical velocity
    - camera bounds (and how to break them,)
    - ledge detection (so you can, for example, have the camera pan down to hint to your players that they CAN fall down that ledge.)
    - setting up different camera settings for different rooms (Ie. vertically centered, vertically locked, full position locked) and a system to easily swap between them when needed.
    I spent a good deal of time analyzing Hollow Knight's camera system and it's complexities, and by the end of this video you'll know how to create them all!
    Link to Download the FREE 2D Asset Pack seen in this tutorial:
    veilofmaia.com/tutorial-asset...
    ---
    In need of some Unity Assets? Using our affiliate link is a great way to support us. It's free, and we get a small cut that helps keep us up and running: assetstore.unity.com?aid=1100lwgBQ
    ---
    Contents of This Video: ------------------------------------------
    00:00 - Analyzing Hollow Knight's Camera
    02:54 - Direction Bias
    05:37 - Interpolation Based On Vertical Velocity
    07:46 - Setting Up Proper Camera Bounds
    10:39 - Camera Ledge Detection
    14:10 - Setting Up Multiple Cameras and a System to Swap Between Them
    Who We Are-------------------------------------
    If you're new to our channel, we're Brandon & Nikki from Sasquatch B Studios. We sold our house to start our game studio, and work full time on building our business and making our game, Veil of Maia.
    Wishlist our Games:
    Wishlist Samurado on Steam! - store.steampowered.com/app/23...
    Wishlist Veil of Maia! - store.steampowered.com/app/19...
    Don't forget to Subscribe for NEW game dev videos every Monday & Thursday!
    Follow us on Twitter for regular updates!
    / sasquatchbgames
    #unitytutorial #unity2d #unity3d
  • Hry

Komentáře • 105

  • @sasquatchbgames
    @sasquatchbgames  Před rokem +25

    be sure to add #if UNITY_EDITOR before the MyScriptEditor script, and an #endif at the end of it, or this will give you errors when you try to build the game.

    • @fireraccoon_
      @fireraccoon_ Před rokem +1

      i used this but when i try to build game i have " cannot build game while player is compiling and building script" any idea?:(

    • @fireraccoon_
      @fireraccoon_ Před rokem +4

      fount issue....you must put this #If Unity_EDITOR before "[CustomEditor(typeof(CameraControlTrigger))]" not in the middle of this and MyScriptEditor :)

    • @DawidLewandowski-ev7rd
      @DawidLewandowski-ev7rd Před 10 měsíci +1

      oh god , thx bro i find this comment like sec before i got rage at my code and trow my laptop out the window

  • @actuallyZiggyZagga
    @actuallyZiggyZagga Před rokem +18

    Wow! As an spiring Game Designer, I never realized how nuanced the camera system is in Hollow Knight, Devs should certainly implement this system in their games. Thank you Sasquatch B Studios, for another amazing tutorial!

  • @Watzefuk1192
    @Watzefuk1192 Před rokem +9

    The breakdown of how it works in hollow knight is a life saver man thanks. Was planning on doing that at some point to fine tune my camera system!

  • @StealthyShiroeanGames
    @StealthyShiroeanGames Před rokem +1

    Wow, this is an excellent tutorial. I think some of it was over my head but I definitely will be tucking this away for when and if I ever need it in the future. I really love your analysis of the Hollow Knight camera as well. It gave me something to think about and challenged to me to be more analytical with games I play.

  • @MrBb155
    @MrBb155 Před 3 měsíci +1

    Honestly, your tutorials have saved my skin enormously! excellent explanations and actually teaches the functionalities in unity and not just a copy me code.

  • @heroslegendstudios1658
    @heroslegendstudios1658 Před 8 měsíci +3

    Great stuff can't wait to bring this kind of camera work into my game

  • @CogNoman
    @CogNoman Před rokem +4

    Great video. I never even thought of or noticed any of this while I was playing. If you had asked me, I would have just assumed the camera always kept the knight in the centre of the screen.
    It's very interesting because, in my head, I kind of figured "I could make a game like Hollow Knight" (because I can draw cartoons and use Unity) - but this video shows that there's quite a lot of polish and subtlety in a lot of aspects of the game - there's a reason why Hollow Knight was a success while most other 2D cartoon platformers fade in to obscurity.

  • @MI-ll3xy
    @MI-ll3xy Před 5 měsíci +1

    This is the best ever camera tutorial on YT and helped a lot! Thank you.

  • @TheWunshot
    @TheWunshot Před 6 měsíci +1

    Bravo! I'm starting to delve into creating a Metroidvania and you have really done an amazing job with this topic. I honestly didn't understand 90% of what you said, but i can tell you know what you're doing so I'll just use your techniques and try my best to replicate the settings until i understand everything better. Thanks!

  • @FrozenFlameInteractive
    @FrozenFlameInteractive Před 3 měsíci

    Absolutely incredible tutorial! Thanks so much for sharing this!

  • @Ravisherrr
    @Ravisherrr Před rokem

    I personally don't work in unity but I enjoy watching all of your videos as they are informative. Keep up the good work!

  • @rubencrespo9699
    @rubencrespo9699 Před 7 měsíci

    Thanks for this amazing tutorial, i've learned a lot

  • @ronaldosenajr7015
    @ronaldosenajr7015 Před měsícem

    Amazing camera system, thank u so much!

  • @midniteoilsoftware
    @midniteoilsoftware Před rokem +6

    I love tweening libraries. I personally like DOTween but LeanTwean looks like a fantastic option.

  • @teenymeanygames
    @teenymeanygames Před rokem +1

    Thanks for the tutorial. It's very helpful.

  • @masoncrowe
    @masoncrowe Před rokem +2

    It would be really cool to see how to implement the pan for when you push up or down in hollow knight. Also Zooming in and out! in some areas id like my camerato be more zoomed in and others zoomed out. Great video as always!

  • @cheesymcnuggets
    @cheesymcnuggets Před rokem +4

    This is something ive never really thought about, very interesting. I wonder if there are any camera tricks i could use in a 2d top-down game

    • @sasquatchbgames
      @sasquatchbgames  Před rokem +2

      guess that depends, is there shooting in your game for example? If so, slightly biasing the camera towards the mouse direction is a nice touch (like what Enter the Gungeon does)

  • @ekekw930
    @ekekw930 Před rokem +3

    Great video!

  • @wardyom
    @wardyom Před rokem

    Your video is awesomen thank u so much !!!

  • @iiropeltonen
    @iiropeltonen Před rokem +2

    Really great and I haven't seen many videos on this topic. I did feel the coding was a bit too fast even for an intermediate coder. The custom inspector was really interesting as I'm personally quite new to coding those.i liked how clean it made the component look with variable functionality ✌️✌️✌️

    • @iiropeltonen
      @iiropeltonen Před rokem

      I'm just gonna watch this again and see If I was too tired last time 😂

    • @TheOriginalDuckley
      @TheOriginalDuckley Před rokem +1

      No his videos are great but they’re so fast. That’s literally the only issue lol I have to rewind many times

  • @_HoangQuangVinh
    @_HoangQuangVinh Před 10 dny

    hello, i really like your videos, great job! And i have a question if i have more than one locked room do i have to create an additional cinemachineCamera for each of them?

  • @pdstudio4477
    @pdstudio4477 Před 10 měsíci +1

    Note that "Oversize Window" is available on Cinemachine +2.7.5 We installed Cinemachine from the package manager and Unity installed version 2.6 which make us a little lost for a while but just update and that'll do the trick. Excellent system as this is not a camera system is THE Camera System... THANKS A LOT!!!!

  • @omriyoffe366
    @omriyoffe366 Před 9 měsíci

    Great Video! Just one question, is there a way to make it so the camera will pan only after 1 second of standing on the ledge for example and not instantly?

  • @auroth6805
    @auroth6805 Před 4 měsíci

    I am saving this video and naming it CameraMan

  • @pocket-logic1154
    @pocket-logic1154 Před rokem +8

    Are you providing the code you're using here, inside the asset pack? The reason I'm asking is because you're writing code faster than anything described in Space Balls. I suppose it's either that, or a two hour video that no one would watch due to its length, but it's difficult to catch some of it, even when paused. Excellent content, nonetheless ;-)

    • @sasquatchbgames
      @sasquatchbgames  Před rokem

      eventually I will be doing that, once i can find the time to figure out the type of solution i want.
      Thanks for the support

  • @fireraccoon_
    @fireraccoon_ Před rokem

    Holy moly Bro that is pretty nice stuff! I must admin for me as begginer was hard to follow some scenes you recorded but in the end i made it. I really like yours tutorials. All of them are simply diffrent connectig scripts etc I feel like I am learning Unity since beginning and what i already know is almost nothing;) PS. i cannot find anywhere how to properly ARCHIVE a finished and built game - put it somewhere to flash (outside of hardrive) and store it in a way that you can always easly acces to it and open and modify if needed. Are you able to record somethign liek this?
    cheers!

  • @user-ey6gb3ic8g
    @user-ey6gb3ic8g Před 11 měsíci

    I've followed this step by step, and my camera works really well, except that it ignores the Cinemachine confiner. Is there an issue with the follow script overriding confiner bounds?

  • @chadmoberly7044
    @chadmoberly7044 Před rokem

    Thanks!

  • @DoubleOSevan
    @DoubleOSevan Před 11 měsíci

    Any idea why a positive X value in the Virtual Camera's Body -> Tracked Object Offset would offset the camera behind the player? It shows correctly in the editor, but once game starts it flips behind the character. A negative value positions it correctly like in the video. I suspect it's something in the code at runtime, but it looks identical to your code.
    Got a long ways to go, but tutorials like yours are a massive help! Thanks! ✌

  • @niallg8918
    @niallg8918 Před 6 měsíci +2

    is there a place to look at the code as a whole I still get error messages after copying it letter for letter

  • @hanhae99
    @hanhae99 Před rokem

    bro I really like your tutorial + i never managed to make my own hollow knight like camera system but one thing is that Team cherry uses perspective camera but your tutorial is based on Y Rotations. which means if we stick to the perspective camera(Not the orthographic camera) then i makes a z axis bounce. If you checked about this then your the best anyway thanks for this lovely video

    • @chillCatto
      @chillCatto Před 9 měsíci +2

      Have you solved z axis bounce?

    • @FluoLente
      @FluoLente Před 9 měsíci +1

      To avoid the rotation problem you could have the camera follow object interpolate it's position instead. Something like: distance * playerObject.transform.forward as a target location, so when the player rotates instantly on Y, the follow object then interpolates towards a desired offset location from the player but the z position remains a fixed value.

    • @hanhae99
      @hanhae99 Před 9 měsíci

      @@FluoLente thanks for the reply should try this when i get home !

  • @jonathanstrong9764
    @jonathanstrong9764 Před 9 měsíci

    Nice video! Is this project file on gitgub?

  • @nikhilvardhantawania4591
    @nikhilvardhantawania4591 Před 6 měsíci +1

    There are channels hidden like gems... Like Yours SUBBED

  • @juanbelmonth1594
    @juanbelmonth1594 Před 7 měsíci

    Does it work in the already compiled version? The desktop version that you open from the icon

  • @engineergaming3830
    @engineergaming3830 Před měsícem

    you can also put the camera on a child object of the player (like a wallcheck) to get the offset without using any code

  • @ArenSpace
    @ArenSpace Před rokem +2

    Great tutorial! The only issue I'm having with the system is that if i go into another room and immediately turn around and go back in, the camera doesnt swap back to the room I'm actually in

    • @ArenSpace
      @ArenSpace Před rokem +2

      nevermind, I had the swapcamera call in OnTriggerEnter. I moved it to Exit and now we're all good XD

    • @pdstudio4477
      @pdstudio4477 Před 10 měsíci

      @@ArenSpace same happened to us....

  • @benbrown3039
    @benbrown3039 Před 7 měsíci

    This is a great tutorial overall! I have one request though, when I was trying to break this after using it, I noticed that when you rapidly flip your character the camera bounces from left to right multiple times trying to keep up even after the player is done moving. Can you come up with a quick fix for this?

    • @peterdong5943
      @peterdong5943 Před 3 měsíci +1

      I have the same issue here. I think the problem is that all of the coroutines that were triggered will not stop until flipYRotationTime is run off. All of the coroutines fight for the rotation of the object at the same time, which caused the camera to jitter left and right.
      You can fix this issue by stoping the last called coroutine.

      public void CallTurn()
      {
      if (turnCoroutine != null)
      {
      StopCoroutine(turnCoroutine);
      }
      turnCoroutine = StartCoroutine(FlipYLerp());
      }

  • @kenneth5095
    @kenneth5095 Před 15 dny

    Instead of doing anything of the direction bias part just increase the lookahead time it is honestly way easier and you barely notice the difference if you put the value at something like 0.20 and then play with the other values to make it look good. I was trying to make the direction bias work for an hour but couldn't. I believe just changing the lookahead time is better than doing allat showed here 3:30 but correct me if I am wrong. The same goes for the Y bias when.jumping or falling, just adjust the values in cinemachine

  • @heirian
    @heirian Před 3 měsíci +6

    Following this tutorial is mentally exhausting.
    The explanations are good, but everything on the screen goes by so quickly that you don't have any time to process the information.
    Then you have to pause and come back to try to read and understand something, but as a result you soon get lost in the explanation.
    In the end, with a lot of effort, you understand, but the mental cost is much higher than necessary, especially for those just starting out.

  • @shangxiangsun3287
    @shangxiangsun3287 Před 9 měsíci

    anyone know which video had the Editor scipt

  • @gaoqiangzhou9960
    @gaoqiangzhou9960 Před 5 měsíci

    great..great...

  • @ChrisMyt
    @ChrisMyt Před rokem +3

    Direction bias section from the video does not work with perspective camera, I get a weird zoom in and zoom out effect when turning, the z position gets changed for some reason on the camera
    Any fix for this?

    • @sasquatchbgames
      @sasquatchbgames  Před rokem +2

      You'll need to take a different approach for a perspective camera:
      A) forget about the 'CameraFollowPlayer' object - have the camera follow the player instead.
      We can just adjust the 'ScreenX' directly instead with this code:
      #region Direction Bias
      public void CallCameraFaceDirection()
      {
      _cameraFaceDirection = StartCoroutine(FacingDirectionBias());
      }
      private IEnumerator FacingDirectionBias()
      {
      float startPoint = _framingTransposer.m_ScreenX;
      float endPoint = DetermineEndPoint();
      float lerpedAmount = 0f;
      float elapsedTime = 0f;
      while(elapsedTime < _flipScreenTime)
      {
      elapsedTime += Time.deltaTime;
      lerpedAmount = Mathf.Lerp(startPoint, endPoint, (elapsedTime / _flipScreenTime));
      _framingTransposer.m_ScreenX = lerpedAmount;
      yield return null;
      }
      }
      private float DetermineEndPoint()
      {
      if (_player.IsFacingRight)
      {
      return 0.45f;
      }
      else
      {
      return 0.55f;
      }
      }
      #endregion
      Call CameraFaceDirection once in start, and each time the player turns around.
      Don't forget to get rid of any TrackedObjectOffset in the X that's already there.
      You'll need a reference to your player in the CameraManager, but that should do the trick

    • @Tigerwhite28
      @Tigerwhite28 Před 2 měsíci

      @@sasquatchbgames I'm a beginner and not sure what to do. Is anyone willing to explain this to me? I have a prespective camera but I don't know where to put this code

  • @andranikmag5240
    @andranikmag5240 Před 3 měsíci

    The direction bias looks weird on my project, i get a whole turn and see the sides of my project, and i am not sure where i went wrong. Does anyone posssibly know a fix for this?

  • @alecraigan4568
    @alecraigan4568 Před 11 měsíci

    Hello! for some reason as the confiner is not working correctly, I started working with polygon collider but I got tired of it and tried to switch to composite, I'm not getting any errors and I change the order so the cameras get the composite collider first and it should be working, but it's not, for the reason the camera just ignores the boundaries, any ideas what I can do?

    • @Westerncreek
      @Westerncreek Před 2 měsíci

      I know its been a long while, but the solution is to set the scale of the cameracoliderobj on 1, and then change the sizes of the box colliders 2d to fit the shape(I was struggling with this for weeks)

    • @alecraigan4568
      @alecraigan4568 Před 2 měsíci

      @@Westerncreek thank you very much, if only I was more observant of the values on the video I wouldn't be having a hard time with the boundaries, too deep in my project to redo all the hitboxes but hopefully this will help someone in the future, have a good one 👍

  • @GrilliBD
    @GrilliBD Před 10 měsíci

    my project uses the sprite renderer flip system to flip the player. Is it possible to make this camera system work in that way or is it necessary to use Y rotation to turn the player?

    • @TripFAU
      @TripFAU Před 6 měsíci

      A bit of a late response, but I skipped that part and it didn't impact anything else. The camera won't be able to give slight indication of the direction your facing though, it'll just remain locked onto you

    • @hadichamli
      @hadichamli Před měsícem

      I guess you could add two follow objects and change them based on which direction the sprite is flipped. (late response)

  • @laugh_topia
    @laugh_topia Před 2 měsíci

    can i please get the direction bias script

  • @oelwechsel
    @oelwechsel Před rokem

    Is there any Fix to the problem of the cinemachine 2d Confiner and the camera pan on edges? if the Boundary is too tight it will affect the Camera Movement

    • @sasquatchbgames
      @sasquatchbgames  Před rokem +1

      I haven't found a fix for it :(

    • @oelwechsel
      @oelwechsel Před rokem

      @@sasquatchbgames ok thanks for the answer. The video was a gold mine! Big thanks!

  • @user-xu3di9zp6l
    @user-xu3di9zp6l Před rokem

    is this using the standard 2d or the 2d urp?

  • @niallg8918
    @niallg8918 Před 5 měsíci

    I get so many using directive errors. Does anyone know how to fix it

  • @user-mx5xh4yi5r
    @user-mx5xh4yi5r Před 5 měsíci

    할나 2D 카메라 시스템 ㅇㄷ

  • @Ddotkay
    @Ddotkay Před 10 měsíci

    First off thanks for the tutorial, I am having an issue and Im not sure if its a bug on your end or just an incorrect implementation by me. When the player moves quickly between left and right and then goes in one direction the camera finishes the damping and then snaps to catch up but the snapping effect is quite jarring. Its hard to describe what i mean but hopefully you get what I mean.

    • @peterdong5943
      @peterdong5943 Před 3 měsíci

      I have the same issue here. I think the problem is that all of the coroutines that were triggered will not stop until flipYRotationTime is run off. All of the coroutines fight for the rotation of the object at the same time, which caused the camera to jitter left and right.

    • @peterdong5943
      @peterdong5943 Před 3 měsíci

      You can fix this issue by stoping the last called coroutine.
      public void CallTurn()
      {
      if (turnCoroutine != null)
      {
      StopCoroutine(turnCoroutine);
      }
      turnCoroutine = StartCoroutine(FlipYLerp());
      }

  • @petes5436
    @petes5436 Před 11 měsíci

    I'm not sure why the y damp doesn't get affected when the fall speed threshold is a negative value, I've tried everything

    • @HomelessHunt
      @HomelessHunt Před 5 měsíci

      hi! did you find the solution?
      I have the same problem

  • @floodedfish
    @floodedfish Před rokem +1

    can you link the code?

  • @thebeangod7752
    @thebeangod7752 Před 5 měsíci +1

    Can you pls rewrite all this code using only "If" statements so i can understand it 😞

  • @user-gu1lg6tg1q
    @user-gu1lg6tg1q Před rokem +1

    very good ,but I cant see your code🥺

  • @kenneth5095
    @kenneth5095 Před 18 dny

    Is the re anyone willing to give a copy paste of the code? I really need this for my game but I am running low on time. Please. Help

  • @adeleutamene7603
    @adeleutamene7603 Před 2 měsíci

    Can we get the full code?

  • @monkeypwners
    @monkeypwners Před 8 měsíci

    The bounderies do nothing for me. I have BoxCollider2D and CompositeCollider2D but it doesn't work. I can't even see the yellow outline for the bounderies on the Cinemachine Cam. Help

    • @monkeypwners
      @monkeypwners Před 8 měsíci +2

      If anyone has this problem, make sure to check the scale of your bounderies... I had expanded the collider using the scale of the gameobject and not the collider itself... Problem solved I guess!

    • @paulricordeau1370
      @paulricordeau1370 Před 5 měsíci

      man you just saved my life, i struggled with this issue for days X) so yes for anyone having the same problem with confiner 2d, make sure you scale the box collider with the OFFSET and SIZE of the Box Collider, not the sacle of the game object @@monkeypwners

  • @KalponicGames
    @KalponicGames Před měsícem

    Btw if you wanna build everything from scratch is like saying I am going mine all the minerals to build my pc . I think it's wrong conception that I must build everything from scratch. Plugins are awesome. It's like using intellisense in visual studio. 🎉

  • @striferules
    @striferules Před 3 měsíci +1

    Your tutorials are great, but I think you should do the coding part a little slower. It's hard to keep up

  • @kenneth5095
    @kenneth5095 Před 15 dny

    Its telling UserInput does not exist in the current context when trying to do this part 3:36 can somebody pleaseeeeeee help me?

    • @kenneth5095
      @kenneth5095 Před 15 dny

      Code:
      private void TurnCheck()
      {
      if (UserInput.instance.moveInput.x > 0 && !IsFacingRight)
      {
      Turn();
      }
      else if (UserInput.instance.moveInput.x

  • @SamuelForFun
    @SamuelForFun Před 14 dny

    Can I implement it in godot?

  • @AetherXIV
    @AetherXIV Před 2 měsíci

    Here is a code version of his Framing Transposer Settings:
    void InitFramingTransposer()
    {
    CinemachineFramingTransposer transposer = vCam.GetCinemachineComponent();
    transposer.m_TrackedObjectOffset = Vector3.zero;
    transposer.m_LookaheadTime = .05f;
    transposer.m_LookaheadSmoothing = 1f;
    transposer.m_LookaheadIgnoreY = true;
    transposer.m_XDamping = .75f;
    transposer.m_YDamping = 2f;
    transposer.m_ZDamping = 0f;
    transposer.m_TargetMovementOnly = true;
    transposer.m_ScreenX = .5f;
    transposer.m_ScreenY = .5f;
    transposer.m_CameraDistance = 10;
    transposer.m_DeadZoneWidth = 0;
    transposer.m_DeadZoneHeight = 0;
    transposer.m_DeadZoneDepth = 0;
    transposer.m_UnlimitedSoftZone = false;
    transposer.m_SoftZoneWidth = .2f;
    transposer.m_SoftZoneHeight = .35f;
    transposer.m_BiasX = 0f;
    transposer.m_BiasY = 0f;
    transposer.m_CenterOnActivate = true;
    }

  • @auroth6805
    @auroth6805 Před 4 měsíci

    why is this camera system more complex then any game I made

  • @talmalobani3144
    @talmalobani3144 Před 10 měsíci +1

    bro why u have so great tutorial but to get the code I have to sign up to your patreon this is so upsetting me i hope you make this code open source bec if not i will be very sad

  • @Coco-gg5vp
    @Coco-gg5vp Před rokem +1

    First

  • @FortbloxNET
    @FortbloxNET Před 2 měsíci +3

    as far as i understood the story of hollow knight, the devs are actual more familiar in creating good arts but less in actual coding. this is why they used PLAYMAKER in unity to use visual scripting more over actual coding the game. so i either they have a huge fucked up visual graph for the camera behaviour or this is way to much overthinking. super complicated. i don't think these 2 devs thought about sth like that and made it in visual scripting. there is probably an easier way and easier explanation.

    • @electrodev.
      @electrodev. Před 3 dny

      make smth better then if ur so good

  • @akael8350
    @akael8350 Před 5 měsíci

    Very thanks for the guide. I love your works.
    Just one improvement. If you have problem when you load new scene with the target player follow camera add in the camera manager :
    private void Start()
    {
    for (int i = 0; i < allVirtualCameras.Length; i++)
    {
    if (allVirtualCameras[i].CompareTag("CameraPlayer"))
    {
    allVirtualCameras[i].Follow = Player.instance.transform;
    }
    }
    }
    and change the camera follow player with a new tag : "CameraPlayer"

  • @alperakin2561
    @alperakin2561 Před 17 hodinami

    hey i have a problem. Camera swap is working proberly when the player pass through left to right, but it doesnt work when the player pass through right to left.
    Here is the code:
    public void SwapCamera(CinemachineVirtualCamera cameraFromLeft, CinemachineVirtualCamera cameraFromRight,Vector2 triggerExitDirection)
    {
    if(_currentCamera == cameraFromLeft && triggerExitDirection.x > 0f)
    {
    Debug.Log("Değişti1");
    cameraFromRight.enabled = true;
    cameraFromLeft.enabled = false;
    _currentCamera = cameraFromRight;
    _framingTransposer = _currentCamera.GetCinemachineComponent();
    }
    else if(_currentCamera == cameraFromRight && triggerExitDirection.x < 0f)
    {
    Debug.Log("Değişti2");
    cameraFromLeft.enabled = true;
    cameraFromRight.enabled = false;
    _currentCamera = cameraFromRight;
    _framingTransposer = _currentCamera.GetCinemachineComponent();
    }
    }

  • @sabeelm9
    @sabeelm9 Před 4 měsíci

    At 5:25 I had to change the tweening logic as it was incredibly buggy when the player was constantly changing direction. Here's my code:
    if (LeanTween.isTweening(gameObject))
    {
    LeanTween.cancel(gameObject);
    }

    LeanTween.rotateY(gameObject, DetemineEndRotation(), _flipYRotationTime).setEaseOutSine();

  • @kenneth5095
    @kenneth5095 Před 12 dny

    For some reason it says that this code. Is not set to an instance of an object. How do I fix it. I already did everything in the tutorial. Pleaseeeee help
    CameraManager.instance.PanCameraOnContact(customInspectorObjects.panDistance, customInspectorObjects.panTime, customInspectorObjects.panDirection, false);