Player will collect the radical gameobject. After that they will need to select the correct option. If they select the wrong answer, i will have to make the hit.gameObject.active = true; the object did reappear but when player try to collide with the gameobject, hit.gameObject.active = false is not working. I feel that my logic quite weird, but i not sure how to tackle the question.
if(hit.gameObject.tag == "rad1b")
{
//Destroy(hit.gameObject);
hit.gameObject.active = false;
//radicals[1].active = false;
// play a sound clip at the exact position we hit the object
AudioSource.PlayClipAtPoint(hitSound, transform.position);
//networkView.RPC("removeDiamond", RPCMode.AllBuffered);
rad1b = true;
print("rad1b");
}
So basically the reactivate of gameObject is done at the openableDoor.js script. And i didn’t do anything to the player script.
function showChoices()// attached to the gameObject door
{
if(choice)
{
if(wrong)
GUI.Label (Rect (20, 30, 300, 60), "Wrong Option!");
if(MoveAround.rad1a)
{
//~ // You may put a label to show a message to the player
if(GUI.Button(Rect(20,44,100,120), R01a, ""))
{
audio.PlayOneShot(correctSound);
print("rad01a");
correct = true;
}
}
if(MoveAround.rad1b)
{
if(GUI.Button(Rect(125,44,100,120), R01b, ""))
{
audio.PlayOneShot(wrongSound);
print("rad01b");
wrong = true;
//R01bb.active = true; // Set gameobject to active
}
}
function Update(){
if(wrong)
{
if(MoveAround.rad1a) // if this true mean that it already destroy, need to respawn the object
{
radical[0].active = true;
r1a = true;
}
if(MoveAround.rad1b)
{
radical[1].active = true;
r1b = true;
}
if(MoveAround.rad1c)
{
radical[2].active = true;
r1c = true;
}
if(MoveAround.rad1d)
{
radical[3].active = true;
r1d = true;
}
if(MoveAround.rad1e)
{
radical[4].active = true;
r1e = true;
}
if(MoveAround.rad1f)
{
radical[5].active = true;
r1f = true;
}
}
if(wrong)
{
MoveAround.rad1a = false;
MoveAround.rad1b = false;
MoveAround.rad1c = false;
MoveAround.rad1d = false;
MoveAround.rad1e = false;
MoveAround.rad1f = false;
}
}
*Edit the code snippet