My First Unity 2.0 Issue

My hockey game project ran fine under Unity 1.6.2, but seems to break down in 2.0 trial version.

I have a GameController GO that instantiates the players. The line of code that worked before but doesn’t work now is:

var thisHockeyPlayer = thisPlayerGO.GetComponent(HockeyPlayer);

I get the following message in the console:

GetComponent requires that the requested component inherits from Component or MonoBehaviour.
You used GetComponent(HockeyPlayer) which does not inherit from Component.

Like I said, this caused no error before 2.0. Is something different now? I use javascript by the way.

Thanks for any help.

Mitch

I see what may be causing the issue.

I have a variable in Player GO exposed to the inspector –

var hockeyPlayer : HockeyPlayer;

(HockeyPlayer is a custom class that I set up)

In Unity v 1.6.2, I could drag and drop a prefab onto that variabe, but now that variabe does not even show up in the inspector.

Any idea why this has changed and what I could do to remedy?

Thanks.

I got it to work - just needed a little tweaking.

Seems like Unity 2 makes things easier than 1.6.2. Whereas I needed var hockeyPlayer : HockeyPlayer before so I could drop the prefab on it to access the custom class variables, now class shows up on it own without the need for the above line of code or the GetComponent call that caused the problems.

I’m probably not describing this very well because I hardly know what I’m doing,
but everything is working again in my hockey game on Unity 2.

And Unity 2 is da bomb!!!

Now back to steering behaviors!

[/i]