Greetings,
I’m trying to use a static var, but unity tells me it’s a Unknown Identifier. My other static var works perfectly, exception this one.
Here where’s the bug
if(other.tag == "Player"){
doorSpawn = goToDoorNum;
Application.LoadLevel("L"+gameLevel+"R"+goToRoomNum);
}
gameLevel and doorSpawn are both static var declared here in another script:
//At which door does the character spawn.
static var doorSpawn : int;
//Which game level are we in.
static var gameLevel : int;
But only gameLevel return me an error. Any idea on how to force Unity to compile it correctly?
Edit:
Script A:
//At which door does the character spawn.
static var doorSpawn : int;
//Which game level are we in.
static var gameLevel : int;
//In which room the character is.
private var charInRoom : int;
//In which room the boss is.
private var bossInRoom : int;
//How many rooms there is.
var roomsQty : int;
private var enemiesInRoom : int[];
function Awake(){
//Resize a native array.
enemiesInRoom = new int[roomsQty+1];
DontDestroyOnLoad (transform.gameObject);
print(enemiesInRoom.Length);
}
function Update () {
}
function charRoomUpdate(room : int){
charInRoom = room;
}
function spawnCharacter(){
if(gameControl.isPlaying){
var DoorSpawn : GameObject;
GameObject.Find("Door"+doorSpawn;)
SendMessage.DoorSpawn(spawnCharacterDoor);
}
}
Script B:
//The number of the door.
var doorNum : int;
gameObject.name = "Door"+doorNum;
;
//The room number to which the character will go.
var goToRoomNum : int;
//The door number the character should spawn at in the next room.
var goToDoorNum : int;
function OnTriggerEnter(other : Collider){
if(other.tag == "Player"){
doorSpawn = goToDoorNum;
Application.LoadLevel("L"+levelManager.gameLevel+"R"+goToRoomNum);
}
}
function spawnCharacterDoor(){
SpawnPoint : GameObject;
GameObject.Find(gameObject.name+"/Spawn");
}