Hello there,
Im new to Unity, and i got a small problem.
Imagine i have a square, on which another gameobject should become visible after i click on that gameobject. It should however only happen once, and on the second click it should do nothing.
I can create the object on a click, but how can i store the fact that the gameobject has been clicked already, so it wont create a new gameobject on every click. What i would like is for example a variable named "inUse" attached to every GameObject, which can have the value true or false. Ofcourse, when a new gameobject gets created it should be set to false.
I think, i need to add a new component or something to the gameobject that keeps track of this, but i cant seem to do that ;)
I hope someone can help.
Thanks in advance.
Thanks both for the answers. I did that, but now im running into more problems ;) In short, i got it working, however, now i want to check from the script, if any of the other objects are also clicked. my code: public class click : MonoBehaviour { public bool isclicked = false; public int clickedby = 0; void checkWinner() { print(Cube5.clickedby); print(clickedby); The first print does not work, the second prints the value in clickedby, of the current object. How can i read te value of the other object ?
– anon9371456You should open a new question for this, so others may find the answer to this question.
– StephanK