Question by
Draken17 · May 30 at 06:14 PM ·
animatorgetcomponent
Trying to reference script that is attached to empty state in the animator. GetComponent Not Working
Is there a way to reference the script that is attached to the empty state in the animator. I have a script called ResetAnimatorBool and I want to reference it from another script but GetComponent does not work
The Idea is to see if the bool is false(if the animation is finished and back the the empty state) and if it isn't and the animation is still playing, then disable controls until the animation is finised.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ResetAnimatorBool : StateMachineBehaviour
{
[Header("Disable Root Motion")]
public string disableRootMotion = "disableRootMotion";
public bool disableRootMotionStatus = false;
[Header("Is Performing Action Bool")]
public string isPerformingAction = "isPerformingAction";
public bool isPerformingActionStatus = false;
[Header("Is Preforming Quick Turn")]
public string isPerformingQuickTurn = "isPerformingQuickTurn";
public bool isPerformingQuickTurnStatus = false;
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
animator.SetBool(disableRootMotion, disableRootMotionStatus);
animator.SetBool(isPerformingAction, isPerformingActionStatus);
animator.SetBool(isPerformingQuickTurn, isPerformingQuickTurnStatus);
}
}
Comment
Your answer
