How to Jump in Unity - Unity3D Fundamentals

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024

Комментарии • 243

  • @mateusferreiramoreira5147
    @mateusferreiramoreira5147 4 года назад +50

    Isn't it wrong to use physics related stuff inside update?

    • @DenizSimsek
      @DenizSimsek  4 года назад +30

      You are right. The physics related calculations, meaning adding force to a rigid body , should be in the FixedUpdate. My mistake here.

    • @mateusferreiramoreira5147
      @mateusferreiramoreira5147 4 года назад +2

      @@DenizSimsek That's absolutely fine. But, if may I ask, how would you o about jumping now? Toggling a bool in update so it can trigger the jump in fixed update?

    • @DenizSimsek
      @DenizSimsek  4 года назад +3

      You can move the jump related code, toggling and adding force to the FixedUpdate method. Update can only be used for the movement now. FixedUpdate and Update can be used within a script file at the same time. Their execution time will differ.

    • @raik1766
      @raik1766 4 года назад

      @@DenizSimsek my collisionenter is not doing anything whatsoever /:
      this is the code im using:
      private void OnCollisionEnter(Collision collision)
      {
      if (collision.gameObject.tag == "Ground")
      {
      OnGround = true;
      }
      }

    • @itstwilight7417
      @itstwilight7417 4 года назад

      @@raik1766 You should use: if (collision.gameObject.CompareTag("Ground")) instead since it's more performent

  • @jangronowski7450
    @jangronowski7450 5 лет назад +29

    finally a good turtorial its so hard to find these!!!

  • @TeréziaKorcová
    @TeréziaKorcová Месяц назад

    Thank you for the helpful tutorial:)) For anyone who might have the same issue: it wasn't working for me even though onKeyDown was fine - just had to increase the force, aka the middle number in the Vector3, cause my character model was set to be heavier than the cube in the video:D

  • @davidossuprimos9211
    @davidossuprimos9211 4 года назад

    Thanks for making this, it worked first time for me. Which is high praise considering that for me most tutorials on youtube don't work the first time for me.

  • @RohithPMenon-k7p
    @RohithPMenon-k7p 3 месяца назад

    BRO, i have been searching about this for a long time. But this was the right video for it. Thank you so much

  • @Maggiethegsd
    @Maggiethegsd 4 года назад +2

    Just saying this, nothing is better than creating a new fresh unity project, knowing that you have around 10 hours for yourself, and make start out in visual studio with all your knowledge!

    • @DenizSimsek
      @DenizSimsek  4 года назад +1

      I am addicted to fresh starts!

    • @SoulCatcher8965
      @SoulCatcher8965 Год назад +1

      @@DenizSimsek I am too and very but i am getting un addicted to it which i think is good

  • @khurum
    @khurum Год назад

    great this helped me a lot in going to make game in unity called collectables there are various tasks you have to do like search for 3 bottles and 2 cars and etc...

  • @JustinReeve
    @JustinReeve 2 года назад +2

    Thank you so so so much i've been trying to find a simple explanation of how to jump with a cube in unity and this is the perfect one Thank you!

  • @ManjeetSingh-ry6is
    @ManjeetSingh-ry6is 3 года назад

    Thanks a lot after 1 and a half day of watching videos and reading articles finally this worked thanks a lot you made my day

  • @pixeld2492
    @pixeld2492 2 года назад +1

    Thank you so much.
    I have a question that if i pressed “X” in a PS5 controller, will the character jump? If not, how do i do that?

    • @concotime
      @concotime Год назад

      To do that, look at the ps5 controller mapping for unity. That’s how I found out how to make a player jump in vr!

    • @pixeld2492
      @pixeld2492 Год назад

      @@concotime Thank you so much!

  • @XamXoXa
    @XamXoXa 3 года назад +1

    “We’ll name his ass……w….w..we’ll name it as” Good video and a good laugh thanks man!

  • @huseyincansimsek9675
    @huseyincansimsek9675 4 года назад +1

    Your english is so fluently. I took an example by you.

  • @jackjunior1439
    @jackjunior1439 3 года назад +5

    I can still only jump once :(

  • @swiftcreations
    @swiftcreations 4 года назад +2

    Thanks a ton! I couldn't figure this out, and all the other tutorials broke my movement code, really underrated channel right here.

    • @waviation9
      @waviation9 2 года назад

      Let me guess, your movement code is for the Brackeys tutorial

  • @quarathunisahussain8416
    @quarathunisahussain8416 4 года назад +6

    I'm stuck. I can only jump once. The CubeIsOnTheGround box doesn't check again. Stays unchecked

    • @X0MB
      @X0MB 3 года назад +3

      You can fix it by going to the if collision thingie in private void oncollision and then in the if(collision.gameObject.name == "Your ground name") your ground name means whatever you have named your ground as put the name there, done it worked for me after doing that :)

    • @quarathunisahussain8416
      @quarathunisahussain8416 3 года назад +1

      @@X0MB Thanks!!

    • @milindbhandari
      @milindbhandari 3 года назад

      @@X0MB thanks a lot dude. i had the same problem. Solved it!!!

    • @mahnoorfaisal2751
      @mahnoorfaisal2751 3 года назад

      @@milindbhandari The script doesnt work at all? I cant jump...do you have any tips?

  • @bobosmith101
    @bobosmith101 Год назад

    Won't this allow you to jump as long as you're touching a ground object, such as the side?

  • @nicktoelen3479
    @nicktoelen3479 4 года назад +15

    Why is it so difficult to find such good tutorials?!!

    • @kenpalarold9476
      @kenpalarold9476 4 года назад +4

      its number 1 if you search unity how to jump 3d
      soo for me it was not

    • @arpitsrivstva
      @arpitsrivstva 3 года назад

      Because most of the people are ... you know..

    • @SkorpionYassine
      @SkorpionYassine 2 года назад

      this one is bad trsut me

  • @EverythingRox
    @EverythingRox 4 года назад +2

    This was the video I was looking for. Thanksss.

  • @davidmcasas
    @davidmcasas 4 года назад +2

    With this method, wouldn't you be able to climb-jump a large cube if it's tagged as ground? Because when you jump towards its side you are colliding with it thus triggering the ground condition. Correct me if I'm wrong.

    • @nonEuclideanExplosive
      @nonEuclideanExplosive 2 года назад

      i aint no pro here, but you could place a invisible plane with tag ground thing and yeah. I realised whilst typing it aint perfect but ill leave it in case it helps

  • @deadbeamoth3744
    @deadbeamoth3744 4 года назад +6

    for some reason when I used this code for my player, i could only jump once. I would jump once and then I wouldn't be able to jump again. There were no errors that Unity could find. How do I fix this?

    • @wyatt2299
      @wyatt2299 3 года назад

      Are you sure that EVERY piece of cube or whatever your ground is is tagged as Ground?

    • @lucasnasr8496
      @lucasnasr8496 3 года назад

      same thing is happening to me

    • @lucasnasr8496
      @lucasnasr8496 3 года назад +1

      just figured it out, my void OnCollisionEnter was not was indented. Make sure it isn't indented into the void update function.

    • @bierdl7641
      @bierdl7641 3 года назад

      just write if(collision.gameObject){}works too

    • @nomad2809
      @nomad2809 3 года назад

      @@lucasnasr8496 not working

  • @simaolive4370
    @simaolive4370 2 года назад +1

    when I click the spacebar, nothing happens, I don't know if it's a project sentings problem
    please help me

  • @hamzarashid7579
    @hamzarashid7579 4 года назад

    Thank you for this tutorial I am tired of searching how to jump the player only one time
    Thank you for this amazing tutorial

  • @darabyss9963
    @darabyss9963 4 года назад +2

    Hello i wanted to know how do i make the fall when i jump faster? is tooo slow and you can literally move in the air

  • @jakesmeef0323
    @jakesmeef0323 4 года назад +7

    I think I did something wrong, so I followed the tutorial doing the same code as you but I can only jump once and after I land I can’t jump again, what’s happened?

    • @thenukdevendra1902
      @thenukdevendra1902 4 года назад

      probs you not set the varible back to true so you can jump again? Or something might not match in the script and your tags or names

    • @spyzn
      @spyzn 4 года назад

      @Jake Smeef03 This should help
      void OnCollisionEnter(Collision collision)
      {
      if (collision.collider.tag == "Ground")
      {
      groundCheck = true;
      }
      else
      {
      groundCheck = true;
      }
      }

    • @DemonPig666
      @DemonPig666 4 года назад

      @@spyzn thx i know im not him but this helped me a lo9t

    • @spyzn
      @spyzn 4 года назад +1

      @@DemonPig666 no problem :) always happy to help.

    • @lucasnasr8496
      @lucasnasr8496 3 года назад +1

      make sure your void OnCollisionEnter is indented to the right area. Make sure it isn't within the void update function

  • @akshatkumar7603
    @akshatkumar7603 3 года назад

    9:42 I had been having dis problem since a week..Ty I finally fixed it

  • @nipzipz208
    @nipzipz208 2 года назад

    I have I have some help because when you jump you slightly slow down and move normally when you touch the grounf

  • @wagon7052
    @wagon7052 4 года назад +3

    i rly wish that you didnt stop filming
    nice tutorial btw
    ty a lot

    • @DenizSimsek
      @DenizSimsek  4 года назад

      I plan to make more tutorials soon. Thank you for your comment!

  • @mustafadenizustaoglu106
    @mustafadenizustaoglu106 3 года назад

    Good work Dayi

  • @Elopo
    @Elopo 4 года назад +1

    Thank you bro you just saved me so much time subscribed

  • @FuS1oNDaBest
    @FuS1oNDaBest Год назад

    for me after I jump my character slowly goes in the air , yk why?

  • @vaggelismanousakis6147
    @vaggelismanousakis6147 3 года назад +1

    It didnt work for me Unity 2020.3.19f1 :/

  • @zartoz777
    @zartoz777 2 года назад

    How to do it so it can jump while its moving

  • @pyschofritz8955
    @pyschofritz8955 Год назад +1

    Hey man, thanks for the tutorial, just one question:
    When setting the variable back to "true" in the OnCollisionEnter() method, for me it does not set back to true. It becomes false when the user has jumped, but when landing it doesn't change back to true. I even checked to see if it the method was working by putting a Debug.Log and the method DOES execute, but the variable doesn't change. Any fix for this?

  • @lex-new-n2d
    @lex-new-n2d Год назад

    Is there a way to make shake camera when landing

  • @ferasalfarsi897
    @ferasalfarsi897 Год назад

    Thank you for the video, but please, zoom in, so we can see clearly
    the letters is very small.

  • @dirtroadgamer7276
    @dirtroadgamer7276 2 года назад

    Thanks man, this made it so simple!

  • @144hz_ichiro8
    @144hz_ichiro8 4 года назад

    THIS CHANNEL IS AMAZING you helped me so much thx

  • @ethankral3215
    @ethankral3215 3 года назад

    You are a savior btw

  • @sssmaxs2615
    @sssmaxs2615 4 года назад +4

    can you please copy and paste the script ? plz

  • @itzgrey6688
    @itzgrey6688 4 года назад +2

    so it works fine but when I take the cube to a slope it glitches and I cant jump

  • @HawX192
    @HawX192 5 лет назад +2

    Great Job with the tutorials! Hopefully you will continue them.
    Quick question, for example, when you jump on the platform and stay on the edge the player object will "fall" (change z axis rotation) how can i stop that?
    I added "rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionZ;" this stops that BUT if i stay on the edge on the platform long enough, then the object will walk on the side of the platform like a spider.
    How would one edit it, as to make the player "stand" on the edge but not fall, BUT also freeze the axis as to stop the side of the platform from becoming "the floor", i dont know if you understand what i mean.

    • @DenizSimsek
      @DenizSimsek  5 лет назад +1

      Thank you very much for your feedback. If I understand it correctly, you want the cube to stay on the edge without falling and not slide from the side of the platform. Right? If it is, I'll try to find a solution tomorrow.

    • @HawX192
      @HawX192 5 лет назад

      @@DenizSimsek Basically yes, as long as 1 pixel is on the platform, the player wont fall, BUT if it falls, i want the player to stay in the upright position, right now it starts falling and it "lands on the face".
      I tried with the constraints as i said, but then the side of the platform becomes the new "down" or floor.

    • @HawX192
      @HawX192 5 лет назад

      Ok I figured it out, to anyone wondering.
      Under the rigidbody component for the player, theres a little dropdown menu called constraints, tick the boxes for freeze rotation on x y z and now your player objects stays upright! :D

    • @DenizSimsek
      @DenizSimsek  5 лет назад

      Glad you figured it out. Have fun!

  • @unigolde
    @unigolde 4 года назад

    This is a bit wrong as it would refresh your jump even if touch the side of an object named floor it wont refresh the jump if it lands on an object which is not floor. Shouldn't we use raycasts pointing downwards

  • @44Beats-1
    @44Beats-1 Год назад

    Thank you for this masterpiece!!!!

  • @maoguai
    @maoguai 3 года назад

    why my character jump still flying when I take the code to the input event.... I already have rigidbody..

  • @realrrnc
    @realrrnc 3 года назад +1

    Guys pls anyone one answer, how can n make it the opposite direction in looking up and down

  • @aadi.124
    @aadi.124 4 года назад +1

    Thanks, bro Loved it I finally made my cube jump after 3 weeks I move my cube

    • @aadi.124
      @aadi.124 4 года назад +1

      bro why I fell down after some time I moved I am using capsule

    • @kaden7030
      @kaden7030 4 года назад +2

      @@aadi.124 on your rigidbody control freeze the x y z constraints for rotation

  • @MinhLuong1006
    @MinhLuong1006 3 года назад

    Thank you very much, the script is so simple. Subscribed.

  • @DenizSimsek
    @DenizSimsek  5 лет назад +11

    I will add a new video with touch controls for jump

  • @Baabli_proest_player
    @Baabli_proest_player Год назад

    i got error CS1003: Syntax error, ',' expected while making bool pls help

  • @blakeskit
    @blakeskit 3 года назад

    This was so helpful

  • @tanmaysinghal8370
    @tanmaysinghal8370 4 года назад +2

    Even though it is not jumping in the air But when it comes to ground then 'cubeisonground' doesn't checks to true..... due to which it doesn't jump any more.....

    • @DenizSimsek
      @DenizSimsek  4 года назад +1

      The cube needs to collide with a game object which has a tag of “Ground” when it is landed

    • @tanmaysinghal8370
      @tanmaysinghal8370 4 года назад

      @@DenizSimsek it is colliding when it falls down.....

    • @Gamer-uf1kl
      @Gamer-uf1kl 4 года назад

      OnCollisionEnter()
      {
      onGround = true;
      }

  • @JuaDix
    @JuaDix 2 года назад

    Thank you so much you rly help me a lot

  • @FickleHydra
    @FickleHydra Год назад

    wait it jumps on the side of it, how would i fix that?

  • @cashionsteven5695
    @cashionsteven5695 2 года назад

    holy, simple yet affective for me 😁
    bro keep up :))

  • @Yujoon-ls8nk
    @Yujoon-ls8nk 7 месяцев назад

    Hi I would aprecciate it if you could help I wrote
    public bool FeetIsGrounded = false;
    private void OnCollisionEnter(Collision collision)
    {
    if(collision.gameObject.tag == "Ground")
    {
    FeetIsGrounded = true;
    Debug.Log("Feet are grounded.");
    }
    }
    but it doesn't work. why?

  • @itsidza2198
    @itsidza2198 2 года назад

    I have a character controller in my code too, but with a character controller the jump code doesn't work anymore, what can i do?

  • @fabianw8661
    @fabianw8661 4 года назад +1

    This Video is amazing!
    Great Job

  • @neutralmichaelc
    @neutralmichaelc 4 года назад

    I love this tutorial so much. Thank u so much.

  • @danielberntsenomdal4853
    @danielberntsenomdal4853 3 года назад

    Thanks bro, you help me a lot

  • @Zyifo
    @Zyifo 3 года назад

    how do you fix your player jumping only once

  • @olayismitton1952
    @olayismitton1952 3 года назад

    im getting an error from "OnCollisionEnter" it is say unexpected symbol
    my code is writen the same as you though any help?? thanks

  • @foxi7463
    @foxi7463 4 года назад +3

    I'm stuck. I can only jump once. The CubeIsOnTheGround box doesn't check again. Stays unchecked.
    Edit: Nevermind, fixed it somehow, don't ask me how lol.

    • @NONSTOP-or5mu
      @NONSTOP-or5mu 4 года назад +1

      Damn, I have the same problem....

    • @beastmasterbg
      @beastmasterbg 3 года назад +2

      same problem ,how did you fix it

  • @nikita_stefanov_
    @nikita_stefanov_ 4 года назад

    Thank you man. I had a big headache because of the "flappy bird" jump controls on my player.

  • @Racoony
    @Racoony 2 года назад

    my first jump is normal but the jumps after barely goes in the air

  • @township_villa
    @township_villa 3 года назад

    Bro when done this showing that forcemod not exist

  • @mohammedabdeen9841
    @mohammedabdeen9841 2 года назад

    Thank you so much!!!! This was very useful

  • @tintlost2160
    @tintlost2160 3 года назад

    i change the name of "cubeisonground" to "playerOnGround" and did everything exacttly the same but it goes bad with my movement and just docent stop jumping, any idea what i might of done wrong?

  • @Rodehaas
    @Rodehaas 2 года назад

    But this only works if the bottom game object is called floor, so you have to add everything by hand for different floor objects, inefficent.

  • @Gamer-uf1kl
    @Gamer-uf1kl 4 года назад +9

    Just a tip :-
    Watch every yt tutorial at x1.5 speed

    • @DenizSimsek
      @DenizSimsek  4 года назад +1

      Nice tip 👍🏻

    • @tudorradu5848
      @tudorradu5848 4 года назад +1

      ikr, they reeeeally want it to be as long as they could, even if they stretch it annoyingly much

  • @franpc386
    @franpc386 4 года назад +1

    UnassignedReferenceException: The variable rb of Move has not been assigned.
    You probably need to assign the rb variable of the Move script in the inspector.
    UnityEngine.Rigidbody.AddForce (UnityEngine.Vector3 force, UnityEngine.ForceMode mode) (at :0)
    Move.Update () (at Assets/Move.cs:29)

  • @999basi4
    @999basi4 3 года назад

    i need help it doesn't jump almost every time its like I can jump only once

  • @wiljuniorelcrack4144
    @wiljuniorelcrack4144 4 года назад +1

    Hey, I have a problem, the thing is that I can't jump when I jumped, I mean, I can only jump once, after that I can't jump, I know it's because of the position but I don't know how to solve it, help please

    • @spyzn
      @spyzn 4 года назад

      This Should Help!
      void OnCollisionEnter(Collision collision)
      {
      if (collision.collider.tag == "Ground")
      {
      groundCheck = true;
      }
      else
      {
      groundCheck = true;
      }
      }

    • @wiljuniorelcrack4144
      @wiljuniorelcrack4144 4 года назад

      @@spyzn thanks!

    • @spyzn
      @spyzn 4 года назад +2

      @@wiljuniorelcrack4144 no problem man, happy to help

  • @TeaShrooomPog
    @TeaShrooomPog 4 года назад

    When i press space, the onGround bool turns off, but the player does not jump. Why?

  • @newtnuts567
    @newtnuts567 2 года назад

    other tuts are way too complex.. tysm

  • @risingcode3909
    @risingcode3909 3 года назад

    for some reason its not working for me its telling me that the private OnCollisionEnter for this item is invalid

  • @gozdekgozdek
    @gozdekgozdek 4 года назад

    great tutorial! I want more!!!

  • @christophershaju3737
    @christophershaju3737 5 лет назад +3

    jump = touch controls please

  • @vivekrmenon
    @vivekrmenon 4 года назад +1

    Thank you soo much for this tutorial😍

  • @jameswalker6052
    @jameswalker6052 4 года назад

    Very good tutorial.

  • @pratikshasuman4410
    @pratikshasuman4410 4 года назад

    Thanks it HElp Me a Lot

  • @bavvireal
    @bavvireal 3 года назад

    thx. great vid

  • @ASSASSIN79100
    @ASSASSIN79100 4 месяца назад

    My player keeps falling through the ground.

  • @Costliness
    @Costliness 9 месяцев назад

    Eyvallah reis çok sağolasın

  • @user-gy6cw7sx3q
    @user-gy6cw7sx3q 4 года назад

    Thank you for this tutorial !

  • @praneetpatil6512
    @praneetpatil6512 4 года назад +1

    'boooleann' the way he said it lol

  • @gautamgarg7377
    @gautamgarg7377 4 года назад

    Thank you very much.

  • @drago7086
    @drago7086 4 года назад

    THANKS THAT HELPED

  • @thenukdevendra1902
    @thenukdevendra1902 4 года назад

    Deniz sorry for basically spamming all your vids with ideas but I was wondering if you could do a tutorial on, "WaitForSeconds" and the "IEnumerator" functions.

  • @pedrofernandes8984
    @pedrofernandes8984 4 года назад

    Thank you so much!!

  • @Sooparch
    @Sooparch 4 года назад +1

    I don't wanna sound lazy but anyone got the source code

  • @radical9619
    @radical9619 3 года назад

    May I ask how can I apply the nice lighting to my own unity game?

  • @waltdisney6676
    @waltdisney6676 3 года назад

    For me it’s only able to jump once and after that it can’t jump at all

  • @v3vlog
    @v3vlog 4 года назад

    Great video 👍

  • @KorinDevsDumbStuff
    @KorinDevsDumbStuff 2 года назад

    You Can Use Also if (Input.GetButtonDown("Jump") && Mathf.Abs(rb.velocity.y) < 0.002f)

  • @kiddoswithviddos5589
    @kiddoswithviddos5589 4 года назад

    finally a good tutorial

  • @paxl6635
    @paxl6635 3 года назад

    Thank you!

  • @mauriciochapelle
    @mauriciochapelle 4 года назад

    You are awesome man, thanks for your tutorials! :D

  • @Sfh70979
    @Sfh70979 4 года назад

    how if I use Character Controller instead of Rigid Body? Can I use both of them?

    • @DenizSimsek
      @DenizSimsek  4 года назад

      You don’t need to use Rigid Body with Character Controller, because with that you control the character without physics. With Character Controller you just give a y position to your player when the Jump button pressed down. If you want to keep the Rigid Body and use Character Controller for jumping then you should disable gravity from the Rigid Body, I think.

    • @Sfh70979
      @Sfh70979 4 года назад

      @@DenizSimsek okay.. thanks..

  • @moonglowmelodies7336
    @moonglowmelodies7336 4 года назад +1

    Thank you soooooooooo muuuuuuuucchhhhhhhhhhhhhhhhhhhhhhhh!

  • @Scarlood
    @Scarlood 4 года назад +1

    9:40 Try typing "Untagged" so you he can jump without changing the tags

    • @arpitsrivstva
      @arpitsrivstva 3 года назад +1

      My error is saying "the reference script on this behaviour (GameObject) is missing." PLease help!