- Home /
Problems with finger count.
I am trying to make simple controls for player. If you tap with one finger, you start rotating cw, but if you tap with 2 fingers instead, you rotate in opposite direction. Everything works well so far, but there is one annoying problem. You have to be extremely precise while tapping with two fingers and if you don't pay 100% attention player will rotate in the wrong direction. Is there any way how I can increase accuracy?
Here is my code so far:
bool seObrne = false;
void Update (){
int fingerCount = 0;
foreach (Touch touch in Input.touches) { if (touch.phase != TouchPhase.Stationary)
fingerCount++; }
if ((Input.GetKeyDown (KeyCode.Space) || Input.GetMouseButtonDown (0))) { seObrne = true; }
if (fingerCount == 1 && seObrne == true) {
seObrne = false;
stevilo++;
transform.rotation = Quaternion.AngleAxis (rotacija * stevilo, Vector3.up);
{ transform.rotation = Quaternion.Euler (90, transform.rotation.eulerAngles.y, lockPos); }
}
else if (fingerCount == 2 && seObrne == true) {
seObrne = false;
stevilo +=3 ;
transform.rotation = Quaternion.AngleAxis (rotacija * stevilo, Vector3.up);
{ transform.rotation = Quaternion.Euler (90, transform.rotation.eulerAngles.y, lockPos); }
Thanks for taking time and your help!
It may appear that this is a result of the way you have segregated them using if/else. I could be wrong.
Thanks for your reply. However the code works, but it is too precise. It works only if you tap with two fingers at EXACTLY the same time. I would like to make it more user-friendly.