Search Unity

Take control of when CinemachineBrain updates camera positions.

Discussion in 'Cinemachine' started by Lipoly, Aug 27, 2018.

  1. Lipoly

    Lipoly

    Joined:
    Feb 11, 2014
    Posts:
    42
    Is there any way to take control over exactly when the CinemachineBrain updates its camera's position? A method like brain.UpdateCamera() which I call after everything is positioned properly for that frame. The current options for Late/Fixed/SmartUpdate are not sufficient for me.

    The reasoning is that I have UI elements which represent world-position objects, and they therefore need to update based on the camera's position. Without the ability to dictate when the camera updates (and can therefore be certain of its final frame-position) I occasionally end up using stale data and an element may appear "one frame behind." This issue is exacerbated b/c the game supports very high time-compression, so one frame worth of camera movement might be quite large and cause UI elements to jitter around and not be precisely positioned.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Cinemachine updates the individual vcams according to the Brain's Update Method, but the actual Camera's transform is always set by CinemachineBrain in LateUpdate. CinemachineBrain has a script execution order setting of +100. If you have another script that depends on the Camera's position, you can set its script execution order to something >100 and use LateUpdate.
     
  3. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    Can I set the order of Cinemachine brain in 10500 ?.
    I ask this question because I am using an asset called Final IK and this asset modifies the transform giving to Cinemachine a wrong position.
    I set up Cinemachinebrain in excecution order 10500 and I do not see that it breaks anything. I didn't have time to investigate whether it affects or not, that's why I prefer to ask :p

     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You can set the execution order to what you want. It won't break anything, so long as it's happening when it needs to.
     
    churi24 likes this.
  5. mariusgeorge

    mariusgeorge

    Joined:
    Jan 29, 2016
    Posts:
    18