Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Change virtual camera's follow target via script

Discussion in 'Cinemachine' started by gon777, Dec 4, 2017.

  1. gon777

    gon777

    Joined:
    Dec 20, 2016
    Posts:
    7
    Hi,

    I want to change the follow target of my virtual cam to a different game object via script while game in progress.

    I managed to reference the whateverCinemachineVirtualCamera.Follow = whateverGameobject.transform, but it doesn't seem enough to make it work (reference changed but camera is not following at all).

    What else is needed to make the virtual camera to work? Much appreciated.
     
    Last edited: Dec 4, 2017
  2. gon777

    gon777

    Joined:
    Dec 20, 2016
    Posts:
    7
    Sorry it was actually following the object..
     
  3. Adam_Myhill

    Adam_Myhill

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    342
    There's an example script in the demo scenes - check here - it has example of how to switch follow objects. Let me know if that's not working for you
    upload_2017-12-4_17-48-21.png
     
    DungDajHjep likes this.
  4. aphixe

    aphixe

    Joined:
    Sep 5, 2012
    Posts:
    7
    Doesn't exist any more?
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    @aphixe You need to import it into your project:

    upload_2018-9-2_18-59-17.png
     
    DungDajHjep likes this.
  6. blekkh

    blekkh

    Joined:
    Feb 14, 2019
    Posts:
    19
    Doesnt exist any more?
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    Now it's in the Package Manager:

    upload_2020-5-10_12-57-34.png
     
    DungDajHjep likes this.