Search Unity

Cinemachine smooth World Up override

Discussion in 'Cinemachine' started by Mikhail94, Jun 22, 2019.

  1. Mikhail94

    Mikhail94

    Joined:
    Dec 22, 2015
    Posts:
    35
    Is there any way to smoothly rotate the camera when world up changing? Or at least keep the camera position after change.

    Right now, I created a dummy gameobject that smoothly rotates like player (which is used to override). But I would like to avoid creating unnecessary entities.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
  3. Mikhail94

    Mikhail94

    Joined:
    Dec 22, 2015
    Posts:
    35
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Can you show a picture of your vcam inspector?
     
  5. Mikhail94

    Mikhail94

    Joined:
    Dec 22, 2015
    Posts:
    35
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Your setup is wrong.
    You need to have the main camera with the Brain as one top-level object, and the freeLook as another. Each vcam is a separate game object, and the brain will track the current active one.
     
    Shamantiks likes this.
  7. Mikhail94

    Mikhail94

    Joined:
    Dec 22, 2015
    Posts:
    35
    Thanks for the help, but it still does not work -_-

    Now I have two separate top-level objects:
    MainCamera (Brain, World Up - None)
    CM FreeLook (FreeLook and Camera Up Extension script)

    PostPipelineStageCallback is invoked and state.ReferenceUp = myTarget.up is changed, but during the next invoke it contains default value and Free Look Orbit in editor does not change its rotation.

    It looks like something overwrites it. I have already tried a new clear scene - all the same.
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    I made a quick scene to test it with a free look. It seems to work.
    What versions of Unity/CM are you using?
    What is the binding mode of the freeLook?
    Is the target objects a separate game object?
     
  9. Mikhail94

    Mikhail94

    Joined:
    Dec 22, 2015
    Posts:
    35
    @Gregoryl
    Unity 2019.1.2.f1
    CM 2.3.4
    FreeLook binding mode: Simple follow with world up
    The target is separate object that can move & rotate.

    For testing I created a new scene only with the most necessary.

    This is how the free look camera orbit changes if I set my target in MainCamera (CM Brain) -> World up. This I am trying to achieve, but with my control of smoothness.
    https://i.imgur.com/vW1R900.gif (at the beginning delay for a few seconds, sorry)

    And this if I set world up only through a script (just state.ReferenceUp = myTarget.up;):
    https://i.imgur.com/Q58BcFA.gif (free look camera orbit does not change at all)
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Can you send me the scene? Ideally, exported as a unitypackage. That will save us some back-and forth.
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    If you're just trying to have the up match the target, then a good option is to use LockToTarget binding mode, which sets the vcam's up properly. Then you don't need the custom up script.

    Use damping to keep things smooth:

    upload_2019-6-23_15-56-54.png
     
  12. Mikhail94

    Mikhail94

    Joined:
    Dec 22, 2015
    Posts:
    35
     

    Attached Files:

  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Thanks for sending.

    So in fact it's working - the red gizmo is just drawn incorrectly (it's a bug in the Gizmo Drawer for the FreeLook - we will fix it).

    I do think you'll get better results with the LockToTarget suggestion I made above. Would that approach work for you?
     
  14. Mikhail94

    Mikhail94

    Joined:
    Dec 22, 2015
    Posts:
    35
    Are you sure? Because when I try to move the camera, it moves and stops exactly in gizmo, regardless of the current target rotation.

    Unfortunately, this does not suit me. Without going into details - I need to smoothly change the world up only at certain moments, not all time.

    Anyway, thanks for the help. I think in my case my initial decision will suit me: dummy object which I use to override world up and just rotating it at the right time for me.