Why a different way this time?

Why is the GameOverHandler stored as a GameOverHandler and not as a GameObject like everything else?

This caused some confusion as the NetworkManager apperantly doesn’t accept anything that’s not a GameObject ans I couldn’t assign the reference in the editor if I tried adding the script into it. But it did accept the GameOverHandler gameobject prefab WITH the script attached as a component.

image

image

Is this an oversight or something as this is not explained in the lecture?

Hi there, when you serialize a field of a specific type like the GameOverHandler, the reference takes a gameObject that contains that component (i.e. has that script attached). However when you go to reference it in the script, you have a direct reference to the GameOverHandler component on that gameObject. So you don’t need to get a hold of that component further.

I am not sure this is an oversight, this is very typical to how Unity functions.

Yeah, you’re not supposed to be assigning a script to it. It wants a game object that has that component.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms