SLOPE MOVEMENT, SPRINTING & CROUCHING - Unity Tutorial

Поделиться
HTML-код
  • Опубликовано: 14 фев 2022
  • SLOPE MOVEMENT, SPRINTING & CROUCHING - Unity Tutorial
    In this video, I'm going to show you how to further improve my previous player movement controller by adding slope movement, sprinting and crouching. (You can also use your own player controller if you want to)
    If this tutorial has helped you in any way, I would really appreciate it if you leave a like in return. And you can also subscribe to this channel if you want to see more tutorials like this one.
    Links:
    ➤ DOWNLOAD the SCRIPT: www.mediafire.com/file/eibwbh...
    ➤ DOWNLOAD the PROJECT (in the free-code-dave channel): / discord
    ➤ DON'T CLICK: bit.ly/2VcrDZt
    ➡️ Get Access to my full MOVEMENT LAB! ➡️
    ➤ Trailer: • MOVEMENT LAB - Unity P...
    🏹 Get Access to my RANGED COMBAT LAB! 🏹
    ➤ Trailer: • RANGED COMBAT LAB - Un...
    Other interesting videos :D
    ➤ THROWING Grenades, Knives and Other Objects - Unity Tutorial): • THROWING Grenades, Kni...
    ➤ FULL 3D ENEMY AI in 6 MINUTES! || Unity Tutorial: • FULL 3D ENEMY AI in 6 ...
    Support me on Patreon:
    ➤ / davegamedevelopment
    #UnityMovement #FirstPersonMovement #UnityTutorial

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

  • @davegamedevelopment
    @davegamedevelopment  Год назад +12

    If you need help with any of the code shown, just visit the "coding-help" channel on my discord server :D
    Also you can find many more movement tutorials on my channel in the "Tutorials!" playlist - I really hope they help you on your further GameDev journey!
    And in case you're interested in getting access to my full MOVEMENT LAB, where I combined all of the movement abilities shown in the tutorials and some more, check out the trailer:
    ➡ MLab Trailer: ruclips.net/video/9_Q9UxK7VF8/видео.html
    Also, since I know lot's of you are interested in ranged combat as well - I can gladly announce that I'm about to release my RANGED COMBAT LAB as well:
    🏹 RcLab Trailer: ruclips.net/video/j2YplilHjCA/видео.html
    Thanks so much for watching, hope this tutorial has helped you!

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

      The crouching speed in the script is being rewritten by the other states,

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

      Yep

    • @blacksad23
      @blacksad23 10 месяцев назад

      For anyone who' might be wondering why the crouch speed is really slow / jittery or barely seems to be moving at all no matter what you set crouchSpeed to, It's not the states or the ground detection. You have to put a frictionless physics material on the ground object or you get the same bug as when moving against a wall with friction and the player "sticks" to it.

    • @TakaShitake-rt8bz
      @TakaShitake-rt8bz 9 месяцев назад

      @@blacksad23 he left out the "else" on the last one for the crouch - see the other comments - it needs to be if.... else if.... else if..... NOT what we got in the vid which is if... else if.... if....

    • @TakaShitake-rt8bz
      @TakaShitake-rt8bz 9 месяцев назад

      everyone taking the time to read thru the comments - also - make sure folks: you set your slopes to WhatisGround for gawd's sakes!! doh!

  • @JW.165
    @JW.165 2 года назад +102

    You know, these are the types of tutorials you like to see, straight to the point, easy to follow, but now boringly slow, and explained perfectly. Keep up the good work 👏

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

      Thanks a lot!

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

      @@davegamedevelopment Dave. The slope system make my Transform spin. I'm using cube collision. Even if I change to capsule It's still spinning.

  • @LM-cc7qz
    @LM-cc7qz 2 года назад +177

    Please pin this comment, for those having issues with going down slopes being bumpy please make sure that the series of if statements in the move player method are else if's and not multiple different if statements. Also in the state Handler method please make sure that they are all else if until the last one which is an else because otherwise your code won't work correctly. This is what caused issues in my code and it took me forever to figure it out. Please make sure that these are correct.

    • @ivania406
      @ivania406 Год назад +6

      Thank u that fixed all my movement realated issues

    • @bax9766
      @bax9766 Год назад +7

      you're a saint

    • @Skycrafter328
      @Skycrafter328 Год назад +4

      small but important difference!

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

      oh my god i didn't think that would be the problem tysm

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

      bro, you are the best

  • @yairtayb8665
    @yairtayb8665 Год назад +2

    your tutorials are superb! please do more of these, you dive deeper than many of the existing chanels and provide us with great learning opportunities

  • @FabUni-jy7xj
    @FabUni-jy7xj Год назад

    You are amazing! I love your voice because it makes everything clearer, you don't miss a word 😎Your tutorials are great! Thanks to you and some further additions, now I can manage an advanced on-ship deck movement!

  • @Hyphen3372
    @Hyphen3372 2 года назад +6

    Ay nice I have actually added sprinting myself before you made this so I was proud of myself also, what an awesome tutorial man keep it up.

  • @Chaomaster200
    @Chaomaster200 2 месяца назад

    This has seriously been a god send, thank you for making these videos, I've learned so much in a such a short amount of time and it is very easy to adapt into my own project

  • @sofiaonaga5352
    @sofiaonaga5352 Год назад +3

    Two things:
    1. THIS IS AMAZING. I'm going to get everyone I know to watch and subscribe.
    2. Thank you comment section for being the answer to my problems!

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

    I liked and saved your every single video. It's so helpful for my summer vacation game projects

  • @michaelechim2148
    @michaelechim2148 2 года назад +9

    Thank you so much! Please keep making these tutorials, they are awesome!!

  • @user-yx2ui3db6t
    @user-yx2ui3db6t Год назад

    it took me many hours to figure how to do slope movment but your method is easy ,thanks a lot

  • @user-sp5hx2se6g
    @user-sp5hx2se6g 10 месяцев назад +1

    Very great tutorial! It helped a lot!

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

    So informative, thanks a lot!

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

    Thank you so much for making stuff in soft a lot easier to understand.

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

    TNice tutorials comnt from you is legendary. Uncomplicated like your video!!!

  • @grantmilner8908
    @grantmilner8908 10 месяцев назад

    Thanks so much for leaving a link to the script! that helps so much when tutorials do that so I can read through the original when I have errors.

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

    Absolute legend. Nice one

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

    This is great, thank you!

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

    it worked! thank you so much!!

  • @jeanpiereramospatricio6954
    @jeanpiereramospatricio6954 Год назад +2

    will get it. Just don't get burnt out. Whenever you need a break, take one.

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

    when i typed in soft soft tutorial i did not expect it to be tNice tutorials good thank you so much aaaaaaa

  • @johanjaviernavarroticce4632
    @johanjaviernavarroticce4632 Год назад +2

    Damn bro top tier content, I'm sure you had to visit multiple countries to produce a masterpiece like this

  • @MIO-ym8rx
    @MIO-ym8rx Год назад

    OMG THANKS SO SO MUCH THIS HELPED!!!

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

    That was great. Thank you.

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

    After long time
    Good to see you 👍

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

    This Man is OP (Overpowered) 😁💪
    I like your Videos 👍

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

    You really good at explaining thank you

  • @amanKumar-xl4fw
    @amanKumar-xl4fw Год назад +1

    it's finally ti. i'm ready to learn.

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

    we've missed you for so long ❤

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

    You're a legend you have helpped me alot :')

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

    Omg thanks very much ! ✨

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

    works perfectly, thank you

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

    Great video, thank you ! :)

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

    Thank u for this ❤❤

  • @Blutengel6661
    @Blutengel6661 Год назад +2

    WOW IT WORKED!!!!! THANKS MAN

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

    Bet your soft is absolutely amazing! Never give up

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

    Very helpful..thanks a lot.

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

    ty cuz ive been having a hard ti getting started.

  • @tanc4635
    @tanc4635 Год назад +12

    Great video, I'm really liking these tutorials. One thing: Towards the end when you are accounting for on-slope speed control, instead of adding a new bool flag for jumping from slopes, I actually just re-used the 'canJump' flag instead to keep it simpler. Since 'canJump' is only set to false when the player presses the jump bind, and the Jump() method is called right after, you can use it in the SpeedControl() method to only control the speed on the slope when the player has not yet jumped (so when they are still only the slope). It seems to work all the time for me, but my testing wasn't very long so let me know if I missed something. Also have you thought about making videos about using the new Input System and a Character Controller, especially for a third person controller?
    Again, thanks for the help!

    • @davegamedevelopment
      @davegamedevelopment  Год назад +3

      Glad you liked the tutorial! And sure, if this works feel free to do it this way. Also I recently uploaded a video on third person movement. And thanks for the other ideas, I'll think about them!

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

    Ah I need to add crouching to my game. Nice job! I might take some ideas from your movement code

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

    have. But, your tutorial was amazing and I have made a semi-decent soft. Thanks!

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

    !thanks dude!

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

    thank u helped me a lot

  • @AgentNano
    @AgentNano 5 месяцев назад +3

    For those struggling with very weird movement on slopes and not being able to jump on them, try changing the line "grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.2f, whatIsGround);" to "grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.3f, whatIsGround);" sp change 0.2f to 0.3f. Atleast thats what fixed it for me

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

    As I said :D I'm following your tutorials now taking your code :D

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

    great tutorials man
    actual good code, no brackeys asset store nonsense, this is just what i was looking for

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

    thank you so so so much your a great person you helped

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

    Thanks yummy script love it

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

    Genius bro

  • @dalidasse9593
    @dalidasse9593 11 месяцев назад +8

    For people struggling with the slope with high character velocity, you can add more force to "80f" so you don't get launched in the air, but dont put too much or you'll be stuck on the slope which is worse

    • @thazeus1754
      @thazeus1754 11 месяцев назад +1

      what exactly did you change? I have the same problem

    • @dalidasse9593
      @dalidasse9593 11 месяцев назад +2

      @@thazeus1754 go in the script and where you can add force "Vector3.down * 80f" you can get this more high, also normally you can fix it also by verifying missing lines in your code :)

    • @TakaShitake-rt8bz
      @TakaShitake-rt8bz 9 месяцев назад +1

      change all the Force.Force's to Force.Impulse's and prepare to laugh your ass off

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

    You got my sub

  • @hawk8566
    @hawk8566 2 года назад +9

    I have followed your last 3 fps movement and the grenade throwing videos. Thankyou so much the way you explain things it is very easy to understand. Will be following the next vids in the series keep it going!! So much to learn.
    P.s. Please add movement on stairs currently if I try to climb stair the player gets stuck.

    • @davegamedevelopment
      @davegamedevelopment  2 года назад +5

      Glad you like my tutorials! :D
      And I'll probably do something about stair movement sometime soon, but it's definitely going to be one of the most complicated tutorials ^^

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

      @Hawk If you wat to move on stairs make an invisible slope overlapping them. It makes them go smoother than other ways and its easy to do.

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

      @@davegamedevelopment ummmmm this is taking awhile

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

      Watch this: ruclips.net/video/DrFk5Q_IwG0/видео.html

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

    Works well!! DANKEEE

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

    Very helpful

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

    Welcome Back

  • @sid_.k
    @sid_.k 2 года назад +1

    Bro, this tutorial helped me out so much. Can you make a weapon switching tutorial as well? I want to try and finish my project, but I can't figure out how to make your all in one gun script compatible with other weapon switching scripts on RUclips. With that said, your content is absolutely brilliant. Keep it up!!

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

      Thanks a lot! Glad I could help you :D
      I kind of did a weapon switching tutorial already, check it out if you want, but it's a bit specific - only for picking up and dropping weapons, not really storing them in an inventory :D

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

    Thanks Bruu

  • @simonperry8955
    @simonperry8955 3 месяца назад

    if you dont want to remove gravity on slopes you can add extra downforce while your y velocity is negative on slopes so that you dont fly off of them

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

    great tutorial!!! please make the sliding/wallrunning one

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

      Thanks - Sliding tutorial is going to be uploaded tomorrow :D

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

    Thank you so much for these videos! They're helping me so much!
    I was wondering why you were doing Raycasting to detect the ground below the player instead of collision detection? Is it because Raycasting is more computationally efficient, or is it because it's easier to code Raycasting than writing a loop through the collision object array?

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

    Brackeys Leaves, and Dave Arrives, Boys We Got A New One

  • @Supportik
    @Supportik 6 месяцев назад +14

    I am not sure why this is not mentioned but the walk speed overrides the crouchspeed since you are still grounded.
    The statehandler still says walking even though you are crouching.
    Found the issue: My sprint mode had just Else and not Else if.
    // Mode - Sprinting
    else if(grounded && Input.GetKey(sprintKey))
    {
    state = MovementState.sprinting;
    moveSpeed = sprintSpeed;
    }

    • @bigboi1847
      @bigboi1847 4 месяца назад +1

      saved me a bunch of time. Thanks a lot

    • @jacobjoseph11
      @jacobjoseph11 Месяц назад +1

      Thanks

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

    Lol, was just on your channel and then a new video popped up.

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

    if anyone is having issues with the raycast detecting ground that isn't there (ie you're high in the air and still able to jump), go to your mesh collider component, cooking options, and deselect "use fast midphase"
    was tearing my hair out for days trying to figure out why my very short raycast was still detecting ground despite my character being high in the air, tried this and it immediately fixed that issue.
    edit: you might need to reimport it as well

    • @MatejSunavec
      @MatejSunavec 8 месяцев назад

      This does not work. I am still above 1.0 in the air when able to jump. Unless I check convex, I get message: Non-convex Mesh-Collider with non-kinematic Rigidbody is not longer supported since Unity 5. And with convex checked, I can not move up the slope. I also can not crouch through a tunnel.

  • @fuzziau5669
    @fuzziau5669 Год назад +32

    alternatively, you could use animations for crouching.
    you can simply create an animation within the Unity dope sheet animator, move the players collider and model down, resize things if needed to prevent clipping, or pose them as well if they are a rigged model.
    this should resolve any temporary floating in mid air, though you could simple make an if-statement and alternative animation for when the player model is not grounded so that they don't suddenly drop downward.
    there's always much more easier alternatives, provided you learn about their attributes

    • @notanagger4861
      @notanagger4861 10 месяцев назад +3

      The animation way is the way to go I would say for beginners... the way he does it in this video is just so janky

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

    Hey nice video man looking for the grappling gun part also!!

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

    finished 2 in one sittig already lol got the sub

  • @user-dk5xj7uu4m
    @user-dk5xj7uu4m Год назад +1

    If you input left shift and MoveSpeed is still equal to WalkSpeed,Put the sprint mode under the walking mode in the StateHandler function

    • @TakaShitake-rt8bz
      @TakaShitake-rt8bz 9 месяцев назад +2

      sometimes, you can help your script by giving it a little nudge - to make sure everything starts in right place.
      For instance, to help you might in your void start:
      state = MovementState.walk;
      to help give it a frame of reference
      also, the coding demonstrated in the tutorial for the StateHandler() function is not the best
      truthfully, you need every other one after the first as "else if" for it work best
      so in your state handler
      if...
      else if...
      else if...
      else if...
      for some reason, Dave gets really sloppy in the second half of the tutorial overall, after being so thorough and diligent with good coding in the first parts

  • @just_gaminlive3402
    @just_gaminlive3402 Год назад +30

    0:28 sprinting
    2:07 crouching
    3:46 handling slopes

  • @kdawg717
    @kdawg717 3 месяца назад

    We like this.

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

    really Nice

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

    I was expecting a flood of among us comments from the thumbnail, glad there wasn't any lol, anyway thanks for this video :)

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

      Haha you know, the game dev community just accepted the default Unity capsule as a player model for first-person games xD

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

    wow, nice

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

    Brackey's back

  • @MaxIzrin
    @MaxIzrin Год назад +9

    There will be no need to add downward force on crouch if your player's pivot is at his feet.
    This also negates the need to know the player's height before raycasting to check for ground.
    And additionally helps placing units/characters in the scene without needed to adjust their Y position so they don't clip through the ground.

    • @TakaShitake-rt8bz
      @TakaShitake-rt8bz 9 месяцев назад +1

      but it can be a real b*ch with all the Rigidbody.Addforce stuff etc gravity goin' on - like center of gravity really helps in Physics in Unity. Could you imagine if you r center of gravity was instead placed at your feet? What a DRAG man

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

      @@TakaShitake-rt8bz You can actually set that manually.
      And if your rotation is locked anyway, which it is for most character controllers, then the center of gravity doesn't matter at all.

    • @TakaShitake-rt8bz
      @TakaShitake-rt8bz 9 месяцев назад +1

      @@MaxIzrin force on crouch is the best way to guarantee you are the "floor" of any low ceiling shaft, duct, tunnel, cave - that's in essence most important especially if you crouch forward and come into a cave that is 3/4 of your height - you stand up - you will clip the ceiling - you need to make sure at all times when in a crouch environment you are at the lowest point of it - to guarantee a raycast up to check ceiling only hits something your full height or lower - anything above is false and you can stand up - and not clip.

    • @ramelo07
      @ramelo07 7 месяцев назад

      @@TakaShitake-rt8bz the issue with adding force down is that u cant do something like crouch jump. if u hold crouch while in air the player gets pushed down constantly

    • @nightninja1219
      @nightninja1219 2 месяца назад

      my crouchijng doesnt work, only my croush speed works but not my yscale, i havent done the ray casting so im not sure if taht is the problem. help quick!!!!!!

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

    Quick and gud :D

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

    Awesomeee video, clear steps and straight to results. I have just a little problem, I'm making a fps shooter game so i have a gun attached to my camera so when i crouch everything also shrinks. is there a fix to to that ?

  • @thxr9766
    @thxr9766 2 года назад +8

    hey! i'm loving the series so far but i have a quick question, when i crouch the transition between standing and crouching is instant which looks like i teleported the camera downwards whereas in your project and videos the camera moves between the standing and crouching positions i don't know how to explain it better but what i mean is in my project the crouching is instant and in yours it's smooth so how do i make it like yours?

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

    Awesome program

  • @owen261
    @owen261 5 дней назад

    Mess with the Jump fource, cooldown, and air multiplier if you are having issues with choppy jumping.
    For me Force of 13, cool down of 0.7, and multiplier of 1 work well (this is with gravity set at -30 in project settings)

  • @loupa6128
    @loupa6128 6 месяцев назад

    Nice video. Do you have a tutorial for walking stairs?

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

    most people got sotNice tutorialng from tNice tutorials video. Much love!

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

    Really Great Video. Well explained and easy to implement in own scripts. Could you make a tutorial for a dash move?

  • @mishaaskar
    @mishaaskar 6 месяцев назад

    shit.. i clicked and now im subbed xD

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

    tNice tutorialngs

  • @mas-o
    @mas-o 9 месяцев назад +2

    These tutorials are great, did have an issue with my crouchSpeed not being used whenever i crouched, after i saw that, i noticed that my movement state wasn't being saved. Just had to set the next if statement to else if in the StateHandler!

    • @TakaShitake-rt8bz
      @TakaShitake-rt8bz 9 месяцев назад

      YES - and read my other comments in here for more helpful hints - there were a few oversights in the tutorial as presented cheers

    • @chillnook
      @chillnook 8 месяцев назад

      Only comment that solved my issue, appreciate it!

    • @zackdasilva3195
      @zackdasilva3195 2 месяца назад

      Thanks I wasnt able to figure it out

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

    Could you make one for stairs? Mine seems te get stuck on them. Thank you

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

    Thank you man! I just started Learning Unity and i wanted to make an FPS game parkour kinda think but like in 2018 or 2019 i tried but failed thanks for this video now im working on the game THANKS -subbed-

  • @timothybaldinger261
    @timothybaldinger261 Год назад +2

    This tutorial has made me realize my typing skills are lacking lol.

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

      Well the typing is sped up to fit the audio, but yes, typing fast is equal to increaing your productivity in coding :D

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

    I recommend where it has the bool for the slope and has != 0 to put like 5 or smthn cause your flat ground wont always be completely flat and you dont want slope physics on flat ground so yea

    • @TakaShitake-rt8bz
      @TakaShitake-rt8bz 9 месяцев назад

      or, oh shit - ya can maybe remember to make sure your slope is whatisGround

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

    love the tutorial! but what is the asset file you use for slope and crouch tests?!? im wanting to use it for basic testing

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

    good tutorial, one question about soft recording. How do you do it? lol

  • @rado1244
    @rado1244 2 года назад +10

    Hello Mr.Dave,
    I noticed that jump height is slightly inconsistent. First/single jump is normal however if you hold down space and jump multiple times all jumps after the first one are slightly higher. I tested this even on your project in the description and i was having the same issue. I know its barely noticable but when changing the jump force or gravity the difference can be felt quite a bit. I was wondering if there is maybe some way to fix this ? The easiest solution would probably be just to make the player jump once but i like the feature of autojumping. Hope you see this and thank you for all the amazing tutorials :D.

    • @davegamedevelopment
      @davegamedevelopment  2 года назад +13

      Yes, I noticed that as well. I am going to fix it sometime soon, but so far didn't spend more time on it.
      Try setting the rididbody y velocity directly,
      so change the line "rb.velocity = new Vector3(rb.velocity.x, 0f, rb.velocity.z);"
      to "rb.velocity = new Vector3(rb.velocity.x, someJumpForce, rb.velocity.z);"
      and delete the AddForce line afterwards.
      Didn't try this out, but it might work :D

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

      @@davegamedevelopment I've tried it out and it works just fine. Thanks for this ;)

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

      @@sanducosmin7427 No problem, glad it works!

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

      I tried this and i can no longer jump 😭

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

      @@deadlocked85 Still need help ?

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

    hi, thanks for the video, that helps a lot, i have an issue when i goes down a slope, my player bouncing down. i followed the video until the end, and i dont know how to fix it, his bouncing is the same size of the line grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.2f, whatIsGround); if i turn this 0.2f to a higher value, his bouncing comes higher too

  • @a.gosman7155
    @a.gosman7155 Год назад +1

    Hi I am having two weird issues, one is that when I am crouched my grounded variable becomes false and secondly when I uncrouch it does a weird and slow growth back to normal height

  • @BlobifyYT
    @BlobifyYT 3 месяца назад

    i have a question, while the player is in air what is the move speed set to? cuz in the script its seems that its not assigned to nothing in air but it still works , is it because the player is always on the ground before jumping so its just set the speed before jumping?

  • @VSwede
    @VSwede 2 года назад +6

    Hey, you make such incredible tutorials. Bravo. I will say though that I do have one pretty odd issue with crouching and slopes. When I crouch on a slope and try to move up on it, my character moves right into the slope and not in unison with the slope, and the character can't move towards the slope. Moving down the slope crouched works fine though. I'm not entirely sure how else to solve this apart from disabling crouching while on a slope. Any help with this at all would be great!

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

      I had a similar issue. But it was when you held down space while crouching it would jump earlier than the rigid body hit the ground. Just make a float and whenever you crouch set it to 0.2f and then 0.5f when you dont crouch set the raycast multiplier to whatever you named your float. I named mine "jumpCrouch": grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * jumpCrouch + 0.2f, whatIsGround); ... if(Physics.Raycast(transform.position, Vector3.down, out slopeHit, playerHeight * jumpCrouch + 0.3f)) This should work. sorry for the late reply, hope you figure out your issue

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

    thanks! Works super well.
    sadly, for my FPS, the movement needs to be fairly fluid. Two issues.
    1. the player movement script already sucks
    2. the player can still fly off slopes and won't always "attach" to them going downwards, especially when playing a faster class.
    i'm experimenting with adding extra downwards force when entering and leaving slopes, changing the slope detection raycast distance, adding a new ground detection raycast (it's hard to explain why i'm doing that one), etc. hopefully i can figure something out

    • @microman502
      @microman502 Год назад +2

      my player movement script sucks, not yours btw

  • @Diamond-yn4nu
    @Diamond-yn4nu Год назад

    Hello, I have the pumping movement problem when walking on the slope, but when I move down not up, unfortunately, the solution that you put in the script did not solve the problem. Any suggestions? Thanks

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

    I have the problem of joting when walking down slope as well, I can add one which make so that there is downward force when walking down as well, but that will push you down on slope as well…

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

      maybe try something like this
      if(OnSlope() && (rb.velocity.x > 0 || rb.velocity.z > 0)
      {
      //apply downwards force
      }