Hey there, I asked this in Unity answers but couldn’t really understand the explanations I was given. So basically I was following a tutorial and its about tiling backgrounds. So when I call the function from the if statment, the boolean hasARightBuddy (and hasALeftBuddy) set to true, so that the function won’t be called again.
However this just isn’t the case. If i leave this code out then the object is STILL instantiated. So naturally I’m wondering if the function is no longer being called, then why is the object still instantiating. Why the need for the code at the bottom?
if (rightOrLeft > 0)
{
newBuddy.GetComponent<Tiling>().hasALeftBuddy = true; // the newBuddy of our tiling script that is instantiated on the left (the instantiated object that met the conditions of hasALeftBuddy...that was invoked invoked)
}
else
{
newBuddy.GetComponent<Tiling>().hasARightBuddy = true; // the newBuddy of our tililng script that is instantiated on the right
}
So after trying to use a prefab (instead of the actual gameObject that already exists in scene), it turns out that it doesn’t work, and it doesn’t work because the prefab that is created is actually asking for another prefab to be dragged in so that it can keep duplicating them. so yea kind of interesting. Not 100 percent sure on how the code works, but so far that’s what I have found out.
I actually have a new problem, and thought I would post it here rather than try and start a new thread. Basically I can’t really make a connection with the booleans in the last if and else statements in the script. In order to try and make sense of it, I wrote out a sentence.
if the parameter is -1 have the variable (newBuddy) of this script given the property hasALeftBuddy = true because the hasALeft Buddy Boolean…
and then I draw a blank. Does anybody think they can help me with the rest of the logic? Does it cut off the entire Update function?