title: Unity- Player Jump Height / Public, Private, Static, nothing
body: <p>I have been following a tutorial on 2D Player Controller in Unity (It's 'Live Training 16 Dec 2013 - 2D Character Controllers' video). </p>
  
  <p>I was able to implement everything the tutorial showed successfully with some edits to make it work in Unity 5. Afterwards, I decided to play around with it so that I can gain a better understanding. One thing I tried to do was changing the jump height when pressing the Space key. Here is the code:</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class RobotControllerScript : MonoBehaviour {
      public float maxSpeed = 10f;
      bool facingRight = true;
  
      Animator anim;
  
      bool grounded = false;
      public Transform groundCheck;
      float groundRadius = 0.2f;
      public LayerMask whatIsGround;
      public float jumpForce = 700f;
  
      // Use this for initialization
      void Start () {
          anim = GetComponent&lt;Animator&gt;();
      }
  
      // Update is called once per frame
      void FixedUpdate () {
  
          grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
          anim.SetBool("Ground", grounded);
  
          //vSpeed = vertical speed
          anim.SetFloat("vSpeed", GetComponent&lt;Rigidbody2D&gt;().velocity.y);
  
          float move = Input.GetAxis("Horizontal");
  
          anim.SetFloat("Speed", Mathf.Abs(move));
  
          GetComponent&lt;Rigidbody2D&gt;().velocity = new Vector2(move * maxSpeed, 
                                          GetComponent&lt;Rigidbody2D&gt;().velocity.y);
  
          if (move &gt; 0 &amp;&amp; !facingRight)
          {
              Flip();
          }
          else if (move &lt; 0 &amp;&amp; facingRight)
          {
              Flip();
          }
      }
  
      void Update()
      {
          if(grounded &amp;&amp; Input.GetKeyDown(KeyCode.Space))
          {
              anim.SetBool("Ground", false);
              GetComponent&lt;Rigidbody2D&gt;().AddForce(new Vector2(0, jumpForce));
          }
      }
  
      void Flip()
      {
          facingRight = !facingRight;
          Vector3 theScale = transform.localScale;
          theScale.x *= -1;
          transform.localScale = theScale;
      }
  }
  </code></pre>
  
  <p>Looking at the code and the tutorial explanations, jumpForce is the variable that controls how high the character will jump (force applied). So, I changed 700f to a 5f. I expected the character to make a really small jump, but this was not the case. It jumped at the same height as 700f. </p>
  
  <pre><code>public float jumpForce = 700f;
  </code></pre>
  
  <p>After playing around with the code, I was able to have the expected result by removing the 'public' next to jumpForce. Other ways to fix this was setting it to private or static. I remember I had a similar problem when making a temperature widget on QT Creator. I had to set a variable to static or else it would not return to the default value after C to F conversion, but I don't remember exactly why. </p>
  
  <p>Can anyone explain why 'public' does not work and why a private/static/nothing might? What is the best/efficient solution for this problem? Thank you very much.</p>