Character pose reset issues when doing runtime binding to timeline

Hi,

I’m having an issue where a characters pose gets reset when binding to a timeline at runtime.It then blends into the timeline animation track from the wrong pose instead of what the Animator was playing. The pose seems to be the same one you see when configuring muscle settings for an avatar.

It doesn’t do it for all timelines that are handled the same way but it happens to a few.

This shows what happens. The second frame is when the timeline binding occurs.

Here are the timeline settings (first track is the relevant one):

And here is the code I use to bind the agents:

private void PreparePlayableAndStartTimeline()
        {
            var toTarget = m_TargetTransform.position - m_Transform.position;
            toTarget.y = 0;
            var dir = toTarget.normalized;
            var rot = Quaternion.LookRotation(dir);
            m_TargetController.SetRotation(Quaternion.LookRotation(-dir));
            m_Fatality.GetPlayableTimeline(m_Attack, m_AttackerStartPosition, rot, OnPlayableReady);
        }
       
        private void OnPlayableReady(PlayableDirector director)
        {
            m_PlayableDirector = director;
           
            BindToPlayableTimeline(director, m_Transform.gameObject, m_TargetTransform.gameObject);
            m_PlayableDirector.stopped += OnPlayableStopped;
            m_PlayableDirector.enabled = true;
            m_PlayableDirector.Play();
        }
       
        public void BindToPlayableTimeline(PlayableDirector timeline, GameObject attacker, GameObject receiver)
        {
            foreach (var playableAssetOutput in timeline.playableAsset.outputs)
            {
                switch (playableAssetOutput.streamName)
                {
                    case "Attacker Track":
                        timeline.SetGenericBinding(playableAssetOutput.sourceObject, attacker);
                        break;
                    case "Receiver Track":
                        timeline.SetGenericBinding(playableAssetOutput.sourceObject, receiver);
                        break;
                }
            }
        }

Can anyone tell me what I’m doing wrong here? I’ve been pulling my hair out over this and can’t figure out what the issues is.

Thanks

I don’t have a solution for this but can +1 this also happens constantly to me. I’m not doing any sort of runtime binding, though. Steps to repro are:

  1. Have a PlayableDirector attached to a GameObject with an Animator targeting a Humanoid rig,
  2. Disable PlayableDirector.PlayOnAwake
  3. Click the GameObject, which puts the PlayableDirector into Preview mode and sets the Animator state to whatever clip is playing on the Timeline
  4. Enter PlayMode: observe the character is stuck in neutral muscle pose until the Timeline is played

This only happens when the PlayableDirector has been put into Preview mode at least one time since the last time PlayMode was entered, and will happen even if Preview is not enabled and/or the PlayableDirector does not have focus in the Inspector when PlayMode is entered. The “fix” for me is to always start PlayMode twice… The first time I start PlayMode, Animator gets initialized in the bad state, the second time - as long as I don’t click on the object with the PlayableDirector attached - it will start without issue.

Of additional note: When I start PlayMode with my PlayableDirector object selected in the Hierarchy, the Inspector panel reports “This object only exists at Runtime,” which is an interesting thing to say when I am in Runtime. Reselecting the GameObject causes the Inspector to redraw appropriately. I suspect whatever hacky shenanigans are happening inside the #if UNITY_EDITOR blocks in AnimationTrack are worth a look. Especially lines 927-929 (in v1.7.5) which look particularly sus to me:

// Create default pose clip from collected properties
if (hasHumanMotion)
    animClips.Add(GetDefaultHumanoidClip());

Thanks for the additional info. I was going to try pre binding the player to the timeline next time I have a chance but it seems like it might still be an issue? In my case I’m not actively modifying the timeline although I do have the timeline window open. If it is somehow related to the editor preview mode I might need to see if the issue persists in an actual build.

EDIT: After checking that anim referenced in GetDefaultHumanoidClip it is the t-pose anim that you see when blending in/out of a timeline. So for me at least that doesn’t seem the be the issue. If someone knows where the muscle pose animation comes from that might help narrow down the source of the problem.

Having exactly this issue as you describe it. Did you ever find a work around? It’s driving me nuts.

Could you try isolate what differentiate them ? We use this exact setup with timeline and all is well. Maybe you do bind at a later stage sometimes ?

For us, this occurs with any timeline that is animating a rigged character. Once you’ve previewed the timeline, the character will be stuck in the pose the next time you enter playmode. All bindings are set manually, they’re never changed