[Help] Problem in making simple jumping character

Hi, I’m an absolute beginner and I want to get a grasp of Unity as a person with no background whatsoever in computing language.

I’m following the 2D tutorial on

but I am not concerned with the animations therefore I have omitted the lines related to the animation however with the followingcode I have created, I cannot make a character jump.

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour
{

    public float jumpforce = 10f;
    public float maxSpeed = 10f;
    private Rigidbody2D rb;

    bool grounded = false;
    public Transform groundcheck;
    public float groundRadius = 0.2f;
    public LayerMask whatIsGround;

    // Use this for initialization
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        CharacterController controller = GetComponent<CharacterController>();
    }

    // Update is called once per frame
    void Update()
    {
        if (grounded && Input.GetKeyDown(KeyCode.Space))
        {
            rb.AddForce(new Vector2(0, jumpforce));
        }
    }


    void FixedUpdate()
    {
        grounded = Physics2D.OverlapCircle(groundcheck.position, groundRadius, whatIsGround);

        float move = Input.GetAxis("Horizontal");

        rb.velocity = new Vector2(move * maxSpeed, rb.velocity.y);

    }
}

Here is a reference screenshot of my work,

This is a screenshot of my desktop if needed. Imgur: The magic of the Internet

You’ll probably want to use ForceMode2D.Impulse, since you’re modeling the jump as an instantaneous force (only forcing for one frame):

rb.AddForce(new Vector2(0, jumpForce), ForceMode2D.Impulse);

You never want to get Inputs in FixedUpdate, as FixedUpdate could be called more than once, or not at all between two game Updates depending on framerate.

Get your Inputs in Update, then add your forces in FixedUpdate.

Thanks a lot! Such a simple solution. I appreciate your help!

I’ve took your points to great consideration. I’ll be sure to change my code to reflect this. Thanks for the additional pointers~