title: Unity Jumping code for player not working
body: <p>The jump button is not working in my unity, as my player is not jumping. I followed a tutorial but it does not seem to work. Must be something wrong with my code but I cannot seem to work it out as there are no errors.</p>
  
  <p>I am not sure but, I created an image in unity and placed it in canvas and named it "Fixed Joybutton", with the script Joybutton.cs, but when I run it and try to click it, it wont make my player jump. I thought the problem was the "joybutton = FindObjectOfType();" and changed it to "joybutton = GetComponent();" but still doesnt work.</p>
  
  <p>This is the code for the jump button itself, Joybutton.cs: </p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.EventSystems;
  </code></pre>
  
  <pre><code>{
      [HideInInspector]
      public bool Pressed;
  
      // Start is called before the first frame update
      void Start()
      {
  
      }
  
      // Update is called once per frame
      void Update()
      {
  
      }
  
      public void OnPointerDown(PointerEventData eventData)
      {
          Pressed = true;
      }
  
      public void OnPointerUp(PointerEventData eventData)
      {
          Pressed = false;
      }
  }
  
  // and this is the code that is in my player, PlayerController.cs:
  
  using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  
  public class PlayerController : MonoBehaviour
  {
  
  
      protected Joystick joystick;
      protected Joybutton joybutton;
      protected bool jump;
      public float speed;
      public Text playerDisplay;
      public Text scoreDisplay;
      public bool isFlat = true;
  
      private Rigidbody rb;
      public static int count = 0;
  
      private void Start()
      {
          joystick = FindObjectOfType&lt;Joystick&gt;();
          joybutton = FindObjectOfType&lt;Joybutton&gt;();//this is to find the object, I changed it to "joybutton = GetComponent&lt;Joybutton&gt;();" but still doesnt work
          rb = GetComponent&lt;Rigidbody&gt;();
  
      }
  
  
  
      private void FixedUpdate()
      {
  
          rb.velocity = new Vector3(joystick.Horizontal * 5f, rb.velocity.y, joystick.Vertical * 5f); // joystick to move my player, its working
  
          if (!jump &amp;&amp; joybutton.Pressed)// this is for the jump, that is not working
          {
              jump = true;
              rb.velocity += Vector3.up * 10f;
          }
  
          if (jump &amp;&amp; !joybutton.Pressed)
          {
              jump = false;
          }
  
  
      }
  
  
      public void OnTriggerEnter(Collider other)
      {
          GameObject gameControl = GameObject.Find("Timer");//name of my gameobject
          Loading loading = gameControl.GetComponent&lt;Loading&gt;();
          if (other.gameObject.CompareTag("Pick Up"))
          {
              other.gameObject.SetActive(false);
              count = count + 1;
              Awake();
          }
          else if (other.gameObject.CompareTag("Time Boost"))
          {
              other.gameObject.SetActive(false);
              loading.sec += 10;
              if (loading.sec &gt; 60)
              {
                  int sec1 = loading.sec - 60;
                  loading.sec = sec1;
                  loading.minutes ++;
              }
  
              Awake();
          }
      }
  
      private void Awake()
      {
          if (DBManager.username == null)
          {
              UnityEngine.SceneManagement.SceneManager.LoadScene(0);
          }
          playerDisplay.text = "Player: " + DBManager.username;//display username
          scoreDisplay.text = "Score: " + count.ToString();//display score 
      }
  
  }
  
  
  //Player is moving but cannot jump. Please show me the error in my code and solution. Thank you so much.
  </code></pre>