Enable / disable avatar mask in timeline via script

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.

5682130--592750--Screen Shot 2020-04-07 at 11.46.06 AM.png

Unity - Scripting API: Timeline.AnimationTrack.applyAvatarMask and Unity - Scripting API: Timeline.AnimationTrack.avatarMask

You can get the list of animations tracks using timelineAsset.GetOutputTracks().OfType()

1 Like

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.

TimelineAsset tl = (TimelineAsset)timeline.playableAsset;
IEnumerable<TrackAsset> tracks = tl.GetOutputTracks();

If I was creating the timeline asset via script, I think I wouldn’t need to do this.