- Home /
how to initiate animation from implementing script in state machine?
Hello all,
I've been implementing my own state machine C# scripts based on this tutorial by @MatthewSchell, which is a very good one btw . There's a thing I can't understand. Say I get a function PatrolState() , which is being called from the MonoBehaviour script StatePatternEnemy. and while in PatrolState I want my enemy to become Idle (as it's part of the animatorController animations attached to the enemy). So I've set a "public Animator animator" on the StatePatternEnemy, and expected that when calling Idle from PatrolState, by: animator.SetBool("Idle", true) - it'll work. Instead it gives me a nullReference error. (Object reference not set to an instance of an object).
What am I doing wrong? perhaps I'm not understanding the relationships between the scripts.
Thank you!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Root motion handled by script. How to still use root motion with disabled navmesh agent? 0 Answers
How do I get gameobjects to fire a method based on an interface? 1 Answer
Annoying MissingReferenceException with Interfaces and Monobehavior 1 Answer