code line not working

im watching this tutorial on animation

and this line of code

[SerializeField] private Animator MyAnimatorController;

wont work. i followed the tutorial exactly. did somthing change between now and when the tutorial was made?

In what way is it not working? Is there a compile error?

1 Like

Tutorial shows that line as follows (time in video = 6:53):
6479774--727853--upload_2020-11-1_15-27-29.png

@puddleglum

Maybe share your code with codetags, it must be something else in your code…

there was a compier error but i left it alone for a few days and it fixed itself?

there really wasnt enything else in my code since i had just started the script

Can I buy your compiler?

1 Like

:stuck_out_tongue: . so if im understanding the line of code

[SerializeField] private Animator myAnimatorController;

Animator is the type. and myAnimatorController is the name?

Correct! This particular line of code declares a variable. This particular kind of variable is called a “field” or “instance variable” or “member variable”. Learn more here https://www.pluralsight.com/guides/declaring-and-initializing-variables-in-c

ok thank you :stuck_out_tongue: i was struggling

so if i have an asset or animator controller named “Crossfade” i would put

[SerializeField] private Animator Crossfade;

?

Bingo.

:open_mouth: you know what i think i might be finaly learning c#. after like 7 months using it

1 Like

Haha. You never stop learning! I’ve been programming for 12 years, and using Unity/C# for at least 7 (still a baby compared to some people on this very forum) and I’m still learning new things every day.

lol true