In my StateMachineBehaviours public variables do not update in the inspector
Hi,
I'm trying to use an animator controller as a Finite State Machine for NPC AI, but I'm just starting. I created a StateMachineBehaviour and attached it to a State. The script contains some public variables. When I pressed play, I checked the object that had the animator, and checked the state in which the StateMachineBehaviour was placed. The values of the variables were not changing in the inspector. I used Debug.Log and the Visual Studio debugger to check whether the variable values were changing or not, and they were working fine. Hence, the problem is that the inspector is not refreshing, it just shows the initial values. Even though I can continue working, debugging will be horrible.
I'm using Unity 5.4.3.
Thanks for your help.
public class BasicNeeds : StateMachineBehaviour {
public int test = -1;
public string ImperantNeed;
public GameObject Character;
// 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) {
Character = animator.gameObject.transform.parent.gameObject;
Debug.Log(Character.name);
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
test = test +1;
ImperantNeed = "saying hello";
}
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
//override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
}
Same here. I want to do live changes to speedup the development process, but changing values in the inspector does not update the object
Your answer
Follow this Question
Related Questions
Why StateMachineBehaviour not calling OnStateExit when doing animator.Crossfade through code? 0 Answers
Animation is not playing eventhough state shows it 0 Answers
Animator not changing states on prefabs 1 Answer
Trouble with a State Machine for Turret 0 Answers
Is there any good examples or tutorials of using StateMachineBehaviour properly? 0 Answers