Hi
I have two two gameobject. One of them called “Llave 1” and the other “accion_personaje” and in Llave withethe tag “Llave” have a script called “LlavesOn” and “accion_ironman” with the tag “Accion” have one script called “AccionIronman”.
I want to use one function of LlavesOn’s Script in the AccionIronman Script. I want to desactivate the gameObject “Llave” (GameObject.setactive(false)) and later, in a talk activate it (GameObject.setactive(true)).
setactive(false) work well but later setactive(true) don’t work.
How can i activate the gameobject when the game is playing?
I have tried with GetComponent but i cant. I write the two script.
Please, i need help.
Thank you and Happy new year.
LlavesOn Script:
#pragmastrict
functionStart()
{
Off();
}
functionOn()
{
gameObject.SetActive(true); //Paraactivar/desactivarelgameObjectenelquevaacoplado. ‘activar’ (true), ‘desactivar’ (false).
}
functionOff()
{
gameObject.SetActive(false); //Paraactivar/desactivarelgameObjectenelquevaacoplado. ‘activar’ (true), ‘desactivar’ (false).
}
AccionIronman Script:
#pragmastrict
publicvarestetica:GUISkin;
privatevardialogo1:String = “”;
privatevardialogo2:String = “Aúntequedanllaves. Búscalas!!”;
privatevardialogo3:String = “Yatieneslasllaves! Pirémonosdeaquí!!”;
privatevarcomentarios = false;
publicvarTiempoEspera:int = 3;
privatevarnumKeys:int;
//varllave : GameObject;
//privatevarkeysOn : LlavesOn;
functionStart()
{
mensajes();
//keysOn = llave.gameObject.GetComponent(“LlavesOn”);
//llave.SetActive(false);
//llave.SetActiveRecursively(false);
}
functionUpdate()
{
varkeys:RecogerLlaves = GetComponent(“RecogerLlaves”) asRecogerLlaves;
numKeys = keys.NumLlaves;
}
functionOnGUI()
{
GUI.skin = estetica;
if(comentarios == true)
{
switch(numKeys)
{
case0:
GUI.Box(Rect(Screen.width/2-250, Screen.height/2-25, 500, 50), dialogo1);
break;
case1:
GUI.Box(Rect(Screen.width/2-250, Screen.height/2-25, 500, 50), dialogo2);
break;
case2:
GUI.Box(Rect(Screen.width/2-250, Screen.height/2-25, 500, 50), dialogo2);
break;
case3:
GUI.Box(Rect(Screen.width/2-250, Screen.height/2-25, 500, 50), dialogo2);
break;
case4:
GUI.Box(Rect(Screen.width/2-250, Screen.height/2-25, 500, 50), dialogo2);
break;
case5:
GUI.Box(Rect(Screen.width/2-250, Screen.height/2-25, 500, 50), dialogo2);
break;
case6:
GUI.Box(Rect(Screen.width/2-250, Screen.height/2-25, 500, 50), dialogo2);
break;
case7:
GUI.Box(Rect(Screen.width/2-250, Screen.height/2-25, 500, 50), dialogo2);
break;
case8:
GUI.Box(Rect(Screen.width/2-250, Screen.height/2-25, 500, 50), dialogo2);
break;
case9:
GUI.Box(Rect(Screen.width/2-250, Screen.height/2-25, 500, 50), dialogo2);
break;
default:
GUI.Box(Rect(Screen.width/2-250, Screen.height/2-25, 500, 50), dialogo3);
}
}
}
functionOnTriggerEnter()
{
comentarios = true;
}
functionOnTriggerExit()
{
comentarios = false;
}
functionmensajes()
{
yieldWaitForSeconds(TiempoEspera);
dialogo1 = “Hola, CaballeroenGallumbos.”;
yieldWaitForSeconds(TiempoEspera);
dialogo1 = “MellamoIronman.”;
yieldWaitForSeconds(TiempoEspera);
dialogo1 = “Yaunqueestémazaodepasta,”;
yieldWaitForSeconds(TiempoEspera);
dialogo1 = “notengonizorradecomoescapardeesteantro.”;
yieldWaitForSeconds(TiempoEspera);
dialogo1 = “Necesitodiezllavesysoloheencontradoesta.”;
yieldWaitForSeconds(TiempoEspera);
dialogo1 = “¿Puedesayudarmeaencontrarlasnuevequemequedan?”;
yieldWaitForSeconds(TiempoEspera);
//llavesOn();
//keysOn.llavesOn();
//GameObject.Find(“Llave”).GetComponent(“LlavesOn”).On();
//llave.SetActiveRecursively(true);
dialogo1 = “Tomalaprimera, lasdemássonigualesyestanrepartidasporahí.”;
yieldWaitForSeconds(TiempoEspera);
dialogo1 = “¡Suerteyquelafuerzateacompañe!”;
}