Search Unity

Assigning the Follow target of vcam2d through code

Discussion in 'Cinemachine' started by Zoraph, Nov 23, 2018.

  1. Zoraph

    Zoraph

    Joined:
    Aug 23, 2012
    Posts:
    29
    How can I set a target in a 2d vcam (The Follow field) through code. It needs to be set at runtime since the player is not in the scene when the game starts and I can't find it in the API. The follow field to be none existant and I didn't find anything about it over the web.

    ??? = FindGameObjectWithTag("Player").transform;

    What goes there with cinemachine? How can I set this at runtime for the Follow field in the 2d vcam?
     
  2. boyqnam9x

    boyqnam9x

    Joined:
    Jun 2, 2018
    Posts:
    3
    same question
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    vcam.Follow = bla;
    vcam.LookAt = bla;