2D JUMP IN UNITY IN UNDER 1 MINUTE

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 76

  • @keeyuhl
    @keeyuhl Рік тому +18

    For anyone confused about the variables, basically a float is a number value, it allows decimals. A int doesn't allow decimals into their value. And the difference between private and public is that private only gives the script the information that the variable has and public allows information that the variable has outside the script, making it being configurable outside the script too.

    • @cgillis3989
      @cgillis3989 9 місяців тому

      We came to this one minute tutorial to NOT hear all the explanations
      (Jk, I'm just teasing- it's always a good idea to understand the variables lol. Thank you)

    • @Mattuzik
      @Mattuzik 5 місяців тому

      ДА НУ НАХУЙ, Я НЕ ЗНАЛ

  • @Blaxe75
    @Blaxe75 Рік тому +10

    THANK U SO MUCH BRO this helped so much i have been trying to find a decident jump script for days and i find this vid u helped so much keep up the good work

  • @W5529Fortnite
    @W5529Fortnite Рік тому +5

    This is a life breaker I just got pure errors one after the other

    • @Rapu65
      @Rapu65 2 місяці тому

      Remember to check your spelling

  • @spikeleon8408
    @spikeleon8408 Рік тому +3

    THANK YOU. Your video is short, but very informative, thanks😊

  • @ilyjothepig9314
    @ilyjothepig9314 Рік тому +29

    What about the ground check? Currently you’ can just jump forever essentially flight.

    • @kryuza3191
      @kryuza3191 Рік тому +9

      just add collision,
      whenever the player is collsion to the ground its ready to jump but whenever the player is not touching the ground its not ready to jump

    • @gianlucapapa1508
      @gianlucapapa1508 Рік тому +6

      ​@@kryuza3191 how can I add it? it's my first time doing it

    • @kryuza3191
      @kryuza3191 Рік тому

      @@gianlucapapa1508 ua-cam.com/video/ctpExP8GaiQ/v-deo.html&ab_channel=bblakeyyy

    • @xFizzo0606
      @xFizzo0606 Рік тому +1

      @@gianlucapapa1508 hes not gonna answer it since its 4 months old

    • @JakeSimmer
      @JakeSimmer Рік тому +1

      @@gianlucapapa1508 find other 2dvids bro, 'isjumping' = tru, they put that in the ifstatement. would be cool to keep on jumping tho... Keep on trucking and trying. I only just started and those first steps are soo hard, but allmost there to understand c#... ;-)

  • @cgillis3989
    @cgillis3989 9 місяців тому

    Very concise and effective, thank you very much :)

  • @Nightlock77
    @Nightlock77 9 місяців тому

    Why do you prefer default force over impulse?

  • @avalonsculpture9662
    @avalonsculpture9662 Рік тому +2

    how do i bind the jump key to space? it is not binded to any key just "Jump" which is not a key

    • @Isaac096
      @Isaac096 Рік тому

      Ya idk how to do that

    • @hello.4693
      @hello.4693 5 місяців тому

      Old input system:
      bool isJumping = Input.GetKeyDown(KeyCode.Space);
      use this in if statement like
      if(isJumping)

    • @DVFGAVYC
      @DVFGAVYC 2 місяці тому

      Same

    • @DJalonsi
      @DJalonsi Місяць тому +1

      "Jump" already has a keybind which is within Unity's built-in Input Manager system, so you shouldn't have to physically bind it through code

  • @SAITAMAgotTHeW
    @SAITAMAgotTHeW 4 місяці тому +1

    i dont want flappy bird

  • @namelesskok378
    @namelesskok378 Рік тому +1

    So how do i jump aka how do i do the jump key?

  • @tom_a_tree_is_like_a_bee_w4297
    @tom_a_tree_is_like_a_bee_w4297 5 місяців тому

    No fixedupdate for jump collision via layers?

  • @Jestl0w
    @Jestl0w Рік тому +1

    When I click on the script in unity the float doesn’t appear but I put in the float what’s wrong?

    • @Akaz8115
      @Akaz8115 Рік тому +1

      Be sure that it is public or SerializedField private

  • @impactsport109
    @impactsport109 Рік тому

    Thank you so much ❤

  • @BlexStone
    @BlexStone Рік тому

    you should add a time.deltatime moltiplication

    • @toontween
      @toontween Рік тому

      in this case it would be forcemode.impulse

    • @iamstill1451
      @iamstill1451 Рік тому

      What is the use of delta time I am new to all this so idk also this method is more simpler

  • @Capsule-tu6mu
    @Capsule-tu6mu Рік тому +2

    Bro what mine just flyies into the stratosphere

    • @kattree3216
      @kattree3216 3 місяці тому

      too much jump

    • @Rapu65
      @Rapu65 2 місяці тому

      Lower the jump value

  • @Finnersagrinners
    @Finnersagrinners 7 місяців тому

    How can I make it so it won’t fly if you hold it

  • @xHavki
    @xHavki Рік тому

    thank you

  • @Ameno_Pubg
    @Ameno_Pubg Рік тому

    Thanks

  • @Shergon_41k
    @Shergon_41k Рік тому

    How to do a dash in a topdown game by using the new input system?

  • @WRENS_HUMAN
    @WRENS_HUMAN 11 місяців тому

    It says that I need a jump input can you help me out😅

  • @morebblakeyyy
    @morebblakeyyy  Рік тому +1

    Have a full player movement script available on my Patreon: www.patreon.com/BlakeyGames

  • @alandhemn4102
    @alandhemn4102 2 роки тому +1

    keep going

  • @Beanilikecheeeese
    @Beanilikecheeeese Рік тому

    can you have tutorial on how to give the caracter animation with that script

    • @CrayZeeAnimations
      @CrayZeeAnimations Рік тому

      Use animation controllers (in the controller use transition arrows, parameters, and conditions)

  • @basicallyluci8048
    @basicallyluci8048 Рік тому

    knowing how to define the jump key would be nice..

    • @Gamemaker_101
      @Gamemaker_101 8 місяців тому

      Thats Space

    • @slimecraft7620
      @slimecraft7620 4 місяці тому

      pretty sure that's what the Input.GetButtonDown is

    • @Rapu65
      @Rapu65 2 місяці тому

      you can define it on project settings > Input manager > axes

  • @PMI6407
    @PMI6407 Рік тому +1

    COOL!

  • @GaryyHe
    @GaryyHe Рік тому

    It said cannot convert ‘float’ to ‘string’. Pls help

    • @blazer6972
      @blazer6972 Рік тому

      same for me. I dont know why.

  • @mangofr73
    @mangofr73 Рік тому

    what do you mean about the jump float

    • @annoyingdog9646
      @annoyingdog9646 Рік тому

      He means make the character jump more like a person and less like a balloon

    • @mangofr73
      @mangofr73 Рік тому

      @@annoyingdog9646 no like when he says multiply by the jumjp float

  • @bigsmough
    @bigsmough Рік тому +3

    Lifesaver

  • @bumbomumboni4735
    @bumbomumboni4735 2 роки тому

    How do you set the jump key to a mouse click

    • @tntobi80
      @tntobi80 2 роки тому +1

      for a left click its mousebutton 1 and right click mousebutton 2

    • @fillowskyy
      @fillowskyy Рік тому +3

      if (Input.GetKey(KeyCode.LeftMouseButton)

  • @Reaperplayz21
    @Reaperplayz21 Рік тому

    i really never tried to make a game it'll be bad😐

  • @maki9462
    @maki9462 Рік тому

    interact

  • @zaidorigami1281
    @zaidorigami1281 Рік тому +1

    can you please give me the source code?

    • @xFizzo0606
      @xFizzo0606 Рік тому

      heres the script so i can save u $8.50 using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class PlayerJump : MonoBehaviour
      {
      private Rigidbody2D rb;
      public float jump;
      // Start is called before the first frame update
      void Start()
      {
      rb = GetComponent();
      }
      // Update is called once per frame
      void Update()
      {
      if (Input.GetButtonDown("Jump"))
      {
      rb.AddForce(new Vector2(rb. velocity.x, jump));
      }
      }
      }

  • @taylortaco-x4k
    @taylortaco-x4k Рік тому +1

    can I have the code?

    • @Hietakissa
      @Hietakissa Рік тому +2

      @@unitylearning8736 that's not a better way of doing it, just different. In your example you are overriding the player's velocity, which may not always be wanted.
      Alternatively you could use AddForce but use ForceMode.Impulse and run it once so it works the same but doesn't override the velocity.

    • @unitylearning8736
      @unitylearning8736 Рік тому

      @@Hietakissa
      Not really overriding the velocity, we are setting velocity to equate to a locked Vector instead of instantiating a new Rigidbody velocity every frame.
      Say you want to create a variable that controls jump height, you will keep needing to add a new Rigidbody velocity.. Using this method, you can just modify the Vector2. Simple, easy, and much more efficient.

    • @Hietakissa
      @Hietakissa Рік тому

      @@unitylearning8736 Yeah I guess I didn't fully read your comment. My point was that if the player were falling and jumped the downwards velocity would have no effect on the jump which may not always be desired, but that could easily be fixed just by setting the y velocity to rb.velocity.y + jumpForce instead.
      You could also use AddForce, so you still wouldn't be creating a new Vector3 every time you jump.
      Realistically this won't have any effect on performance but you are right it's better to just set the values of the existing Vector instead creating a new one and generating that 96 or so bits of garbage.

    • @ignacio3312
      @ignacio3312 Рік тому

      @@unitylearning8736 can you change the original code to match your changes?

    • @unitylearning8736
      @unitylearning8736 Рік тому

      @@ignacio3312 I can create a UA-cam video so that you will learn out of it. Also can create ground check function because I don't believe it is showcased here..

  • @rubabmubarrat
    @rubabmubarrat Рік тому +2

    just as I guessed you're BRI'I'SH

  • @DamiSel4137
    @DamiSel4137 9 місяців тому

    What do I do with “Assets\playerJump.cs(20,58): error CS1002: ; expected”?

    • @skycloud97
      @skycloud97 8 місяців тому

      That means I think on line 20 there is no semi colon at the end

    • @slimecraft7620
      @slimecraft7620 4 місяці тому

      @@skycloud97 i tried that and it still doesn't work

    • @skycloud97
      @skycloud97 4 місяці тому

      @@slimecraft7620 i might have gotten that wrong do you know where the error line is? Or if you’re lazy like me use chatgpt to check it just throw the code and it will probaly fix it also i have took a long break from unity