- Home /
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!!
Can you post the code where you declare wheel, accelerationTimer and normPower. $$anonymous$$y guess is that you have not declared these anywhere.
This is the NormPower function
function CalculateEnginePower(relativeVelocity : Vector3){
if(throttle == 0)
{
currentEnginePower -= Time.deltaTime * 200;
}
else if( HaveTheSameSign(relativeVelocity.z, throttle) )
{
normPower = (currentEnginePower / engineForceValues[engineForceValues.Length - 1]) * 2;
currentEnginePower += Time.deltaTime * 200 * EvaluateNormPower(normPower);
}
else
{
currentEnginePower -= Time.deltaTime * 300;
}
if(currentGear == 0)
currentEnginePower = $$anonymous$$athf.Clamp(currentEnginePower, 0, engineForceValues[0]);
else
currentEnginePower = $$anonymous$$athf.Clamp(currentEnginePower, engineForceValues[currentGear - 1], engineForceValues[currentGear]);}
This is the Wheel Function
function SetupWheel(wheelTransform : Transform, isFrontWheel : boolean)
{ var go : GameObject = new GameObject(wheelTransform.name + " Collider");
go.transform.position = wheelTransform.position;
go.transform.parent = transform;
go.transform.rotation = wheelTransform.rotation;
var wc : WheelCollider = go.AddComponent(typeof(WheelCollider)) as WheelCollider;
wc.suspensionDistance = suspensionRange;
var js : JointSpring = wc.suspensionSpring;
if (isFrontWheel)
js.spring = suspensionSpringFront;
else
js.spring = suspensionSpringRear;
js.damper = suspensionDamper;
wc.suspensionSpring = js;
wheel = new Wheel();
wheel.collider = wc;
wc.sidewaysFriction = wfc;
wheel.wheelGraphic = wheelTransform;
wheel.tireGraphic = wheelTransform.GetComponentsInChildren(Transform)[1];
wheelRadius = wheel.tireGraphic.renderer.bounds.size.y / 2;
wheel.collider.radius = wheelRadius;
if (isFrontWheel)
{
wheel.steerWheel = true;
go = new GameObject(wheelTransform.name + " Steer Column");
go.transform.position = wheelTransform.position;
go.transform.rotation = wheelTransform.rotation;
go.transform.parent = transform;
wheelTransform.parent = go.transform;
}
else
wheel.driveWheel = true;
return wheel;}
And the last one: The accelerationTimer
function Start(){
// $$anonymous$$easuring 1 - 60
accelerationTimer = Time.time;
SetupWheelColliders();
SetupCenterOf$$anonymous$$ass();
topSpeed = Convert_$$anonymous$$iles_Per_Hour_To_$$anonymous$$eters_Per_Second(topSpeed);
SetupGears();
SetUpSkidmarks();
initialDrag$$anonymous$$ultiplierX = drag$$anonymous$$ultiplier.x;
}
Answer by ThomasQ · Aug 02, 2011 at 05:51 PM
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!
Answer by jmpp · Aug 06, 2011 at 03:13 AM
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
Answer by PeppeProduction · Nov 19, 2012 at 03:35 PM
you could have a. zip file of the complete project with the script and the car?
Answer by PeppeProduction · Nov 19, 2012 at 03:35 PM
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?
Your answer
Follow this Question
Related Questions
I have an error while building the game 1 Answer
Script won't run level (platformer tutorial) 1 Answer
I got a major question 1 Answer
Unknown Identifier "target" 3 Answers
Can't compile script from Scripting Tutorial (translated to Boo) 3 Answers