Upgrading from 3.3 > 3.4=errors...

it appears that after i upgraded my unity editor i keep getting errors on basicly all the static variables in my ThirdPersonController
also static functions

i get:

Assets/scripts/player/ThirdPersonController.js(960,80): BCE0019: 'freeze' is not a member of 'UnityEngine.Component'.

Assets/scripts/player/ThirdPersonController.js(742,25): BCE0005: Unknown identifier: 'VerticalSpeed'.it wont even compile. i suspected it had something to do with the compiling sequence so i tried racking the ThirdPersonController up as #1. Didn’t work. Any ideas?

Weird. How is saying that a variable’s not found the same as saying that it’s a function?

This sounds like you’re trying to access the function ‘freeze’ of a class without typecasting the thing you’re calling ‘freeze’ on. What’s the content of that line of code?

You might want to make it look like;

(yourComponent as yourComponentsType).freeze ();

i think i found out something.

By removing #pragma strict from ALL my scripts. they compiled just fine.

it was going nuts by lines like this:
playerController=GetComponent(ThirdPersonController);
i don’t know how this should be written so that #pragma strict accepts it.

Edit: the console now starts flaming me for dt >= 0

I had the same issues when starting with pragma strict. You need to typecast everything, which takes a little more effort but makes for more efficient code.

var playerController = GetComponent(ThirdPersonController);

This will just returns an object (i.e. a component) which you have to typecast to be the correct type (in this case, ThirdPersonController).

So to typecast it, you could have;

 var playerController : ThirdPersonController = (GetComponent(ThirdPersonController) as ThirdPersonController);

Or you can use the other version of GetComponent that returns the correct type by default, which is a bit neater;

 var playerController : ThirdPersonController = GetComponent.<ThirdPersonController> ();

I was under the impression that casting a GetComponent call was no longer necessary. My guess is that typing the variable beforehand would rectify the issue

var playerController : ThirdPersonController = GetComponent(ThirdPersonController);

instead of

var playerController = GetComponent(ThirdPersonController);

That’s not true. This is perfectly valid:

var playerController = GetComponent(ThirdPersonController); // good

and will result in playerController being typed as ThirdPersonController. All the extra casting you’re doing is unnecessary. The only thing to remember is do not use strings:

var playerController = GetComponent("ThirdPersonController"); // bad

Aside from being slower, this will screw up the type inference, and result in Component instead of ThirdPersonController.

This is will work, but 1) you don’t need to write “var playerController : ThirdPersonController =”, you can just write “var playerController =”, and 2) it’s a bit slower than using GetComponent without generics, so there’s no reason to use this format. (It was more useful before Unity 3.4 made GetComponent return the actual type of the component, instead of Component.)

No, type inference means you don’t have to manually supply the type. Since “GetComponent(ThirdPersonController)” returns ThirdPersonController, that means playerController is typed as ThirdPersonController whether you write it out again or not. Those two lines of code you wrote are 100% identical in practice and there’s no difference in speed.

Whenever you upgrade Unity, re-import the standard packages that you used.

–Eric

Thanks for clearing that up Eric.

Yeah, cheers. It’s a little clearer in my head now.

I have some code cleanup to do :stuck_out_tongue: