Hi there,
I'm fairly new to scripting and I was hoping someone out there could answer my question.
I have 2 Scripts
The first script is a Char Controller that features this If statement. The code below basically is trying to say that if the character is stepping on the tile type called EndTile and if if the current stage is IntroRoom1 and if CollectItem which is a boolean from another script equals to true then load another stage
if(currentTileType == "EndTile"){
if(currentStage == "IntroRoom_1" && GameObject.Find("CollectCube).GetComponent("Collect").CollectItem == True){
levelToLoad = "Stage_1";
}
} The following script called Collect which is attached to a cube gameobject says that if our Main Character collides with the game object destroy the current game object and switch the CollectItem boolean to true
if(theOther.gameObject.name == "MainChar"){ Destroy(gameObject); CollectItem = true;
}
When I destroy the gameobject Collect Item turns to True but when I walk onto my EndTile object it says NullReferenceException: Object reference not set to an instance of an object
anyone know what I did wrong ?