system
December 4, 2011, 9:57pm
1
Hi, i wanted to create a Button in unity which creat’s an object when i press it i tried:
if(Input.touchCount >=1) {
var touch: Touch = Input.touches[0];
if(touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) {
Instantiate(basis,pos.position,pos.rotation);}
else {Instantiate(basis,pos.position,pos.rotation);
}
}
}
But with this it doesnt stop creating objects, and it isnt a button at all, would be really thankful if anyone could help me.
gregzo
December 4, 2011, 10:34pm
2
Hi! Surely you’ve mistyped your script, because as we can read it, it basicaly says: if this, do that, and if not, well… do it as well! No wonder you’re instantiating lots of objects.
system
December 5, 2011, 12:49am
3
Yes I know,but the problem is that I don't know how to stop it, because stop/end don't work.
I tried `else {return Instantiate(basis,pos.position,pos.rotation);` but this also wont work.
delete this part
“else {Instantiate(basis,pos.position,pos.rotation);”