- Home /
Unity Touch=2 commends?
Hi. I have problem. This is my simple script:
if(Input.touchCount==1&&guiTexture.HitTest(Input.mousePosition)&&may==true){
may=false;
belaK.SendMessage("Zb");
OP();
}
function OP(){
yield WaitForSeconds(0.2);
may=true;
}
The function ZB is here:
function Zb(){
if(may==false&&may2==true){
mesh.enabled=false;
Instantiate (build1, point.transform.position, point.transform.rotation);
}
}
And this ZB function create 1 build, but when i touch GuiTexture (to Send Message function Zb) function Zb create 2 builds. I don't have any idea how fix it.
Maybe you know?
Thanks in advence ;)
Answer by fred_gds · Dec 19, 2013 at 10:21 PM
Does the player need to touch the texture/button with two fingers? if not you could only use Input.touchCount > 0
so then you should always use Input.GetTouch(0).phase == TouchPhase.Began (or .Ended whatever you need) because other ways it will call the function every frame in which the finger is down.
http://docs.unity3d.com/Documentation/ScriptReference/Touch-phase.html
that should fix your problem
Your answer
Follow this Question
Related Questions
Touch returns twice on Android 1 Answer
Problem with Input.touchCount == 1 1 Answer
touch buttons function OnGUI issue 1 Answer
Scripts don't work when i try app 2 Answers
Standard Assets disappears in somes Android Phones 0 Answers