[SOLVED] Object not reactivating after even after a trigger has been triggered.

Pardon my English in advance,

I’m making a game where the player needs to input a password in order to make the exit appears, thing is, that doesn’t seem to work. In the debug log, the input did indeed work.

Any help would be nice,

My GameController (basically the input part)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GameController : MonoBehaviour {

public string answer;
public InputField mainInputField;
public static bool GotAnswer;




void Update (){
	
	answer = mainInputField.text;
	if (answer == "Tunku Abdul Rahman" && Input.GetKey(KeyCode.Return)) {
		Debug.Log ("Correct");
		GotAnswer = true;
		
	}
}

}

My ExitHider :

using UnityEngine;
using System.Collections;

public class ExitHider : MonoBehaviour
{
GameObject Exit;

void Start () {
	Exit = GameObject.Find ("Exit");
	Exit.SetActive (false);
}


void Update ()
{
	if (GameController.GotAnswer == false) 
	{
		
		Exit.SetActive (false);
	}

	if (GameController.GotAnswer == true) 
	{
		
		Exit.SetActive (true);
	}
}

}

I would guess that exit is not being found. Although rather than checking each frame if the correct answer has been given, consider using an event. You can also change your system slightly so each possible answer for each exit doesn’t need to be hard coded.

using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

public class GameController : MonoBehaviour
{
    public InputField mainInputField;
 
    public class AnswerEvent : UnityEvent<string>{ };

    public AnswerEvent PasswordResponse;

    private void Update()
    {
        if (Input.GetKey(KeyCode.Return))
        {
            PasswordResponse.Invoke(mainInputField.text);
        }
    }
}

public class ExitHider : MonoBehaviour
{
    //Populate Exit in the Inspetor
    [SerializeField]
    private GameObject _exit;


    [SerializeField]
    private string _correctAnswer;

    void Start()
    {
        var controller = FindObjectOfType<GameController>();

        controller.PasswordResponse.AddListener(PasswordResponse);

        _exit.SetActive(false);
    }

    private void PasswordResponse(string answer)
    {
        _exit.SetActive(answer == _correctAnswer);
    }
}

i think in addition to what WarMed stated, you bool needs to be defined as false where you’re declaring the variable. not just saying there’s a bool.

@surfuay @WarmedxMints

NVM, I seem to have solved this issue. The thing was, I placed the ExitHider component ON the EXIT itself, which when deactivated, cannot be reactivated.

Thank you for taking your time to help me non the less.