- Home /
mobile programming questions
I have a question involving the mobile programming, mainly the input for touch. I am in the development/design phase of the mobile game and i wanted to know if for the touch sensor specifically android if there is a function similar to onmousedown where i am touching a button and holding it down and while it is down to instantiate and fire a projectile.
thanks in advance for any and all help.
Answer by dannyskim · Jan 31, 2012 at 07:21 PM
There is a stationary phase with the touch class.
http://unity3d.com/support/documentation/ScriptReference/TouchPhase.html
So:
void Update()
{
if( Input.touchCount == 1 )
{
Touch touch_0 = Input.touches[0];
switch( touch_0.phase )
{
case TouchPhase.Stationary:
//Do checks here
break;
default:
break;
}
}
}
Your answer
Follow this Question
Related Questions
cant touch multiple objects on screen (c# , mobile) 0 Answers
Button reaction time problem 1 Answer
How to only get touch on specific object? 0 Answers
How to Move the Car With Touch? 1 Answer