The contents of my if-statement are being called even when the conditions are not met

Just … seriously, DO NOT code like this:

You’re asking "Is there ANY GameObject named “PlayerSpawn” And then you’re checking if the chosenBlock is named “PlayerSpawn” If the second part is true, how could the first part NOT be true?

That’s why we don’t use GameObject.Find(). Just… don’t.

And this… just make a mouse indicator graphic in the scene and drag in a reference to it:

Remember the first rule of GameObject.Find():

Do not use GameObject.Find();

More information: https://starmanta.gitbooks.io/unitytipsredux/content/first-question.html

More information: https://discussions.unity.com/t/899843/12

In general, DO NOT use Find-like or GetComponent/AddComponent-like methods unless there truly is no other way, eg, dynamic runtime discovery of arbitrary objects. These mechanisms are for extremely-advanced use ONLY.
If something is built into your scene or prefab, make a script and drag the reference(s) in. That will let you experience the highest rate of The Unity Way™ success of accessing things in your game.

“Stop playing ‘Where’s GameWaldo’ and drag it in already!”

1 Like