BCE0005: Unknown identifier errors Unity 3.4

Hi All!

After upgrading to Unity 3.4 I got some errors on a Android build…

They are all BCE0005: Unknown identifier errors in the Car.js script that comes with the car tutorial, wich hasn’t been altered, except for the controls.

The main errors are these: BCE0005: Unknown identifier: ‘wheel’.

It errors at these lines:

wheel = new Wheel(); 


wheel.collider = wc;


wheel.wheelGraphic = wheelTransform;

wheel.tireGraphic = wheelTransform.GetComponentsInChildren(Transform)[1];

etc. Basicly every time that ‘wheel’ comes into play…

The next one is a BCE0005: Unknown identifier: ‘accelerationTimer’.

	accelerationTimer = Time.time;

The last one is BCE0005: Unknown identifier: ‘normPower’.

	normPower = (currentEnginePower / engineForceValues[engineForceValues.Length - 1]) * 2;

	currentEnginePower += Time.deltaTime * 200 * EvaluateNormPower(normPower);

Can anyone please help me make these lines Unity 3.4 / Android proof? The whole game is build around this script, and we’ve been stuck for a couple of days now…

Thanks a lot in advance!!

The answer is indeed just putting ‘var’ in front of example wheel = new Wheel();

so

wheel = new Wheel()

has to be

var wheel = new Wheel()

I’m still not sure on the reason though, there are enough other variables being made without ‘var’… But I’m just glad that it works! Thanks guys!

The reason for this is that the JavaScript compiler shipped with Unity 3.4 became more stringent in its syntactic checks of scripts to better enforce its own guidelines. What you were seeing was the compiler chocking on “implicit variable declaration”, which basically means that if an identifier (e.g. a variable name) is unknown at the time it is encountered the compiler creates it automatically. It seems to me like the JS guys over at UT decided it was a good enough trade-off to remove that feature from 3.4 to make it more compliant (meaning that now the compiler errors out automatically when encountering an unknown identifier), along with enforcing more stringent dynamic typing checks. For more info have a read at the JavaScript specific section of the release notes:

http://unity3d.com/unity/whats-new/unity-3.4

HTH! Regards,

  • jmpp

Did you delete the other question?

What I was saying there is that you wrote down that the issue is coming from the Car.js script, which is javascript. However, variable declaration from what you posted appears to be done in C#. I do not believe JavaScript uses the “new” keyword, and each variable declaration should start off with the “var” keyword.

Wow Unity answers is awsome!!

you could have a. zip file of the complete project with the script and the car?

I managed to make the script of the machine for Android without giving me errors but I can not now make the joystick can you tell me how to do it?