I am trying to make my character jump when the player taps the screen.
At the moment it jumps when I press space bar, but how can I change the code to make him jump when the screen is tapped?
This code works as the character then jumps up:
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
rb.gravityScale *= -1;
}
}
This code using touch does not work: the character just stays where he is when I click the screen on my computer.
public void Update()
{
if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
rb.gravityScale *= -1;
}
}