Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can't seem to frame-perfectly match the main camera

Discussion in 'Cinemachine' started by Awarisu, Jul 30, 2019.

  1. Awarisu

    Awarisu

    Joined:
    May 6, 2019
    Posts:
    215
    I'm using Update() in MonoBehaviours to move Images on a screen-space Canvas based on the position of certain GameObjects and Camera.main, think of something like an always-on-top target marker.

    Normally my script runs at "Default time", which makes my markers one frame late. This is noticeable if I look around in game. If I change my MonoBehaviour in Script Execution Order to run after the Cinemachine Brain, then my markers are one frame early. Out of desperation I attempted to give my scripts the exact same execution order value as the brain, but the brain just changes its own number in response whenever I do that.

    What's the correct setting to achieve a frame-perfect match?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    The most reliable method is to use CinemachineCore.CameraUpdatedEvent. It gets issued immediately after the main camera is repositioned.
     
    Awarisu likes this.
  3. Awarisu

    Awarisu

    Joined:
    May 6, 2019
    Posts:
    215
    That did the trick, thank you.
     
    Gregoryl likes this.