- Home /
Unity see different objects as the same
Hello, why unity see two different objects as the same?
if (pathwalking.GetComponent<Pedestrianarean>().Next[randPath] == pathTemp)
{
Debug.Log(pathwalking.GetComponent<Pedestrianarean>().Next[randPath] + " " + pathTemp);
Debug.LogError("The same!");
}
And Debug:
Your question is lacking important information. What type does pathTemp has? What is "Next"? is randPath a variable / field or a property?
We need much more context to give any meaningful answer. If the type you're comparing is a UnityEngine.Object derived type you're actually using the overloaded == operator The CompareBaseObjects method just compares the instance id of the object which should never be equal for two different objects. If they are you somehow messed something up.
Your answer
Follow this Question
Related Questions
Check value equality of two Instances of the same type 2 Answers
Check if Material of a gameObject == a material variable (instance)? 2 Answers
Spawn Script Not Working 1 Answer
Using Environment variables (Such as keys to external services) 1 Answer
Having some problems with randomization 2 Answers