Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Brackeys 2D Movement Jump Not Working

Discussion in 'Getting Started' started by Cahtoah, Jun 15, 2020.

  1. Cahtoah

    Cahtoah

    Joined:
    Jun 11, 2020
    Posts:
    3
    I am new to coding and I watched the "2D Movement in Unity (Tutorial)" video by Brackeys. *Yes I went to their discord and multiple others as well.* The moving and crouching all works so far however my character will not jump. (My ground check is lower than the players hitbox.)
     
  2. elliotfriesen

    elliotfriesen

    Joined:
    Mar 17, 2020
    Posts:
    71
    Can you submit your code here
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,064
    Either post your code and make a specific question, or ask "Brackeys", don't assume everyone is familiar with some terrible youtube tutorial you found.
     
  4. Cahtoah

    Cahtoah

    Joined:
    Jun 11, 2020
    Posts:
    3
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class PlayerMovement1 : MonoBehaviour
    {
    public CharacterController2D controller;
    public float runSpeed = 40f;
    float horizontalMove = 0f;
    bool jump = false;
    bool crouch = false;
    // Update is called once per frame
    void Update()
    {
    horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;

    if (Input.GetButtonDown("Jump"))
    {
    jump = true;
    }

    if (Input.GetButtonDown("Crouch"))
    {
    crouch = true;
    } else if (Input.GetButtonUp("Crouch"))
    {
    crouch = false;
    }
    }

    void FixedUpdate()
    {
    // Move our character
    controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);
    jump = false;
    }
    }
     
  5. Cahtoah

    Cahtoah

    Joined:
    Jun 11, 2020
    Posts:
    3
    Video title and channel is there, said I asked their discord, and stated my problem as well as one solution I tried. New here sorry for your confusion
     
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,064
    Use code tags to better format your code. Seems you're using a Unity character controller, since those are pretty terrible I never use them, so I don't know the answer, but why are you setting jump to false in every fixed update?
     
  7. MustyMuffin

    MustyMuffin

    Joined:
    Mar 16, 2021
    Posts:
    3
    Lol this guy patronized you, insulted Brackey's, which is stupid because of how good his channel really is and him dedicating a decade of his life to make unity more accessible for beginners (because people like this commenter exist), made excuses for why he couldn't answer the question, and then answered the question!
     
  8. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,064
    Thank you for the meta-commentary a year and a half later.

    If you want an update on my situation: I now know who Brackeys is and I can confirm that I do not like his videos. I guess he didn't like them much either since he stopped making them.

    I still think posting about an issue without providing the relevant code is a bad idea, and going even further by not providing context, or a link to the tutorial itself, and assuming everyone knows what you're talking about is an even worse idea.

    I also still think Unity's character controller is terrible and shouldn't be used by anyone.

    If you have any actual issues and need help, please post code (in code tags) and not just refer to a random tutorial you just watched assuming everyone else knows what you're talking about.
     
    Last edited: Jan 23, 2022
  9. SaunaYon

    SaunaYon

    Joined:
    Nov 30, 2022
    Posts:
    2
    I'm also new and if your saying that character controller is bad what is the better way of writing a character movement script and where can I learn that way.
     
  10. RichAllen2023

    RichAllen2023

    Joined:
    Jul 19, 2016
    Posts:
    1,026
    I hate to be pedantic but when you're doing code, watch your spelling and grammar, it doesn't like typos.

    Like your equals you're :D