2d controller script won't recognize Animator

hi guys, i need your help:

i was following this tutorial
Live Training 16 Dec 2013 - 2D Character Controllers

All went good till 45:30 when it’s time to insert a referment to Animator in my C# script. Before that all was fine:

  1. My animations are working properly if i try them in the animation’s window

  2. The script is a component inside character, I’m sure about this because if i try the code until here it works fine, i can move my char and all.

  3. The animator is a component inside character as well, i verified this pressing play and watching at my character properly moving how the idle animation is supposed to make him move.

Now, from 45:30 i got a problem.

4)I declare an Animator variable called anim and all works fine, obviously.

5)I try to make anim refer to my Animator writing this in Start(): “anim.GetComponent< Animator >();” (left some space after the < and the > here but it’s written properly in the code)

  1. try to add a modifier for the Speed parameter writing this in FixedUpdate():
    anim.SetFloat (“Speed”, Mathf.Abs(move));

So i do everything he does, also i got no errors in the code. But then this happens when i start the scene, which immediatly pause:

“NullReferenceException
UnityEngine.Component.GetComponent[Animator] () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/UnityEngineComponent.cs:187)”
refering to the line in point 5

“NullReferenceException
UnityEngine.Animator.SetFloat (System.String name, Single value) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/AnimatorBindings.cs:176)”
refering to the line in point 6

As far as i get the script won’t recognize the animator inside character, even if they both are inside it. I tried to create a brand new animator and script but i got the same problem so I’m probably missing something and i’ll be glad if you could help me.

Tyvm for your attention, sorry if i wrote so much

Peace

Solved myself. This was the error:

I wrote “anim.GetComponent< Animator >();” instead of “anim = GetComponent< Animator >();”

If this ever happens to anyone else, hope this thread could help,

cya guys