Regarding Ch 2 “Accessing Controllers from a Script”
You state in the book to use “private Animator anim;” When I use this, I get a Null Exception at the line of code “anim.SetFloat(“speed”, Mathf.Abs(movePlayerVector));”. I realized that anim is never assigned. So I made it public so that I could drag the gameObject containing the animation into the anim variable space in the Inspector window. That allows it to work, and I can move the character and see the animation.
So my question is; is there a line of code missing in the book to initialize anim in the script (as a private variable) rather than via drag and drop in the Inspector window (as a public variable)?
It seems that the second bullet item in this section is missing the new code needed for this, as the only code shown is code that was already put into place earlier in the chapter.