title: How can I make a game object jump when I press a key (preferably space)?
body: <p>I have this C# script attached to my main camera game object which also has a capsule collider attribute. However, it doesn't seem to do anything. How should I modify/add to this to make the camera "jump" and fall down to the ground again?</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class Jump : MonoBehaviour {
  
  
      [HideInInspector] public bool jump = false;
      public float jumpForce = 1000f;
      public Transform groundCheck;
  
  
      private bool grounded = false;
      private Rigidbody rb;
  
  
      // Use this for initialization
      void Awake () 
      {
          rb = GetComponent&lt;Rigidbody&gt;();
      }
  
      // Update is called once per frame
      void Update () 
      {
          grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 &lt;&lt; LayerMask.NameToLayer("Ground"));
  
          if (Input.GetButtonDown("Jump") &amp;&amp; grounded)
          {
              jump = true;
          }
      }
  
      void FixedUpdate()
      {
  
          if (jump)
          {
              rb.AddForce(new Vector2(0f, jumpForce));
              jump = false;
          }
      }
  }
  </code></pre>
  
  <p>Also, I would like to have the key for this be the spacebar if possible, but whatever key works or is there already is fine. I am still learning C#, so please forgive me if the solution is obvious.</p>