Search Unity

Is there a way to freeze a cinemachine cam movement?

Discussion in 'Cinemachine' started by laxhen, Jul 21, 2019.

  1. laxhen

    laxhen

    Joined:
    Mar 3, 2019
    Posts:
    1
    I want to create a Pause screen, while still using Cinemachine
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    If you set Time.timescale to 0 that should do it
     
  3. SayAllenthing

    SayAllenthing

    Joined:
    Sep 9, 2015
    Posts:
    3
    Sorry to revive this, I'm in a similar situation with bringing up my JRPG menu while transitioning between two Virtual Cameras.

    There are plenty of reasons to keep TimeScale at 1 for a pause menu, I do all my UI Tweens programmatically for instance, not to mention a lot of pause menus show your play time increase in real time.

    Needless to say, TimeScale = 0 is a bit of a hacky way to implement a pause screen, are there any other solutions?
    Currently when I set enabled = false; on the camera it pauses for the menu, but when I re-enabled it after the menu closes it jumps to the end of the blend, which I imagine is tied to Time.time.

    I've tried to grab the Brain's ActiveBlend and try to restore it when my menu closes, but it doesn't work still.

    If there's no current solution in Cinemachine, I might make a patched version of CinemachineBlend that has an exposed Pause()/Resume().
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Might be better to implement a timescale override on the brain, replacing the current IgnoreTimescale checkbox.
     
  5. SayAllenthing

    SayAllenthing

    Joined:
    Sep 9, 2015
    Posts:
    3
    So originally I wanted to just make a wrapper, but not enough variables were accessible from the base code to have any impact.

    Here's my workaround for anyone who faces the same problem.

    When I bring up my menu mid transition,
    1: Disable the active camera on the brain, store said camera
    2: Have a PauseMenuCamera copy the main camera's transform and enable it.
    3: In code find out the remaining time from Brain.ActiveBlend, Duration - TimeSpent
    4: Set the custom blend from PauseMenuCamera -> **ANY CAMERA** to the remaining time via Brain.CustomBlends (They're a struct, so you'll have to pull it, edit it, and send it back in).
    5: When you unpause, disable PauseMenuCamera, enable the previous camera.
    6: Watch it finish the transition.
     
    Gregoryl likes this.
  6. sfr3

    sfr3

    Joined:
    Sep 14, 2019
    Posts:
    1
    I found a way to lock camera while opening canvas (when you want to lock the camera)
    By setting X Axis and Y Axis Speed (Camera sensitivity)

    Here is how to access inside a script:

    public CinemachineFreeLook cinemachineFL;


    Code (CSharp):
    1. if (opcanv.activeInHierarchy)
    2.                 {
    3.                    
    4.                     cinemachineFL.m_XAxis.m_MaxSpeed = 0.0f;
    5.                     cinemachineFL.m_YAxis.m_MaxSpeed = 0.0f;
    6.                 }
    But you need to revert the speed values after the canvas is closed.
    Easy way to do this is by creating temporary variable to store current speed, or a variable that you use for (Camera Sensitivity) or something..