Search Unity

Enable / disable avatar mask in timeline via script

Discussion in 'Timeline' started by bmangameswhat, Apr 7, 2020.

  1. bmangameswhat

    bmangameswhat

    Joined:
    Apr 30, 2019
    Posts:
    5
    I'm having a hard time finding an answer to this question, so figured I'd see if anyone here can help.

    I'm working on a turn-based RPG battle system and I'm using timeline for each attack. I need to be able to apply an avatar mask to the attack track selectively depending on the equipment the player has.

    My problem is, I can't figure out how via script to access the avatar mask property on the timeline track. I have it set up properly and can manually toggle it on and off, but I just need to be able to toggle it via script.

    Any help could save me hours of work. Thanks.

    Screen Shot 2020-04-07 at 11.46.06 AM.png
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
  3. bmangameswhat

    bmangameswhat

    Joined:
    Apr 30, 2019
    Posts:
    5

    This was what I needed. To get the Timeline Asset from my playable director I had to cast the playable asset as a Timeline asset. In the code below, "timeline" is a reference to the playable director on the game object.

    Code (CSharp):
    1. TimelineAsset tl = (TimelineAsset)timeline.playableAsset;
    2. IEnumerable<TrackAsset> tracks = tl.GetOutputTracks();
    If I was creating the timeline asset via script, I think I wouldn't need to do this.