I’ve been encountering this 'unknown identifier error quite a lot recently, it’s especially annoying when im referencing variables from otehr scripts. I’ve read through the script reference, but it’s still nto quite working.
“Assets/Scripts/movementScript.js(22,9): BCE0005: Unknown identifier: ‘vcamera1’.”
“Assets/Scripts/movementScript.js(22,9): BCE0005: Unknown identifier: ‘vcamera2’.”
Scipt in which boolean is declared:
var vcamera1 : boolean;
var vcamera2 : boolean;
function Start() {
vcamera1 = true;
vcamera2 = false;
}
function OnTriggerEnter(otherObject: Collider){
if(otherObject.gameObject.tag == "cameracorner"){
vcamera1 = false;
vcamera2 = true;
}
}
Script in which boolean is referenced:
var xangle : float;
var yangle : float;
var zangle : float;
var camera01 : Camera;
var camera02 : Camera;
function Start() {
xangle = 0;
yangle = 0;
zangle = 0;
camera01.enabled = true;
camera02.enabled = false;
}
function Update () {
transform.eulerAngles = Vector3(xangle, yangle, zangle);
}
function Vcamera1 (){
if (vcamera1.cameracheckScript == false){
camera01.enabled = false;
}
}
function Vcamera2 () {
if (vcamera2.CameraCheckScript == true){
camera02.enabled = true;
}
}
The “function Vcamera”, were there to try and stop the error as originally i was accessiong the variables through the update function, but i’m pretty lost if im perfectly honest.
You're aware that to reference variables from one script inside the other, you need to acquire a reference to that script first, right? You can't just write the variable's identifier as if they were globally available throughout your entire project like that. You can get the script they reside in by using GetComponent, see this for an example: http://unity3d.com/support/documentation/ScriptReference/GameObject.GetComponent.html
– CHPedersenpretty new to scripting, so no I clearly wasn't aware. Tahnks anyway
– BobbleHeadYou're welcome. We all gotta start somewhere. :)
– CHPedersen