Every time on Key Up, a coroutine is run, it makes the boolean ‘blasting’ true at the start of the coroutine, does some other things, and just before the coroutine ends, it makes the boolean false. What I want it to happen is that when ‘blasting’ becomes true, it should change my animation from Idle to the Jump animation. I created a bool parameter in the ‘Animator’ called Jumping and created transitions from Idle to Jump based on when Jumping becomes true, and from Jump to Idle based on Exit Time.
I’m checking for the ‘blasting’ boolean to be true and setting the Jumping boolean to true but the Jump animation never plays. I also have the Animator controller on my Player object and Apply Root Motion is ticked off on it. Here is the code.
private Animator anim;
void Start (){
anim = GetComponent<Animator> ();
}
void Update () {
if (blast.GetComponent<InstantiateBlast> ().blasting)
{
anim.SetBool("Jumped",true);
}
}
Update: Upon further checking, on adding debug statements inside the if statement, nothing is getting debugged. I’m getting errors in Unity that say - NullReferenceException: Object reference not set to an instance of an object - for the line - if (blast.GetComponent ().blasting). Now, my blast object keeps getting activated and deactivated due to other collisions in the scene. How do I make sure that the NullReferenceException stops occuring and allowing for the checking of ‘blasting’ to continue ?