Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Timeline, cinemachine and time scale - Fixed timestep

Discussion in 'Cinemachine' started by Suduckgames, Nov 23, 2018.

  1. Suduckgames

    Suduckgames

    Joined:
    Nov 28, 2016
    Posts:
    218
    I have a timeline when a boss appear. Before playing the timeline I just stop the time setting TimeScale to 0 and play a cutscene to show the boss. In order to make it work the update metod of the Timeline and the animator (on the camera) is set to "unscaled time". This was working great, but suddenly it stopped to work.

    After a lot of search, I found that the "Fixed timestep" also affect the cinemachine camera. So if i change the fixed timestep of my game the behaviour of the camera change.

    Is there any way to make the timeline or cinemachine to ignore the fixed timestep? Since I put the Unscaled tme on the update metod, I don't expect it to be influenced by fixed timestep
     
    ericksm703 likes this.
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    There is a setting on the Brain to ignore timescale, so that cameras will keep working in realtime even when time is frozen. Is that what you're looking for?
     
  3. Suduckgames

    Suduckgames

    Joined:
    Nov 28, 2016
    Posts:
    218
    Yes, Thank you very much! Didn't expect it at the brain. Since maybe I want to have cameras affected by timescale and cameras who don't
     
    Tigromvivo likes this.
  4. cvadiablo

    cvadiablo

    Joined:
    Jun 2, 2017
    Posts:
    19
    Hello, I have the same issue but I found that Ignore time scale does not work when I set Time.timeScale = 0 to pause the game.
    Only if I set the Update Method to LateUpdate works,but the player character movement will be very wired becuz I am using rigidbody move...
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    Yes this is a bug that is fixed for CM 2.6
     
  6. cvadiablo

    cvadiablo

    Joined:
    Jun 2, 2017
    Posts:
    19
    good to hear that ! so in my case.. use smart update?

    I update CM to 2.6.0 preview 5, but the issue still exsits...
    When I pause the game(time scale = 0)
    1、if select smart update with Ignore time scale. the vcam damping will stop when pause.and continue when resume.
    2、if select late update with Ignore time scale. the vcam will damping during pause ( that's what I want), but the player character use rigid body move look like weird...

    and...
    I found that some problem with the cinemachine impulse.
    For example if I want to have a camera impulse during game pause ( like talking with the NPC, I will pause the game, then I need to have a camera shake ), I used cinemachine impulse.I trigger it at pause state, but the impulse will come after the game is resume.(Ignore time scale is checked)
     
    Last edited: May 3, 2020
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    Yes, my mistake. Sorry to mislead you.

    In fact brain.IgnoreTimescale can't work for vcams that are tracking RigidBodies without producing the juddering effect that you see in LateUpdate.

    I think the solution in your case is that when you pause the game, switch the brain to LateUpdate, and when the game is running, switch it back to FixedUpdate.

    The Impulse subsystem has its own independent IgnoreTimeScale setting. Use ImpulseManager.Instance.IgnoreTimeScale.
     
  8. cvadiablo

    cvadiablo

    Joined:
    Jun 2, 2017
    Posts:
    19
    Thank you for the reply ! It helps a lot !
     
    Last edited: May 23, 2020
    Gregoryl likes this.
  9. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
    Hi there!

    I am currently doing a sort of slow motion where basically nothing is moving but the player!
    It does work pretty well expect for the camera :/
    Since it is tracking a rigidbody, switching to LateUpdate does make it work for ignoring timescale but it does look pretty bad then.

    Any chance this will be updated in the future to include FixedUpdate as well?

    EDIT: After checking the source code, the GetEffectiveDeltaTime has a boolean as a parameter that basically ignores the ignore scaled time parameter using the FixedUpdate or SmartUpdate. Any reason why there is such a parameter?

    Thanks in advance :)
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    Cameras following RigidBodies must animate on the physics clock. I'm not quite sure I understand the problem you're having. If all is slowed down except the player, and the camera is following the player, why would you slow down the camera? Doesn't it still need to track the player?
     
  11. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
    Well I might find another option but currently I basically set the timescale to something very low (along with fixedtimescale) and run the player on unscaled deltatime.

    I might just actually only impact the enemies: keep the same timescale and just freeze the enemies. Might make more sense
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    That might be better. If the player is a RigidBody then running it on unscaled might give choppy results
     
  13. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
    Sounds good thanks
     
  14. unity_C6B4FE2D65EE0939EA39

    unity_C6B4FE2D65EE0939EA39

    Joined:
    May 10, 2021
    Posts:
    3
    @Gregoryl , you are a life-saver! I used both impulses and manual zooming with timeScale 0, I was totally stuck until I read your answers. The following lines fixed my issues!

    Code (CSharp):
    1.  
    2. CinemachineImpulseManager.Instance.IgnoreTimeScale = true;
    3. Camera.main.GetComponent<CinemachineBrain>().m_UpdateMethod = CinemachineBrain.UpdateMethod.LateUpdate;
    4. Camera.main.GetComponent<CinemachineBrain>().m_IgnoreTimeScale = true;
    5.  
     
  15. ookk47oo

    ookk47oo

    Joined:
    Mar 17, 2017
    Posts:
    80
    Finally I find this solution works , many thanks !!!
     
    Gregoryl likes this.
  16. Deleted User

    Deleted User

    Guest

    I just found out the IgnoreTimeScale setting is not working on Cinemachine 2.6.11 and up when using a Freelook camera with the speed setting set on "MaxSpeed".
    The issue does not happen when using "InputValueGain" (but this setting has a bug which makes it framerate dependant), nor does it happen on 2.6.10.
     
  17. Synergy192

    Synergy192

    Joined:
    Jun 12, 2017
    Posts:
    2
    I think I'm having a similar issue @Gregoryl - previously I had IgnoreTimeScale disabled to make the camera stop moving when the time scale was 0, but changing the FreeLookCamera to use Input Value Gain instead of Max Speed results in the camera ignoring the time scale, despite the setting on the Cinemachine brain.

    I'll think fix this later in my project when I start using the new input system, but there is definitely is a bug there when using the old input system.
     
  18. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    What version of Cinemachine?