Question by
zacharyaghaizu · Nov 27, 2020 at 09:46 AM ·
mobileinput.getkeyinput.touch
Replace if( Input.GetKeyUp) & if (Input.GetKeyDown) for TAPPING SYSTEM in MOBILE
I followed a tutorial by Peer Play link text to get a tempo tapping system. And I've tried to replace the keyboard inputs with mobile inputs. They don't work the same and allow me to tap 4 times to get the tempo. I tried Onclick, buttons, On pointer down/up events, also touch input too. They all end up not working on the tempo tapper like the computer input buttons. Appreciate any help.
void Update()
{ Tapping();
BeatDetection();
}
public void Tapping()
{
if(Input.GetKeyUp(KeyCode.F1))
{
_customBeat = true;
_tap = 0;
}
if (_customBeat)
{
if(Input.GetKeyDown(KeyCode.Space))
if ((Input.touchCount > 0) && (Input.GetTouch(0).phase == TouchPhase.Began))
{
if(_tap<4)
{
_tapTime[_tap] = Time.realtimeSinceStartup;
_tap++;
}
if(_tap==4)
{
float averageTime = ((_tapTime[1] - _tapTime[0]) +(_tapTime[2] - _tapTime[1]) + (_tapTime[3] - _tapTime[2])) /3;
_bpm = (float)System.Math.Round((double)60/averageTime,2);
_tap = 0;
_beatTimer = 0;
_beatTimerD8 = 0;
_beatCountFull = 0;
_beatCountD8 = 0;
_customBeat = false;
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Can anybody help me with a smooth touch control? 0 Answers
2d touch not working 0 Answers
Cinemachine On Mobile? 1 Answer
Can I render an extra frame onapplication pause in android? 0 Answers
Problem With The Shooting Script 0 Answers