Hi everyone
I have been searching the forums for days but though I have come close I still can’t seem to entirely manage the following.
I want to be able to blend between different times in a timeline therefore when entering playmode I create another playable instance of the playableAsset of my director.
Buffer the animationOutput in a variable
Connect the clone timelinePlayable and the original to a mixer and connect the mixer’s output to the original animationOutput. This all works nice and perfect for one Animation track and the bound animator.
However I fail to connect that single mixer (because one should be enough right? it blends all outputs coming from the timelinePlayble?) to multiple animation outputs. With what I currently have it plays mostly the animation of track 1 but on some frames it flickers to track2 :-/
2kqcll
(The code is loosely based on jeffvella’s Timelord github repository)
This is the function that modifies the graph:
private void BuildOutput()
{
PlayableDirector.Evaluate();
if (PlayableDirector.playableGraph.IsValid())
{
var trackCount = (PlayableDirector.playableAsset as TimelineAsset)?.outputTrackCount;
_outputs.Clear();
Debug.Log("trackcount " + trackCount);
for (int i = 0; i < trackCount; i++)
{
var originalOutput = (AnimationPlayableOutput)PlayableDirector.playableGraph.GetOutputByType<AnimationPlayableOutput>(i);
if (originalOutput.IsOutputValid())
{
_outputs.Add(originalOutput);
}
}
Debug.Log("output count " + _outputs.Count);
if (_outputs.Count > 0)
{
_clone = PlayableDirector.playableAsset.CreatePlayable(PlayableDirector.playableGraph, PlayableDirector.gameObject);
_mixer = AnimationMixerPlayable.Create(PlayableDirector.playableGraph, 2);
var originalSourcePlayable = _outputs[0].GetSourcePlayable();
_mixer.ConnectInput(_cloneIndex, _clone, 0, 0f);
_mixer.ConnectInput(_originalIndex, originalSourcePlayable, 0, 1f);
for (int i = 0; i < _outputs.Count; i++)
{
if (_outputs[i].IsOutputValid() && _outputs[i].GetTarget() != null)
{
var port = _outputs[i].GetSourceOutputPort();
_outputs[i].SetSourcePlayable(_mixer, port);
}
}
Debug.Log("TimelineLoop Blendgraph has been build.");
}
else
{
Debug.Log("Original Director Output is invalid");
}
}
else
{
Debug.Log("Timeline Asset has no animation output");
}
}
I thought that this would be the solution or if not the original port just using i as the next possible output port. But both create the same behaviour
var port = _outputs[i].GetSourceOutputPort();
_outputs[i].SetSourcePlayable(_mixer, port);
So yeah, apparently I am not getting something right, I’d be very thankful for your help
kind regards
outputPortIndex on the mixer does not seem to have any effect…
using multiple mixers does not work either because I can not connect the same timeline Playable port to multiple outputs and when I try to explicetely select another output port unity tells me that port does not exist (“attempting to explicitly set an output connection to a non-existing port”) although it looks to as this is what the animation output nodes do…
setting sub tree index on a mixer does nothing and the fact that first track works is a happy accident?