Search Unity

Fine control over Update

Discussion in 'Cinemachine' started by owen_proto, Feb 14, 2019.

  1. owen_proto

    owen_proto

    Joined:
    Mar 18, 2018
    Posts:
    120
    I need the camera to update at a very specific time within LateUpdate. What are the critical methods I would need to call in another script to update my camera exactly when I need it, or is this even possible?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Camera is updated in CinemachineBrain's LateUpdate method. You can set the script execution order so that your script is updated before or after. By default, Brain updates as late as possible in the cycle, to give all targets a chance to move.

    You can also hook into the Brain's CameraUpdated event, which is emitted whenever the camera is updated.
     
  3. owen_proto

    owen_proto

    Joined:
    Mar 18, 2018
    Posts:
    120
    For some reason I thought that was the first thing I checked, but apparently not!

    Event may be a cleaner way to accomplish this, preventing the need to modify CinemachineBrain or make a copy of it. Thank you!
     
    Gregoryl likes this.
  4. owen_proto

    owen_proto

    Joined:
    Mar 18, 2018
    Posts:
    120
    I need to have the brain script running at default time in the script execution order in able to accomplish it updating exactly where I need it too I think. When I try to remove it from the execution order it automatically places itself back where it was. How am I able to change that?
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    hmmm... there may not be a way without customizing the package (by embedding it in your assets).
    An easier way might be to move your other scripts to update after the brain.
     
  6. owen_proto

    owen_proto

    Joined:
    Mar 18, 2018
    Posts:
    120
    I tried that, what I'm trying to accomplish is sandwiching the camera update between two other operations. Perhaps I'll have to explore splitting that functionality off into another script then. Thanks!