Example #1
0
        public Instance(EntityManager entityManager, Entity owner, PlayableGraph graph, Entity animStateOwner, AnimGraph_Move8Dir settings)
        {
            m_settings        = settings;
            m_EntityManager   = entityManager;
            m_Owner           = owner;
            m_AnimStateOwner  = animStateOwner;
            m_locomotionMixer = AnimationLayerMixerPlayable.Create(graph, 3);

            // Movement
            m_BlendTree = new BlendTree2dSimpleDirectional(graph, settings.blendSpaceNodes);
            graph.Connect(m_BlendTree.GetRootPlayable(), 0, m_locomotionMixer, 0);
            m_locomotionMixer.SetInputWeight(0, 1.0f);
            m_BlendTree.masterSpeed = m_settings.animMovePlaySpeed;

            // Aim
            //if (settings.animAim != null) {
            //    m_clipAim = AnimationClipPlayable.Create(graph, settings.animAim);
            //    m_clipAim.SetApplyFootIK(false);
            //    m_clipAim.Pause();
            //    m_aimTimeFactor = m_clipAim.GetAnimationClip().length / 180.0f;

            //    m_locomotionMixer.SetLayerAdditive(1, true);
            //    graph.Connect(m_clipAim, 0, m_locomotionMixer, 1);
            //    m_locomotionMixer.SetInputWeight(1, 1.0f);
            //}

            // Actions
            m_actionMixer = AnimationLayerMixerPlayable.Create(graph);
            var port = m_actionMixer.AddInput(m_locomotionMixer, 0);

            m_actionMixer.SetInputWeight(port, 1);

            m_actionAnimationHandler = new ActionAnimationHandler(m_actionMixer, settings.actionAnimations);
        }
Example #2
0
        public Instance(EntityManager entityManager, Entity owner, PlayableGraph graph, Entity animStateOwner, AnimGraph_InAir settings)
        {
            m_settings       = settings;
            m_EntityManager  = entityManager;
            m_Owner          = owner;
            m_AnimStateOwner = animStateOwner;

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

            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);
        }
Example #3
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);
        }
Example #4
0
        public CharacterAnimGraph_3PStand(EntityManager entityManager, Entity owner, PlayableGraph graph, Entity animStateOwner, AnimGraph_Stand template)
        {
            if (s_Instances == null)
            {
                s_Instances = new List <CharacterAnimGraph_3PStand>(16);
            }

            s_Instances.Add(this);


            m_template       = template;
            m_EntityManager  = entityManager;
            m_Owner          = owner;
            m_AnimStateOwner = animStateOwner;

            GameDebug.Assert(entityManager.HasComponent <Animator>(owner), "Owner has no Animator component");
            var animator = entityManager.GetComponentObject <Animator>(owner);

            GameDebug.Assert(entityManager.HasComponent <Skeleton>(owner), "Owner has no Skeleton component");
            var skeleton = entityManager.GetComponentObject <Skeleton>(owner);

            GameDebug.Assert(entityManager.HasComponent <CharPredictedStateData>(m_AnimStateOwner), "Owner has no CharPredictedState component");

            var leftToes  = skeleton.bones[skeleton.GetBoneIndex(template.leftToeBone.GetHashCode())];
            var rightToes = skeleton.bones[skeleton.GetBoneIndex(template.rightToeBone.GetHashCode())];

            // Locomotion mixer and loco animation
            m_locomotionMixer = AnimationMixerPlayable.Create(graph, (int)LocoMixerPort.Count);

            // Idle
            m_animIdle = AnimationClipPlayable.Create(graph, template.animIdle);
            m_animIdle.SetApplyFootIK(true);
            graph.Connect(m_animIdle, 0, m_locomotionMixer, (int)LocoMixerPort.Idle);
            m_locomotionMixer.SetInputWeight((int)LocoMixerPort.Idle, 1.0f);

            // Turns and trasitions
            m_animTurnL = CreateTurnAnim(graph, template.animTurnL, LocoMixerPort.TurnL);
            m_animTurnR = CreateTurnAnim(graph, template.animTurnR, LocoMixerPort.TurnR);

            var ports = new int[] { (int)LocoMixerPort.Idle, (int)LocoMixerPort.TurnL, (int)LocoMixerPort.TurnR };

            m_Transition = new SimpleTranstion <AnimationMixerPlayable>(m_locomotionMixer, ports);

            // Foot IK
            if (m_template.animTurnL.events.Length != 0)
            {
                m_LeftTurnFootFalls  = ExtractFootFalls(m_template.animTurnL);
                m_RightTurnFootFalls = ExtractFootFalls(m_template.animTurnR);
            }

            var ikJob = new FootIkJob
            {
                settings = m_template.footIK,
                leftToe  = animator.BindStreamTransform(leftToes),
                rightToe = animator.BindStreamTransform(rightToes)
            };

            m_footIk = AnimationScriptPlayable.Create(graph, ikJob, 1);
            graph.Connect(m_locomotionMixer, 0, m_footIk, 0);
            m_footIk.SetInputWeight(0, 1f);

            m_defaultLayer  = LayerMask.NameToLayer("Default");
            m_playerLayer   = LayerMask.NameToLayer("collision_player");
            m_platformLayer = LayerMask.NameToLayer("Platform");

            m_mask = 1 << m_defaultLayer | 1 << m_playerLayer | 1 << m_platformLayer;

            // Aim and Aim mixer
            m_aimMixer = AnimationMixerPlayable.Create(graph, (int)AimMixerPort.Count, true);

            m_animAimLeft  = CreateAimAnim(graph, template.animAimLeft, AimMixerPort.AimLeft);
            m_animAimMid   = CreateAimAnim(graph, template.animAimMid, AimMixerPort.AimMid);
            m_animAimRight = CreateAimAnim(graph, template.animAimRight, AimMixerPort.AimRight);

            // Setup other additive mixer
            m_additiveMixer = AnimationLayerMixerPlayable.Create(graph);

            var locoMixerPort = m_additiveMixer.AddInput(m_footIk, 0);

            m_additiveMixer.SetInputWeight(locoMixerPort, 1);

            var aimMixerPort = m_additiveMixer.AddInput(m_aimMixer, 0);

            m_additiveMixer.SetInputWeight(aimMixerPort, 1);
            m_additiveMixer.SetLayerAdditive((uint)aimMixerPort, true);

            // Actions
            m_actionAnimationHandler = new ActionAnimationHandler(m_additiveMixer, template.actionAnimations);

            m_ReloadActionAnimation = m_actionAnimationHandler.GetActionAnimation(CharPredictedStateData.Action.Reloading);

            // Shoot pose
            m_animShootPose = AnimationClipPlayable.Create(graph, template.animShootPose);
            m_animShootPose.SetApplyFootIK(false);
            m_animShootPose.SetDuration(template.animShootPose.length);
            m_animShootPose.Pause();
            m_ShootPosePort = m_additiveMixer.AddInput(m_animShootPose, 0);
            m_additiveMixer.SetInputWeight(m_ShootPosePort, 0.0f);
            m_additiveMixer.SetLayerAdditive((uint)m_ShootPosePort, true);
        }