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!
Look at:
This describes how the touches are handled. Each touch has a value called Phase
, see:
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.
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 =)