At 10:30 in the video, Rick uses
GetComponent<Animator>().SetBool("isAttacking", true);
Is there a specific reason this is done instead of going up to the top and putting in
Animator animator;
and then in the method using
animator.SetBool("isAttacking", false);
Is this strictly for demonstrative purposes? Or is there a meaning to the change in how it was written, because in the only other example of this during the lesson he uses the latter instead of the former. I think they do the same thing but I often get confused as to which I am supposed to be using between:
Type nameOfType;
or using:
GetComponent<Type>();
Any insight into purpose or reasoning would be appreciated. Even if this is just a personal style I would be interested in learning why.