コード例 #1
0
    // 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.
        }

    }
コード例 #2
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);
		}

	}
コード例 #3
0
ファイル: Holster.cs プロジェクト: omgware/UnityUnetMovement
	 // 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);
		}
	}