Hello,
Super simple question.
At the moment I make my character jump using:
if (grounded && Input.GetKeyDown (KeyCode.Space)) { rigidbody2D.AddForce(new Vector2(0,jumpForce)); }
I want to change this to work on a touch screen.
I would like to make it so the character will jump when the user taps anywhere on the screen.
I’m not sure there’s a question in there but, but get touch will work for touches. I use
Input.GetMouseButtonDown(0)
This will work for mouse clicks in the editor and will also work with touches on a device. Don’t have to write separate code for touchscreen device and editor unless you are doing something more complex with the touches other than what it looks like
if(Input.GetTouch(0).phase == TouchPhase.Began)
{
//jump
}