Question by
MrCreator97 · Jun 15, 2016 at 07:26 PM ·
guiinputplayertouchtouchscreen
Separate Input from Touch on GUI
Hi everyone!
I've been working on a one tap game recently, and I've created a button on the top right corner of the screen to open a little Pause In-Game menu, the problem is that whenever I tap on the button, my player jumps too, since I use Input.GetAnyKeyDown for the input.
Any suggestions on how to make it work?
Code for the PlayerController:
void Update()
{
//Jumping
if (Input.anyKeyDown && canMove)
{
if (grounded) {
body2d.velocity = new Vector2(body2d.velocity.x, jump);
animator.SetBool("jumping", true);
audioSrc.clip = jumpSnd;
audioSrc.Play();
}
//Right movement
body2d.velocity = new Vector2(speed, body2d.velocity.y);
}
Comment