Ok so, I hope this question works…
I started developing my 2d character controls for PC (arrow keys) and, upon trying to convert my code so that it would work for Android as well (touch), I decided that the best course of action would be to add an or ( || ) condition for touch controls in the part of my code where it checks for user arrow keys input, and thus say:
“IF you receive arrow keys input OR touch input in a specific part of the screen, THEN move”.
My problem, at this point, is that now the game will only receive input through touch (via Unity Remote 4, if that helps any), and the arrow keys of my keyboard won’t work anymore. From a logical standpoint, however, my code seems pretty much flawless to me.
**SO… AS FOR THE BIG QUESTION: ** Is there something amiss in my code, a foundamental issue that I’m currently ignoring? Or maybe you’re not allowed to have PC and Android touch controls working at the same time?
if (standing) {
if ((Input.GetKey ("right"))||((myTouch.position.y<(Screen.width/8))&&((Screen.width/8f*7f)<myTouch.position.x)&&(myTouch.position.x<(Screen.width)))) {
direction=1;
if (absoluteVelX < maxvelocity.x)
forceX = standing ? speed : (speed * airdiminish);
} else if ((Input.GetKey ("left"))||((myTouch.position.y<(Screen.height/4))&&((Screen.width/8f*6f)<myTouch.position.x)&&(myTouch.position.x<(Screen.width/8f*7f)))) {
direction=-1;
if (absoluteVelX < maxvelocity.x)
forceX = standing ? -speed : (-speed * airdiminish);
}
if (Input.GetKeyDown ("up")) {
if (absoluteVelY < maxvelocity.y)
forceY = upspeed;
}
}
GetComponent<Rigidbody2D>().AddForce (new Vector2 (forceX, forceY));