public override void _Process(float delta) { // Check for changes to an animation's enabled state and notify the server when a change is detected. if (_animationPlayers.Count == 0) { return; } foreach (var animationPlayer in _animationPlayers.Values) { if (!GetAnimationData(animationPlayer.Name, out AnimationData animationData) || animationData.Managed || animationData.Enabled == animationPlayer.PlaybackActive ) { continue; } animationData.Enabled = animationPlayer.PlaybackActive; // Let the app know this animation (or interpolation) changed state. NotifySetAnimationStateEvent( animationPlayer.Name, animationTime: null, animationSpeed: null, animationEnabled: animationData.Enabled); // If the animation stopped, sync the actor's final transform. if (!animationData.Enabled) { AttachedActor.SynchronizeApp(ActorComponentType.Transform); } // If this was an internal one-shot animation (aka an interpolation), remove it. if (!animationData.Enabled && animationData.IsInternal) { _animationData.Remove(animationPlayer.Name); GD.Print(animationPlayer.Name); this.RemoveChild(animationPlayer); animationPlayer.QueueFree(); _animationPlayers.Remove(animationPlayer.Name); } } }
private void Update() { // Check for changes to an animation's enabled state and notify the server when a change is detected. var animation = GetUnityAnimationComponent(); if (animation == null) { return; } foreach (AnimationState animationState in animation) { if (!GetAnimationData(animationState.name, out AnimationData animationData) || animationData.Managed || animationData.Enabled == animationState.enabled ) { continue; } animationData.Enabled = animationState.enabled; // Let the app know this animation (or interpolation) changed state. NotifySetAnimationStateEvent( animationState.name, animationTime: null, animationSpeed: null, animationEnabled: animationData.Enabled); // If the animation stopped, sync the actor's final transform. if (!animationData.Enabled) { AttachedActor.SynchronizeApp(ActorComponentType.Transform); } // If this was an internal one-shot animation (aka an interpolation), remove it. if (!animationData.Enabled && animationData.IsInternal) { _animationData.Remove(animationState.name); animation.RemoveClip(animationState.clip); } } }