Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[SOLVED] Best practices for underwater camera (not related to post processing)

Discussion in 'Cinemachine' started by Mars91, Oct 27, 2021.

  1. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Working on an underwater camera for my third person character and I came our with this idea:

    Having one camera for when the player is swimming underwater and having another camera for when the player is not below water level.

    What I cannot get my head around is: I need two cameras and two different collider, no problem but how can I toggle the underwater camera so that is underwater and not where the previous camera used to be?
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    When the character is under water, it means that the character's transform is underwater, for example
    character.transform.y < waterLevel
    , right? So this means you know that the underwater camera has to be below waterLevel with respect to your character.

    You can also use this condition to switch between your vcams.

    Assuming, you are using ThirdPersonFollow for your UnderWater vcam, and the UnderWater vcam is following the character. Then you have to make sure that
    ShoulderOffset.y + VerticalArmLength < 0
    .

    I might have misunderstood what you are asking, in that case, please clarify :)
     
  3. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Hi,
    Thank you for your answer, I'm using FreeLook camera, is there another camera type I'm not aware of?

    Anyway yes detecting when player is underwater is not a big deal, so is switching between cameras, the issue is keeping the underwater camera always underwater.

    Can you better explain
    ShoulderOffset.y + VerticalArmLength < 0
     
  4. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Ok upgraded to the last version of cinemachine and 3rdPersonFollow seems pretty cool but I don't get how to rotate the camera, am I missing something?
     
  5. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    I basically done with done, the only big issue is that when I switch camera since both cameras collide with the water layer there's a bump in Z position since I have cinemachine collider with pull camera forward.
    I tried disabling inherit position but nothing changed.
     
  6. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Managed to achieve a decent result using cut as blend but I still would like to have a better solution