Search Unity

Virtual camera always starts at 0,0,0

Discussion in 'Cinemachine' started by georgeq, Sep 28, 2018.

  1. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    I have a camera rig that includes a virtual camera, everything works fine, except for the fact that when I instantiate the prefab, the virtual camera always begins at 0,0,0 then starts to follow the target object. This behavior is inconvenient in many ways, and I just can't override it, no matter what I do. Is there any solution for this?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    When do you set the vcam's Follow target?
     
  3. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    On the fly after instantiating the prefab, on Awake. I even tried to set all damping parameters to zero (on Awake also), but the first frame is always taken from 0,0,0
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Is it possible that the target object is not correctly positioned at that time? Is the target object part of the prefab? What version of Unity, and what version of CM?
     
  5. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    Unity 2018.3.03b, Cinemachine 2.2.7

    No, the target is correctly located and the targets is not part of the prefab. The target is instantiated then the camera rig is instantiated and finally the target is assigned to the virtual camera, all this is done on the game controller's Awake.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I tried to repro your issue, but it works perfectly for me. Maybe I'm misunderstanding something.

    Create an empty project, install Cinemachine, then import this package and run the scene. It does what (I think) you're trying to do, and there is no bad frame.
     

    Attached Files:

    Last edited: Sep 28, 2018
  7. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    You are right it works fine. I forgot I added a new component to my player and I didn't update the link reference. Sorry my fault!