Search Unity

Assign new targets for Animation Track

Discussion in 'Cinemachine' started by MaximumTre, Aug 8, 2019.

  1. MaximumTre

    MaximumTre

    Joined:
    Nov 28, 2015
    Posts:
    80
    I want to dynamically change the target for an Animation Track. Is this possible? I looked at the documentation and cannot figure out what I'm supposed to use to do this.
     
  2. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    416
  3. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    155
    Create an Animation Track, add your Virtual Camera to the Track (it will add an Animator component on the Virtual Camera).

    Then, where you want to set a specific target on the Timeline, click the record button on the Animation Track with your Virtual Camera, select the Virtual Camera in the hierarchy, and set your Target option. The property will be saved on your Timeline track.

    That is the only way that I have found so far.
     
  4. MaximumTre

    MaximumTre

    Joined:
    Nov 28, 2015
    Posts:
    80
    You know, I hadn't thought to try this, but that won't allow me to access it in code. I'll ask this question in the appropriate forum, I've been busy with other areas of my project. Thanks for the answers.
     
  5. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    155
    You could create a custom Timeline track/clip/behaviour which will take a Transform as a LookAtTarget (and potentially your Virtual Camera you want to adjust), and then on the first frame it will set the Virtual Camera's LookAt to your Clip's LookAt target, and when the clip is complete you can reset the to what it was before LookAt if you need to do that (track the original LookAt in your clip with a private Transform).

    I think you can probably do everything with Cinemachine+Timelines, but sometimes its quite confusing what should be animated or modified at runtime with custom logic, versus what a Cinemachine Shot will achieve on a timeline.