- Home /
Input.GetTouch(0).tapCount question
I used:
if(Input.GetTouch(0).tapCount == 2)
to make a space ship fire a laser. It all works fine, except, if I continue to hold down on the ship on the second click, it will perpetually fire lasers every frame. How do I say "If it is a NEW double click, then fire another laser?"
Thanks guys, this is my first game, just learning how to do all this stuff!
Answer by HolidayAtHome · Apr 14, 2013 at 12:58 PM
GetTouch(0) is your first finger so if you want to check a second finger just write
if(Input.GetTouch(1).tapCount == 2)
third finger
if(Input.GetTouch(2).tapCount == 2)
and so on =)
Answer by Graham-Dunnett · Apr 14, 2013 at 01:08 PM
Look at:
http://docs.unity3d.com/Documentation/ScriptReference/Input.GetTouch.html
This describes how the touches are handled. Each touch has a value called Phase
, see:
http://docs.unity3d.com/Documentation/ScriptReference/TouchPhase.html
If a finger is pressed down onto the screen you will get a touch where phase
is set to TouchPhase.Began
. This is how you should check that a finger has been pressed. So, if tapCount
is 2 and one of the touches has TouchPhase.Began
then you have a new, second finger press.