Пример #1
0
        public Instance(EntityManager entityManager, Entity owner, PlayableGraph graph, Entity animStateOwner, AnimGraph_Jump settings)
        {
            m_EntityManager  = entityManager;
            m_Owner          = owner;
            m_AnimStateOwner = animStateOwner;

            m_additiveMixer = AnimationLayerMixerPlayable.Create(graph);

            m_animJump = AnimationClipPlayable.Create(graph, settings.animJump);
            m_animJump.SetApplyFootIK(true);
            m_animJump.SetDuration(settings.animJump.length);
            m_animJump.Pause();
            int port = m_additiveMixer.AddInput(m_animJump, 0);

            m_additiveMixer.SetLayerAdditive((uint)port, false);
            m_additiveMixer.SetInputWeight(port, 1);

            // Adjust play speed so vertical velocity in animation is matched with character velocity (so feet doesnt penetrate ground)
            var animJumpVel      = settings.jumpHeight / settings.animJump.length;
            var characterJumpVel = Game.config != null ? Game.config.jumpAscentHeight / Game.config.jumpAscentDuration : animJumpVel;

            playSpeed = characterJumpVel / animJumpVel;


            // Aim
            m_aimHandler = new AimVerticalHandler(m_additiveMixer, settings.animAimDownToUp);
        }
Пример #2
0
        public Instance(EntityManager entityManager, Entity owner, PlayableGraph graph, AnimGraph_Simple settings)
        {
            m_EntityManager = entityManager;
            m_Owner         = owner;

            m_layerMixer = AnimationLayerMixerPlayable.Create(graph);
            int port;

            // Idle
            m_animIdle = AnimationClipPlayable.Create(graph, settings.animIdle);
            m_animIdle.SetApplyFootIK(settings.idleFootIKActive);
            port = m_layerMixer.AddInput(m_animIdle, 0);
            m_layerMixer.SetInputWeight(port, 1.0f);

            // Aim
            if (settings.animAimDownToUp != null)
            {
                m_aimHandler = new AimVerticalHandler(m_layerMixer, settings.animAimDownToUp);
            }

            // Actions
            m_actionMixer = AnimationLayerMixerPlayable.Create(graph);
            port          = m_actionMixer.AddInput(m_layerMixer, 0);
            m_actionMixer.SetInputWeight(port, 1);
            m_actionAnimationHandler = new ActionAnimationHandler(m_actionMixer, settings.actionAnimations);
        }
Пример #3
0
        public Instance(EntityManager entityManager, Entity owner, PlayableGraph graph, AnimGraph_InAir settings)
        {
            m_settings      = settings;
            m_EntityManager = entityManager;
            m_Owner         = owner;

            GameDebug.Assert(entityManager.HasComponent <CharacterPredictedState>(owner), "Owner has no Character component");
            m_character = entityManager.GetComponentObject <CharacterPredictedState>(owner);

            m_mainMixer = AnimationMixerPlayable.Create(graph);

            m_animInAir = AnimationClipPlayable.Create(graph, settings.animInAir);
            m_animInAir.Play();
            m_animInAir.SetApplyFootIK(false);
            inAirPort = m_mainMixer.AddInput(m_animInAir, 0);

            m_animLandAntic = AnimationClipPlayable.Create(graph, settings.animLandAntic);
            m_animInAir.Play();
            m_animLandAntic.SetApplyFootIK(false);
            landAnticPort = m_mainMixer.AddInput(m_animLandAntic, 0);

            m_layerMixer = AnimationLayerMixerPlayable.Create(graph);
            var port = m_layerMixer.AddInput(m_mainMixer, 0);

            m_layerMixer.SetInputWeight(port, 1);

            // Aim
            if (settings.animAimDownToUp != null)
            {
                m_aimHandler = new AimVerticalHandler(m_layerMixer, settings.animAimDownToUp);
            }

            // Actions
            m_actionAnimationHandler = new ActionAnimationHandler(m_layerMixer, settings.actionAnimations);
        }
Пример #4
0
        public Instance(EntityManager entityManager, Entity owner, PlayableGraph graph, AnimGraph_Sprint settings)
        {
            m_settings      = settings;
            m_EntityManager = entityManager;
            m_Owner         = owner;

            GameDebug.Assert(entityManager.HasComponent <CharacterPredictedState>(owner), "Owner has no Character component");
            m_character = entityManager.GetComponentObject <CharacterPredictedState>(owner);

            // Movement
            m_movementMixer = AnimationMixerPlayable.Create(graph, 3);

            m_movementClips    = new AnimationClipPlayable[3];
            m_movementClips[0] = AnimationClipPlayable.Create(graph, settings.animMoveN);
            m_movementClips[1] = AnimationClipPlayable.Create(graph, settings.animMoveNW);
            m_movementClips[2] = AnimationClipPlayable.Create(graph, settings.animMoveNE);

            foreach (var moveClip in m_movementClips)
            {
                moveClip.SetApplyFootIK(true);
                moveClip.SetSpeed(settings.animMovePlaySpeed);
            }

            graph.Connect(m_movementClips[0], 0, m_movementMixer, (int)Direction.Forward);
            graph.Connect(m_movementClips[1], 0, m_movementMixer, (int)Direction.Left);
            graph.Connect(m_movementClips[2], 0, m_movementMixer, (int)Direction.Right);

            outputPlayable = m_movementMixer;

            // Aim
            if (settings.animAimDownToUp != null)
            {
                m_aimMixer = AnimationLayerMixerPlayable.Create(graph, 1);
                graph.Connect(m_movementMixer, 0, m_aimMixer, 0);
                m_aimMixer.SetInputWeight(0, 1f);
                m_aimMixer.SetLayerAdditive(0, false);
                m_aimHandler = new AimVerticalHandler(m_aimMixer, settings.animAimDownToUp);

                outputPlayable = m_aimMixer;
            }
        }