The question is answered, right answer was accepted
Basic Code Problem
Hi Guys,
On my project I have a key card which is used to unlock doors throughout the game. As a way to use the key card, I have created a script which will destroy the object once the player picks it up, as well as it's corresponding locked door (eludes the player to think they have equipped the card). Now all I needed to do was create another door which is always unlocked once the previous is destroyed. So far this is the code:
public class IdentityCard : MonoBehaviour {
public GameObject identityCard;
public GameObject GeneratorDoor;
public GameObject GeneratorDoorUNLOCKED;
public void Start()
{
GeneratorDoorUNLOCKED.SetActive(false);
}
public void OnMouseOver()
{
if (Input.GetKey(KeyCode.E))
{
Destroy(identityCard);
Destroy(GeneratorDoor);
GeneratorDoorUNLOCKED.SetActive(true);
}
}
}
As you can see very basic code however the second door always stays as SetActive(false) even though I have coded it to appear once the player presses E. Any help will be greatly appreciated, it is a school assignment so a fast reply is valued.
Answer by tomwatson0403 · Sep 16, 2018 at 12:48 AM
Alright never mind guys, figured out I had the object as a child and when the gameobject was destroyed it destroyed the door with it.
I would recommend answering your question and marking it as the correct answer so that people can see that it is closed.
Done :D
Closing the question...
Bye.
Follow this Question
Related Questions
Need help with c# 1 Answer
Set the username with an inputfield ? 3 Answers
I can't add the script to fix my broken script, because my script is broken 1 Answer
transform.localscale to specific size 1 Answer
how to make mathf.pingpong not from 0 3 Answers