What should i change in this to make my game to work in android?

i am making a game called angry eggs
it is perfectly awesome and working …
now i want to convert it to android .
what should i change in this script to make the character jump when the screen is tapped.?
using UnityEngine;

 public class Player : MonoBehaviour
 {
     // The force which is added when the player jumps
     // This can be changed in the Inspector window
     public Vector2 jumpForce = new Vector2(0, 300);
     
     // Update is called once per frame
     void Update ()
     {
         // Jump
         if (Input.GetKeyUp("space"))
         {
             rigidbody2D.velocity = Vector2.zero;
             rigidbody2D.AddForce(jumpForce);
         }
         
         // Die by being off screen
         Vector2 screenPosition = Camera.main.WorldToScreenPoint(transform.position);
         if (screenPosition.y > Screen.height || screenPosition.y < 0)
         {
             Die();
         }
     }
     
     // Die by collision
     void OnCollisionEnter2D(Collision2D other)
     {
         Die();
     }
     
     void Die()
     {
         Application.LoadLevel(Application.loadedLevel);
     }
 }

Use the 4.6 UI. If you want that jump from a touch anywhere on the screen add a Canvas and then a button, stretch the button so it fills the entire canvas and remove the button image and text (or add a Canvas Group and set the Alpha to 0 - invisible).

add a public function to your script called something like PlayerJump() and put your code in there.

          public void PlayerJump()
          {
              rigidbody2D.velocity = Vector2.zero;
              rigidbody2D.AddForce(jumpForce);
          }

Select the button and look in the inspector, Click + for the OnClick part of the button. A slot appears so whatever your script is attached to drag that onto the slot. Then from the drop down select your script name → PlayerJump.

Job done :slight_smile: