GetNextAnimatorStateInfo() public method

public GetNextAnimatorStateInfo ( int layerIndex ) : AnimatorStateInfo
layerIndex int
return AnimatorStateInfo
Ejemplo n.º 1
0
	void UpdateStatePower(Animator animator, AnimatorStateInfo stateInfo, int layerIndex){
		AnimatorTransitionInfo info = animator.GetAnimatorTransitionInfo (layerIndex);

		if (animator.GetNextAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()) { //Entering the state
			_power = info.normalizedTime;
		}else if(animator.GetCurrentAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()){ //Exiting the state
			_power = (1-info.normalizedTime);
		}

	}
    // Updates the progress counter of this animation state.
    void UpdateStateProgress (Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
        AnimatorTransitionInfo info = animator.GetAnimatorTransitionInfo (layerIndex);

        if (animator.GetNextAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()) { //Entering the state
            m_progress = info.normalizedTime; // Set progress of the animation to the time taken so far.
        } else if(animator.GetCurrentAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()){ //Exiting the state
            m_progress = (1 - info.normalizedTime); // Set the final progress of the animation.
        }

    }
Ejemplo n.º 3
0
	 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
	//override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
	//
	//}

	// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
		AnimatorTransitionInfo info = animator.GetAnimatorTransitionInfo (layerIndex);
		if (animator.GetNextAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()) { //Entering the state
			_power = info.normalizedTime;
		}else if(animator.GetCurrentAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()){ //Exiting the state
			_power = (1-info.normalizedTime);
		}
		if (_power > 0.98f) {
			animator.SetBool ("Holstered", true);
			animator.SetBool ("Holster", false);
		}
	}
Ejemplo n.º 4
0
        public sealed override void OnStateUpdate(UnityEngine.Animator animator, AnimatorStateInfo stateInfo, int layerIndex, AnimatorControllerPlayable controller)
        {
            if (!animator.gameObject.activeSelf)
            {
                return;
            }

            if (animator.IsInTransition(layerIndex) && animator.GetNextAnimatorStateInfo(layerIndex).fullPathHash == stateInfo.fullPathHash)
            {
                OnSLTransitionToStateUpdate(animator, stateInfo, layerIndex);
                OnSLTransitionToStateUpdate(animator, stateInfo, layerIndex, controller);
            }

            if (!animator.IsInTransition(layerIndex) && m_FirstFrameHappened)
            {
                OnSLStateNoTransitionUpdate(animator, stateInfo, layerIndex);
                OnSLStateNoTransitionUpdate(animator, stateInfo, layerIndex, controller);
            }

            if (animator.IsInTransition(layerIndex) && !m_LastFrameHappened && m_FirstFrameHappened)
            {
                m_LastFrameHappened = true;

                OnSLStatePreExit(animator, stateInfo, layerIndex);
                OnSLStatePreExit(animator, stateInfo, layerIndex, controller);
            }

            if (!animator.IsInTransition(layerIndex) && !m_FirstFrameHappened)
            {
                m_FirstFrameHappened = true;

                OnSLStatePostEnter(animator, stateInfo, layerIndex);
                OnSLStatePostEnter(animator, stateInfo, layerIndex, controller);
            }

            if (animator.IsInTransition(layerIndex) && animator.GetCurrentAnimatorStateInfo(layerIndex).fullPathHash == stateInfo.fullPathHash)
            {
                OnSLTransitionFromStateUpdate(animator, stateInfo, layerIndex);
                OnSLTransitionFromStateUpdate(animator, stateInfo, layerIndex, controller);
            }
        }