I have two scenes here; the first one is where the key is…
public static bool Key1= false;
if(Input.GetMouseButtonDown(0)){
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 200)){
if(hit.collider.name == "Key1"){
Key1= true;
}
}
}
And here is where you go to open the door
if(Input.GetMouseButtonDown(0)){
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 200)){
if(hit.collider.name == "Door2" || Captain.Key1== true){
Application.LoadLevel("Deck");
}
}
}
However, I am being able to open the door without getting the key, how do I fix that?