예제 #1
0
            public Instance(AnimStateController controller, PlayableGraph graph, AnimGraphStand settings)
            {
                m_Settings       = settings;
                m_AnimState      = controller.GetComponent <AnimStateData>();
                m_PredictedState = controller.GetComponent <LogicStateData>();

                m_Mask = 1 << LayerMask.NameToLayer("Default") | 1 << LayerMask.NameToLayer("Platform");

                m_LocomotionMixer = AnimationMixerPlayable.Create(graph, (int)LocoMixerPort.Count);

                m_AnimIdle = AnimationClipPlayable.Create(graph, settings.animIdle);
                graph.Connect(m_AnimIdle, 0, m_LocomotionMixer, (int)LocoMixerPort.Idle);
                m_LocomotionMixer.SetInputWeight((int)LocoMixerPort.Idle, 1.0f);

                m_AnimTurnL = CreateTurnPlayable(graph, settings.animTurnL, m_LocomotionMixer, LocoMixerPort.TurnL);
                m_AnimTurnR = CreateTurnPlayable(graph, settings.animTurnR, m_LocomotionMixer, LocoMixerPort.TurnR);

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

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

                if (settings.animTurnL.events.Length != 0)
                {
                    m_LeftTurnFootFalls  = ExtractFootFalls(settings.animTurnL);
                    m_RightTurnFootFalls = ExtractFootFalls(settings.animTurnR);
                }

                var animator  = controller.GetComponent <Animator>();
                var skeleton  = controller.GetComponent <Skeleton>();
                var leftToes  = skeleton.bones[skeleton.GetBoneIndex(settings.leftToeBone.GetHashCode())];
                var rightToes = skeleton.bones[skeleton.GetBoneIndex(settings.rightToeBone.GetHashCode())];

                var ikJob = new FootIkJob
                {
                    settings = settings.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_AimMixer = AnimationMixerPlayable.Create(graph, (int)AimMixerPort.Count, true);

                m_AnimAimLeft  = CreateAimPlayable(graph, settings.animAimLeft, m_AimMixer, AimMixerPort.AimLeft);
                m_AnimAimMid   = CreateAimPlayable(graph, settings.animAimMid, m_AimMixer, AimMixerPort.AimMid);
                m_AnimAimRight = CreateAimPlayable(graph, settings.animAimRight, m_AimMixer, AimMixerPort.AimRight);

                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);
            }
예제 #2
0
            public Instance(AnimStateController controller, PlayableGraph graph, AnimGraphSquash settings)
            {
                m_Settings = settings;

                m_AnimState      = controller.GetComponent <AnimStateData>();
                m_PredictedState = controller.GetComponent <LogicStateData>();

                m_Mixer = AnimationLayerMixerPlayable.Create(graph, 2);

                m_AnimSquash = AnimationClipPlayable.Create(graph, settings.animSquash);
                m_AnimSquash.SetApplyFootIK(false);
                m_AnimSquash.SetDuration(settings.animSquash.length);
                m_AnimSquash.Pause();

                m_Mixer.ConnectInput(1, m_AnimSquash, 0, 0.0f);
                m_Mixer.SetLayerAdditive(1, true);
            }
예제 #3
0
        void Awake()
        {
            m_AbilityMove         = GetComponent <AbilityMove>();
            m_AnimStateController = GetComponent <AnimStateController>();

            m_AnimState = GetComponent <AnimStateData>();
            if (m_AnimState == null)
            {
                m_AnimState = gameObject.AddComponent <AnimStateData>();
            }

            m_PredictedState = GetComponent <LogicStateData>();
            if (m_PredictedState == null)
            {
                m_PredictedState = gameObject.AddComponent <LogicStateData>();
            }
            m_PredictedState.position = transform.position;
            m_PredictedState.velocity = Vector3.zero;
        }
예제 #4
0
        void Start()
        {
            m_PredictedState = GetComponent <LogicStateData>();

            m_DefaultLayer  = LayerMask.NameToLayer("Default");
            m_PlatformLayer = LayerMask.NameToLayer("Platform");
            m_Mask          = 1 << m_DefaultLayer | 1 << m_PlatformLayer;

            var go = new GameObject("MoveColl_" + name, typeof(CharacterController));

            moveQueryController = go.GetComponent <CharacterController>();
            moveQueryController.transform.position = transform.position;
            moveQueryController.slopeLimit         = characterControllerSettings.slopeLimit;
            moveQueryController.stepOffset         = characterControllerSettings.stepOffset;
            moveQueryController.skinWidth          = characterControllerSettings.skinWidth;
            moveQueryController.minMoveDistance    = characterControllerSettings.minMoveDistance;
            moveQueryController.center             = characterControllerSettings.center;
            moveQueryController.radius             = characterControllerSettings.radius;
            moveQueryController.height             = characterControllerSettings.height;
        }
예제 #5
0
        void Start()
        {
            m_AnimState      = GetComponent <AnimStateData>();
            m_PredictedState = GetComponent <LogicStateData>();

            m_PlayableGraph  = PlayableGraph.Create(name);
            m_AnimGraph      = animStateDefinition.Instatiate(this, m_PlayableGraph);
            m_AnimGraphLogic = m_AnimGraph as IGraphLogic;
            m_AnimGraphState = m_AnimGraph as IGraphState;

            m_PlayableGraph.Play();
#if UNITY_EDITOR
            GraphVisualizerClient.Show(m_PlayableGraph);
#endif

            var outputPlayable = Playable.Null;
            var outputPort     = 0;
            m_AnimGraph.GetPlayableOutput(0, ref outputPlayable, ref outputPort);

            var animator = GetComponentInChildren <Animator>();
            animator.fireEvents = enableAnimatorEvent;
            var animationOutput = AnimationPlayableOutput.Create(m_PlayableGraph, "Animator", animator);
            animationOutput.SetSourcePlayable(outputPlayable, outputPort);
        }