Reply To: On Start, anim is unassigned, so the line “anim = anim.GetComponent…” is assigning anim to nothing. The code works because we’re assigning anim manually in the Editor. Am I misunderstanding?

Forum Archive On Start, anim is unassigned, so the line “anim = anim.GetComponent…” is assigning anim to nothing. The code works because we’re assigning anim manually in the Editor. Am I misunderstanding? Reply To: On Start, anim is unassigned, so the line “anim = anim.GetComponent…” is assigning anim to nothing. The code works because we’re assigning anim manually in the Editor. Am I misunderstanding?

#26751
Jonathan Gonzalez
Participant

    Looks like Unity has finally changed how GetComponent works again. They’ve gone back and forth on this so I just naturally use GetComponent. Previously certain components like the Animator would require GetComponent even if you manually assigned it. So yes in this case writing that line wouldn’t be necessary anymore unless you set it as private and want to assign it through script. Either way it’s not going to cause issues. If you do encounter any “missing reference” errors that could be the case.