Search Unity

Cinemachine freelook and main camera dont act the same

Discussion in 'Cinemachine' started by ZzEeRO, Sep 2, 2019.

  1. ZzEeRO

    ZzEeRO

    Joined:
    Aug 30, 2018
    Posts:
    3
    I'm using cinemachine freelook camera to create a 3rd-person demo,but when I use Camera.WorldToScreenPoint() or make a direction follow main camera's forward vector,it always has some offset or damping during mouse moving.How can i solve this?I dont know how to set it if i want the cinemachine exactly match the main camera,with no damping or lag.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844
    It's because you're calling WorldToScreenPoint() before the camera has been positioned for that frame, so are getting data based on the previous frame's position. Camera position is updated in CinemachineBrain.LateUpdate(), and CinemachineBrain has a high script execution order. You can call WorldToScreenPoint from LateUpdate in a script that has even higher script execution order, or hook into CinemachineCore.CameraUpdatedEvent, which is invoked immediately after the camera has been positioned.
     
    Last edited: Sep 3, 2019
  3. ZzEeRO

    ZzEeRO

    Joined:
    Aug 30, 2018
    Posts:
    3
    Thank you.So I need to get camera‘s information after Cinemachine has set main camera's position?I tried to get those information in LateUpdate() it still not working. Or can you tell me some details about the execution order?Does the CinemachineBrain execute before my scripts?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844
    You need to set your script's execution order to be after ConemachineBrain, or use the event.

    upload_2019-9-3_8-12-46.png
     
  5. ZzEeRO

    ZzEeRO

    Joined:
    Aug 30, 2018
    Posts:
    3
    Thank you very much.I solved it by modify some code in CinemachineBrain.:D
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844