Int comparison between two scripts is not working
Well, I'm trying to compare two int type variables from two different scripts, however, it seems it's not working as I expected. This is a part of the code:
Level manager;
void Start(){
manager = GameObject.FindGameObjectWithTag("LevelManager").GetComponent<Level>();
}
void Update(){
if(ObjectForGoalNumber == manager.currentStateGoal){
Debug.LogWarning("You can use this object! Object name: " + this.gameObject.GetComponent<GameObject>().name);
interactable = true;
}
else{
Debug.LogWarning("Nah");
}
}
currentStateGoal it's a non static member, so I had to use GetComponent to access to it.
Now, the problem begins when I'm trying to compare the local variable ObjectForGoalNumber and manager.currentStateGoal. The comparison is never made, and therefore, interactable is never true. Both of them have the same value, but it seems it's not working. Also, both of them are active. Any ideas of what it could be? I'm having a bad time trying to figure it out hehe.
Your answer
![](https://koobas.hobune.stream/wayback/20220613000733im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Auto Set vs Manual Decrease (How to do both?) 1 Answer
Trying to make a door. Zoning or Load Level with Animation. 1 Answer
Set the username with an inputfield ? 3 Answers
I need a Simple and Clear example for how to add a texture (image) to a quad in C# 3 Answers
create .dll file by c# scripting and read/write data in created file through c# scripting 0 Answers