- Home /
Question by
Leos924 · Mar 12, 2015 at 12:11 AM ·
androidjavascriptinputtouch
Touch Input in Android...
I want to make an Android game but i doesnt know how to "correctly" know when the player touches an object or when the player drag it, and i want to know how to use the android input to make a good menu and use it ingame of course. Any help is welcome :) And sorry for my bad english.
Comment
Best Answer
Answer by kevinspawner · Mar 12, 2015 at 02:29 AM
This script twill help you to start the basic touch, all you need to do is place the below code in update function. It will not work just like that, you need to write some simple movement code inside the touch phase, if you have any questions feel free to write down in comment. Good Luck.
if(Input.touchCount>0)
{
foreach(Touch touch in Input.touches)
{
TouchPhase phase = touch.phase;
switch(phase)
{
case TouchPhase.Began:
// When Touch started
break;
case TouchPhase.Moved:
// when touch moved
break;
case TouchPhase.Ended:
// Touch when ended
break;
}
}
}