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?

#26750
Jason Finney
Participant

    @zeekar  I am still starting to learn but I think I can answer this. 

    Even if you did manually assign Spike-trap to the variable in the inspector it doesn’t know what Component to find. 

    I don’t think it having the variable a Animator type is enough, like with referencing scripts like with the health script in this lesson you just create your own variable type by making it a “Health type” 

    Like I said I’m still learning this so I don’t know if I’m right or not.