/// <summary>
        /// Play an animation clip
        /// </summary>
        /// <param name="clip">The clip to play</param>
        /// <returns>The player that will play this clip</returns>
        private void PlayAnimation(MyAnimationDefinition animationDefinition, bool loop, float blendTime, float timeScale, MyPlayAnimationMode mode)
        {
            string model = animationDefinition.AnimationModel;
            int clipIndex = animationDefinition.ClipIndex;

            if (string.IsNullOrEmpty(model))
                return;

            if (animationDefinition.Status == MyAnimationDefinition.AnimationStatus.Unchecked)
            {
                var fsPath = System.IO.Path.IsPathRooted(model) ? model : System.IO.Path.Combine(MyFileSystem.ContentPath, model);
                if (!MyFileSystem.FileExists(fsPath))
                {
                    animationDefinition.Status = MyAnimationDefinition.AnimationStatus.Failed;
                    return;
                }
            }

            animationDefinition.Status = MyAnimationDefinition.AnimationStatus.OK;

            MyModel animation = MyModels.GetModelOnlyAnimationData(model);
            AnimationClip clip = animation.Animations.Clips[clipIndex];

            // Create a clip player and assign it to this model
            m_playerNextAnim.Initialize(clip, this, 1, timeScale, mode == MyPlayAnimationMode.JustFirstFrame);
            m_playerNextAnim.Looping = loop;

            m_currentBlendTime = 0;

            float actualTimeToEnd = 0;

            if (m_player.IsInitialized)
            {
                actualTimeToEnd = m_player.Duration - m_player.Position;

                //from idle to anything
                if (actualTimeToEnd > 0 && m_player.Looping)
                    actualTimeToEnd = blendTime;
            }

            //blend always that time it was required
            m_totalBlendTime = blendTime;

            if (mode == MyPlayAnimationMode.WaitForPreviousEnd)
            {
                m_currentBlendTime = m_totalBlendTime - actualTimeToEnd;
            }
        }
        public void PlayCharacterAnimation(
           string animationName,
           bool loop,
           MyPlayAnimationMode mode,
           float blendTime,           
           float timeScale = 1,
           bool sync = false
           )
        {
            if (animationName == null)
            {
                System.Diagnostics.Debug.Fail("Cannot play null animation!");
                return;
            }

            string animationSubtype = null;
            if (!m_characterDefinition.AnimationNameToSubtypeName.TryGetValue(animationName, out animationSubtype))
            {

                // TODO: Rethinkif we have different skeleton model, we can't play default character animations. 
                // This may still cause problems if character model has humanoid skeleton, but with different bone names and animation subtype wasn't defined.
                if (m_characterDefinition.Skeleton != "Humanoid") return;

                animationSubtype = animationName;
            }

            AddCommand(new MyAnimationCommand()
                {
                    AnimationSubtypeName = animationSubtype,
                    Loop = loop,
                    Mode = mode,
                    BlendTime = blendTime,
                    TimeScale = timeScale
                }, sync);

            FlushAnimationQueue();
        }