Hello,
i want that my finger touches makes a slide sound a la Fruit Ninja when moves.
Is there a way to do this also if the user don`t leave the finger from screen?
For example what i want… the user slides to the right(play slide sound)…the User stops sliding but keeps touching(no slide sound)…the user slides again (play slide sound again)
Here is my first try in a for loop, the tmpMousePosition is stored in Awake to begin and later in every new touch.
private var sound_once : boolean = false;
function Update()
{
for(var touch:Touch in Input.touches)
{
if (tmpMousePosition != touch.position){
Debug.Log("Mouse moved");
tmpMousePosition = touch.position;
slideSoundOnce();
}
if(touch.phase == TouchPhase.Ended)
sound_once = false;
}
}
function slideSoundOnce()
{
if (sound_once == false) {
GameManager_Script.audio_source2.PlayOneShot(slide_01);
sound_once = true;
}
}