FIRST PERSON MOVEMENT in 10 MINUTES - Unity Tutorial

Поділитися
Вставка
  • Опубліковано 6 лют 2022
  • FIRST PERSON MOVEMENT in 10 MINUTES - Unity Tutorial
    In this video I'm going to show you how to code full first person rigidbody movement. You can use this character controller as final movement for your game or build things like dashing, wallrunning or sliding on top of it.
    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/1b7mf5...
    ➤ 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

КОМЕНТАРІ • 2,7 тис.

  • @pikapikalis
    @pikapikalis 2 роки тому +1353

    This tutorial was great but one small problem. I couldn't get the capsule to jump until I compared my script side by side with your script and noticed that in the video you do not say to add the following line to Start()
    readyToJump = true;
    You might consider updating your description so people know. I spent awhile trying to figure it out comparing everything I did from the video before I gave up and looked at your script.
    edit: this was a year ago, still getting thanks to this day. never expected to get this much support, thank you all for the 1k likes. means alot. good luck on your movement systems everyone!

    • @mentallyunprepared8635
      @mentallyunprepared8635 Рік тому +26

      yeah I noticed it too and was so confused, why it didn't jump, thanks for the heads up

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

      You helped me alot thank you.😘

    • @whitehook5450
      @whitehook5450 Рік тому +19

      Hey, I added this, but I still cannot get the capsule to Jump, even tried with the movement script in the description, still doesn't work, do you have any solutions? Everything else works just fine.

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

      Had the same issue. But great tutorial!

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

      @@whitehook5450 do you have your ground layer set to, "whatIsGround"?

  • @Hietakissa
    @Hietakissa 2 роки тому +380

    for anyone struggling with the player sticking to walls; Make a Physic Material with little to no dynamic friction (I used a value of 0.1 with Friction Combine at Minimum) and assign it to the player's Collider. You can experiment with different friction values to find what works best for your game

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

      for me I needed to apply it to the slopes as well

    • @Hietakissa
      @Hietakissa 2 роки тому +2

      @@mlgjman1837 how do you mean? If you set the Friction Combine to minimum it will use the smaller value of the 2 colliding objects, so it should be enough to just apply it to the player directly.
      Unless you are talking about some other problem.

    • @Carl-Randomness
      @Carl-Randomness 2 роки тому +11

      Am i too dumb to understand this

    • @Hietakissa
      @Hietakissa 2 роки тому +2

      @@Carl-Randomness the player is sticking to the walls because of friction, the friction is too high for the player to keep their momentum so they get stuck.
      By making the player have less friction they can slide across the wall

    • @Carl-Randomness
      @Carl-Randomness 2 роки тому +3

      @@Hietakissa Oh thanks

  • @jehriko7525
    @jehriko7525 Рік тому +32

    Thanks a bunch! For someone like me who's absolutely new to programming in unity I'm appreciative that this is low-level enough for me to able to understand why each piece of code is being inputted.

    • @Kwakky69
      @Kwakky69 10 місяців тому +2

      i dont even know how to make a script for the cam

    • @Sushanththeartist
      @Sushanththeartist 2 місяці тому +1

      @@Kwakky69 i dont even know where to put the script

  • @Alejandro_Berra
    @Alejandro_Berra Рік тому +7

    I was doing my own FPS controller without any guidance and everything was alright but some weird camera jitter so I decided to check how everyone was tackling the camera. I never thought of having it outside the hierarchy of the player. Now I have 0 problems amazing idea!

  • @Seestral
    @Seestral 2 роки тому +23

    Just found your channel. Thanks for all the tutorials you're doing and keep it up!

  • @liamwhillier3334
    @liamwhillier3334 2 роки тому +30

    This was an Amazing guide, and it helped a lot with my first game!

  • @jacksmith7139
    @jacksmith7139 Рік тому +17

    Thanks a lot Dave, appreciate the fact you're providing this content, and consolidating it to only 10 minutes so we can crunch through it. Its a good way to work.
    All the best!

  • @Inferim
    @Inferim 5 місяців тому +4

    Your methods are so simple! I've ran into multiple problems with syncing the camera with an object that has a character controller before. Similarly, I had to do mental gymnastics just to figure out how to move the player based on the camera's perspective. Having an object whose only function is to keep track of orientation saves a lot of mental work and is definitely a game changer. I need to think like that more! Glad to have found this tutorial. Great stuff man!

    • @dnrspdr03canadian95
      @dnrspdr03canadian95 Місяць тому

      i gotta ask, i for some reason have copied the exact code and my character doesn't move, im rather new to this and just started learning today, is there something im missing thats just common sense?

  • @thxr9766
    @thxr9766 2 роки тому +123

    if you have a problem with the ground check then just add an empty game object at the bottom of the player then write this:
    grounded = Physics.CheckSphere(groundCheck.position, groundDistance, whatIsGround);
    with these as variables:
    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask whatIsGround;
    bool grounded;
    i got this from brackey's fps tutorial btw and it seems to work nicely with this script.

    • @davegamedevelopment
      @davegamedevelopment  2 роки тому +19

      Yeah that works just fine, thanks for helping others out!

    • @thxr9766
      @thxr9766 2 роки тому +10

      @@davegamedevelopment np dude! i love helping people out!

    • @user-hk8fs9yo2k
      @user-hk8fs9yo2k 2 роки тому +3

      i love you, man :D

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

      @cuitotech no you don't have to you can just put it in the playermovement script in the same place where he put his ground check

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

      Thanks dude , very cool.

  • @cboyslim5490
    @cboyslim5490 2 роки тому +6

    this is the first time i've ever finished a unity tutorial lol hell yeah motivated af now

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

    I looked at over 10 videos, but this... this is just the best. Keep up the great work!

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

    this is the best movement tutorial ive been able to find since Brackeys, thank you :)

  • @ExamProChannel
    @ExamProChannel Рік тому +167

    I followed this to the letter, and I had jumping like I was on the moon. I did solve it myself by downloading the original source files and I found that the global value for the Gravity's Y value is set to -30. For a default project it set to -9, so this is an omission in the video. You can find this setting under Edit -> Project Settings and just make sure its set to -30 and you'll be back on earth lol.

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

      i changed it to 30 and the jump height didnt change

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

      @@nemorururur change it to -30

    • @olly-o3810
      @olly-o3810 Рік тому

      I got the opposite i jump .1mm off the ground

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

      @@olly-o3810 I depends on the scale of ur object too. If ur player is really big you'll have to scale up ur jumpForce

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

      you fucking legend. was having this same problem

  • @_ace55
    @_ace55 2 роки тому +231

    For anyone that has stuttering / jittering issues with their camera: There are 2 options how you can fix it
    • Remove the "* Time.deltaTime" from the PlayerCam Class where getting the input
    • Replace the "* Time.deltaTime" in the PlayerCam class with "* Time.fixedDeltaTime"

    • @consultingprestig2096
      @consultingprestig2096 2 роки тому +4

      I would like to know why it is not the same? The math is the same though, right?

    • @_ace55
      @_ace55 2 роки тому +2

      @@consultingprestig2096 I dont know the exact difference but I think the Input handler by unity already does the frame indenpendence stuff for you, so you dont need the time.deltaTime

    • @consultingprestig2096
      @consultingprestig2096 2 роки тому +19

      @@_ace55 Ok thank you. I also have another question; Every time I work on a project and I come back to it later there are always mistakes... I wonder if it's on their part to demotivate us from creating games... And let rockstar and all those known to keep the place of number 1? .. I say that because I don't understand how is it, with all the assets already done, that there are no games similar to GTA or Call of duty... Because these games are too loaded with server...

    • @_ace55
      @_ace55 2 роки тому +24

      @@consultingprestig2096 I can't tell if youre joking

    • @davegamedevelopment
      @davegamedevelopment  2 роки тому +68

      @Consulting Prestig That's the first Unity conspiracy theory I've heard so far xD

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

    Good enough guide. Got me 90% of the way there. Nice product. smooth realistic movement.

  • @Yukiikakkoi
    @Yukiikakkoi Рік тому +4

    This is very good I just started coding in unity and I understand the code very well with this!

  • @noodletree
    @noodletree 2 роки тому +3

    great videos, I'm using this tutorial to check I didn't create my player controller in an unscalable way and its helped a lot. Thanks for the video chief.

  • @ThePianoPlayerOfficial
    @ThePianoPlayerOfficial 2 роки тому +4

    After some time, i finally found a useful tutorial on detailed fps controller, thank you so much for this tutorial

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

    Thank you DAVE, this video helped me really much.

  • @GaryParkin
    @GaryParkin 10 місяців тому +2

    Thank you so much for the tutorial. Even after a year it's helping folks like me. And what's best is you already made the next video and I can go watch it.

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

      Did you make it so the camera works? I swear I did everything in this video, and everything works but the camera doesn't.

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

      @@xuanki1Yes, the thing to remember is the mouse movement is connected to the camera, not the body. I've watched one where the guy had the camera stationary and the player needed to bend down to see. that's bogus and can't work in a real game.

  • @unleasheddevil1698
    @unleasheddevil1698 2 роки тому +4

    oh your finally back after 1 year
    pls continue making content your doing good
    Thanks.

  • @jcd9456
    @jcd9456 2 роки тому +10

    Thank you very much for the code! I got to test each part on my own after watching your full vid. When following other youtubers as they code (Cuz code not provided) I always ended up messing the copy so I can't test it properly. Thank you once again!

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

    love you, thanks for doing such amazing tutorials man

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

    Fantastic video. Thank you Michael, You have inspired to get into soft editing and videos soft design too.

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

    I appreciate how there’s no ads, thanks.

  • @christophermohite537
    @christophermohite537 10 місяців тому +62

    For anyone having trouble with the Jump function : we just have to set readyToJump to true when we begin (its not shown in the video)

    • @creativeumar10
      @creativeumar10 10 місяців тому

    • @Snek5981
      @Snek5981 9 місяців тому +1

      thank you I was so confused on why my jumping wasn't working!

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

      Thank you!
      I wish I saw this comment before spending half an hour figuring that out!
      People really gotta like and comment on this comment so it gets higher in his comment section so others can find it faster!

    • @user-kg1ok9tw9f
      @user-kg1ok9tw9f 3 місяці тому

      thank you so much, this comment help me so much

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

      Thanks for the help, I could not figure it out lol

  • @yasser_gg2276
    @yasser_gg2276 6 місяців тому +1

    its amaaazing bro its just a very clear and easy tutorial THANKS KEEP GOING 😄💖

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

    BROOO thankyou so much, this really helped and the tutorial was really easy to use as well :)

  • @szialoo9674
    @szialoo9674 2 роки тому +271

    You sound alot like brackeys

  • @libbycb
    @libbycb 7 місяців тому +12

    thanks for the tutorial!!
    if yall can't jump you can put "readyToJump = true;" in Start() or just when you create the variable initialise it to true ("bool readyToJump = true;").
    if ur jumps are huge and fall slowly, i found that increasing the rigidbody's mass in Unity helped, I liked 1.6 but tweak it for yourself. also tweak the jumpForce, i'm at 10.

    • @igoraugun1471
      @igoraugun1471 3 місяці тому +3

      Man, you just fixed my problem which I've been struggling with for 2 hours, tysm

    • @yuko_xzx
      @yuko_xzx Місяць тому

      i have the same problem but i dont get what your saying can you give me help there was 2 ready to jump = the first one was false and the second was true i changed the first one to true nothing happened i tried copy pasting ("bool readyToJump = true;") under but there was an error so i deleted it

    • @aritrabose8h852
      @aritrabose8h852 Місяць тому

      @@yuko_xzx go to your Start() function. See where you can find the any code with the following words "void Start". Then inside the curly braces, write " readyToJump = true; " hopefully that helps.

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

    Thank you very much, your explanations made me understand some basic concepts!

  • @sergiomarcelinovilchezmend5174

    Thank you for your complete and comprehensive training. Very good!

  • @bradleygallavin7378
    @bradleygallavin7378 2 роки тому +4

    Thanks for this, just what I was looking for!

  • @thunderx3005
    @thunderx3005 2 роки тому +6

    Thank You bro I needed this 💪🏾

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

    man you probably wont see this but you have no idea how helpful these videos are. thank you so much!

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

      are you a developer if you are i can give you any unity project or asset that is on my chanel for a very cheap price that we end up with after bargaining there is no one on youtube doing this and it would be with proofs and have a refund policy to if you have a better excuse

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

    Thank you, I watched many videos and none worked because it bugs, but your script worked
    +1 sub

  • @polix9999.2
    @polix9999.2 2 роки тому +4

    i Cant wait for the next tutorial broo !!❤️

  • @rpc6882
    @rpc6882 2 роки тому +10

    Thank you so much for breaking all this down. Please keep up the good work.

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

    Thank you so much for your awesome tutorial.

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

    THANK YOU SO MUCH THIS WAS EXTREMELY HELPFUL :D

  • @Pixelatic0733
    @Pixelatic0733 2 роки тому +3

    you are on fire bro
    nice tutorials and you got a subscriber right away

  • @imfaded3105
    @imfaded3105 2 роки тому +5

    Great tutorial 🙌🏻🔥

  • @FergiesHuman
    @FergiesHuman Місяць тому

    I don't often thumbs-up videos but this one deserved a big one

  • @siddharthshah2274
    @siddharthshah2274 6 місяців тому +1

    Good video, amazing help. Thank you.

  • @soksopanha7348
    @soksopanha7348 2 роки тому +3

    The speed control help alot man, thank so much.

    • @davegamedevelopment
      @davegamedevelopment  2 роки тому +2

      No problem, glad I could help!

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

      @@davegamedevelopmentI need help the speed check has and error and says vector 3 can not be float

  • @razamondo
    @razamondo Рік тому +34

    If you are still having trouble with "penguin sliding" after adding drag double check the position of your capsule in your player holder, if like me you moved the capsule at some point to align things it moves the starting point of the raycast with it, so make sure your capsule has 0,0,0 for position.
    For me my capsule was 0,2,0 and as such my raycast was starting lower then my player. I found this out by starting the game, then hitting esc to free my mouse then change to scene view, I then selected my player holder and unchecked "use gravity" to allow me to drag my player holder up while looking at 'Drag' in the Rigidbody and after my player was hovering ~1 unit in the air my Drag jumped from 0 to 5 which is what my GroundDrag was set to at the time

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

      THANK you!

    • @lmbozz1286
      @lmbozz1286 3 місяці тому +1

      Thank you, this was beginning to annoy me lol

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

      Thank you. That was the problem for me.

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

    Hey Dave. Great little tutorial. Unfortunately I could not adapt it to fit my current script but do keep making tutorials :). PS Happy Belated New Year

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

    This is awesome man, thank you

  • @thefunnybuddy4138
    @thefunnybuddy4138 2 роки тому +16

    I played dying Light 2. I don't like how the controller feels. So now I'm trying to understand how movement, vaulting, etc. works. Then make an obstacle course, code in the movement and tune it until it feels fun.

  • @Jezy258
    @Jezy258 2 роки тому +95

    Couple of things, first off. thank you for making this video, it helped a lot!
    Second, I couldnt jump.
    Tried to check if i was grounded and played with the variables for awhile, but I had some issues finding out if i was grounded and the consol log was really confusing so i used this code in the Update() section :
    Debug.Log(grounded);
    if (Input.GetKey(jumpKey))
    Debug.Log(jumpKey);
    it helped me confirm real time if i was grounded or not so i could alter the varibles until i was actually grounded, and if the game was registering me pressing space bar.
    However i was unable to jump because I initially did not have "readyToJump" set to true.
    I fixed this adding this code to Start() section
    ResetJump();

    • @ahmet_islam8808
      @ahmet_islam8808 2 роки тому +8

      tysm u rly helped me out!

    • @davegamedevelopment
      @davegamedevelopment  2 роки тому +10

      Appreciate the help for others!

    • @whitefox9077
      @whitefox9077 2 роки тому +4

      I followed what you said, and I'm still having trouble jumping, idk else to do, also first time coding

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

      You can also just set the variable to true when declaring it.

    • @biscuitsandgravy1608
      @biscuitsandgravy1608 2 роки тому +2

      Just helped me out, thank you!

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

    Hi Dave... thanks for an amazing tutorial

  • @TomA-ei6tq
    @TomA-ei6tq 3 місяці тому

    Amazing Tutorial! Thanks!

  • @byte-sized-tech
    @byte-sized-tech 2 роки тому +24

    This man is the new brackeys no cap. Seriously though, amazing tutorials.

    • @davegamedevelopment
      @davegamedevelopment  2 роки тому +4

      Thanks a lot, that's about the highest compliment you could give me :D

    • @Mr_BlueBanana
      @Mr_BlueBanana 2 роки тому +2

      @@davegamedevelopment you even sound like brackeys. I sense potential

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

      That said, I can imagine a DGD branding for merch!

  • @willb7484
    @willb7484 2 роки тому +22

    Tip: If you player is sticking to walls, create a Physics Material and set all friction to 0 and then apply that to your walls

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

      Where is Physics Material? I can't find it :( I found only Physics Material 2D

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

      @Juka not sure why this didn't cross my mind too. Good suggestion

    • @Diamond-yn4nu
      @Diamond-yn4nu 2 роки тому

      I will try it thanks

    • @Diamond-yn4nu
      @Diamond-yn4nu 2 роки тому

      I added it to the blayer capsule colider

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

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

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

    I needed this I switched from ue5 to unity cuz it seems more practical in some ways but I still didn't master the coding still learning so yeah thanks man

  • @asstra_s
    @asstra_s 2 роки тому +6

    This is perfect. I hope you upload everything you showed at the beginning.

  • @snipermonkey427
    @snipermonkey427 2 роки тому +69

    This man puts out high-quality, easy to follow, informative videos. Absolutely love it. Can’t believe you don’t have 1 mil+ subs

    • @davegamedevelopment
      @davegamedevelopment  2 роки тому +10

      Thank you so much! :D

    • @u_r_fool
      @u_r_fool 2 роки тому +4

      Ya

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

      @@davegamedevelopment The First Person part works but for some reason my camera changes positions on game start. The camera changes to being under my terrain plz help.

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

      @@davegamedevelopment brillant!

    • @Gunami.
      @Gunami. Рік тому

      @@JaydacapTV download the script

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

    Love your tuts 😁😍🤩

  • @TakaShitake-rt8bz
    @TakaShitake-rt8bz 10 місяців тому

    but honestly I do want to eventually make a hockey/ice-skating game so the part up to 4:54 is pure gold. Now at least I got a nice head-start on that. Amazing tutorials. Subscribed. Can't wait for more

  • @kenan-nynor
    @kenan-nynor 11 місяців тому +14

    Here is (maybe) why you cant get your jump working how you want it to be:
    Go to edit -> Project Setting -> Physics and set the Gravity Y value to -30
    I had it set to -9.81 on default but Dave is using -30 in his video (if you want to have the movement just like in the video)

  • @Mus1im__Goat
    @Mus1im__Goat 2 роки тому +3

    thanks you so much this was sooo helpful but I had a problem with jumping

    • @davegamedevelopment
      @davegamedevelopment  2 роки тому +3

      Glad I could help! Did you manage to fix the problem? If not, you can download the project file over my discord server and copy the exact setup, then everything should work :D

    • @Mus1im__Goat
      @Mus1im__Goat 2 роки тому +2

      @@davegamedevelopment oh thx, every thing is now fine :D

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

    many thanks DAVE

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

    bro you are so amazing!

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

    If your player is sticking to walls add a physics material to the player mesh collider and set the physics materials settings to 0,0,0 minimum, and minimum. Hope this helps!

  • @gabxvyan
    @gabxvyan 2 роки тому +4

    "A transform for the player's orientation"
    I died at that moment

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

      Haha I guess you need to watch some basic tutorials on Unity Variables First :D

  • @mediamermaid333
    @mediamermaid333 8 місяців тому +1

    Thank you!!

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

    🔥 Thank you!!

  • @atomictortoise
    @atomictortoise 11 місяців тому +17

    for anyone struggling with the camera being outside of the player, make sure that the camera holder and the player cam objects are at the same coordinate
    anyone struggling with the player not jumping, add readyToJump = true; to Start() and make sure the player starts while touching the ground

  • @wolfsmith9342
    @wolfsmith9342 2 роки тому +6

    Thank you very much . This is a REALLY smooth controller I really hope ep2 will come soon . bty do you know how to make air strafing and ramp slid like Demoknight Trimping in TF2 and CSGO.

    • @davegamedevelopment
      @davegamedevelopment  2 роки тому +4

      Thanks, glad you like it!
      I know the mechanics you're talking about but never really tried coding them. Try googling for "Csgo Air straving Code", but you need to be quite good at vector maths for this :D

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

    Just wanna thank you i am in a group projekt and the guy that was supposed to make the code didn't do any work so I had to do it in two days with no codig experience so just wanna thank you for saving my projekt

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

    Loved it!

  • @JATEK0S
    @JATEK0S 2 роки тому +265

    intro 0:00
    camera 0:27
    movement 3:22
    drag & speed control 5:16
    jumping & air control 7:27

  • @pridful6103
    @pridful6103 2 роки тому +11

    Thank you so much the movement is very smooth.
    For the jump i had an issue where it didnt work although the script had no error
    I fixed that with putting resetJump() in Start()
    After that i realised i could keep jumping higher and higher if i held Space
    It has to do with this code : grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.2f, whatIsGround);
    Change the "playerHeight * xf" depending on your playerHeight both the variable and the playerObject
    Hope this helps :)

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

      Thank you so much for saving my time :D

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

      i dont understand. What do i change?

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

      @@SpiritualSteve you should make the changes in the player movement script

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

      @pridful it says that "xf" does not exist in current context how do i fix it?

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

      @@ache7795 copy your original code andmake this, if code get error, paste it old code

  • @VikMen-ug5hv
    @VikMen-ug5hv Місяць тому

    Great tutorial it helped me so much

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

    Thanks for the help.

  • @mayankkoli2300
    @mayankkoli2300 2 роки тому +6

    if anyone is having a problem that their player jumps too high and falls too slowly go to Project Settings -> Physics and sety the y value to something even lower i found -30 worked darn good for me

    • @scrooloose4473
      @scrooloose4473 2 роки тому +3

      Thanks! I had fun flying all over the place tho :)

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

      For me, -20 worked much better

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

      Instead of changing the gravity of the entire game just add the fall multiplier to the specific rigidbody you want to change

  • @donajello
    @donajello 2 роки тому +100

    Anyone having trouble with the "penguin sliding" even after adding the drag and all, try moving your environment/whatever has whatIsGround layer down on the Y by -0.7. If your Player empty starts are 0,0,0 the Groundcheck does something weird and doesn't recognize that you're on the ground (at least on my end)

    • @arcadetitan
      @arcadetitan 2 роки тому +5

      This did not work for me, what can I do?

    • @adriandeveraaa
      @adriandeveraaa 2 роки тому +3

      you need to extend your raycast length check. if your ground is -0.7 below your character then it wont pass. playerHeight * 0.5f means it is checking a ray length of 0.7 which may not include the -0.7 you are at. Try increasing it by changin it playerHeight * 0.5f + 0.3f for a total of 0.8f length to intersect the floor

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

      @HyDay it wasn’t an issue with the script, it was an issue with the objects in the scene? downloading the script from the description did not and would not have solved this problem.

    • @donajello
      @donajello 2 роки тому +2

      @HyDay no worries pal- yes you’re correct in saying that downloading the project straight from the creator WOULD solve this problem, but i personally wouldn’t find it all too gratifying. i’m still really early in learning Unity but i find trial and error is a better learning method than copy and paste haha

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

      @@damurlive Thanks D'mur. I just have now a new problem since I can double Jump, and even jump just before I touch the ground

  • @FURKAN-tj7hd
    @FURKAN-tj7hd Рік тому

    works PERFECTLY!

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

    this will help a lot with my Indie game

  • @marcamooo
    @marcamooo 2 роки тому +3

    Best videos ever

  • @noirlavender6409
    @noirlavender6409 2 роки тому +3

    The moment i change from a capsule to a player model i couldnt jump anymore, adding ResetJump(); on start helped with making the capsue jump but not other models, even if i added the collider to the model (capuse collider) the 'fix' was to add the capsule collider directly to the Player, not the PlayerObj, for some reason that worked

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

    Very helpful thank you

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

    THIS IS SOOO GOOD!!!

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

    I followed the steps up until air control and jumping and when i press play i cannot move my character. I downloaded the movement script from the Desc. and i have applied and completed the player camera and camera movement scripts.

  • @Toon444
    @Toon444 2 місяці тому +3

    If anyone is having trouble with having really floaty jumps where you fall really slowly, here's how to fix it:
    Go to Edit -> Project settings -> Physics -> Gravity Y and change this Y value to something even smaller (for me -29.43 works pretty well, which is 3*(-9.81) so three times the normal gravity)
    You're welcome!

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

    wow, thanks dave

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

    This guy is on another league, HE UNDERSTANDS QUATERNIONS!!

  • @zedude21
    @zedude21 Рік тому +4

    It's always fun to see different solutions to the same problems. Well done!
    I wouldn't say auto jump while holding the jumpkey was a missing feature in a player controller, but it's nice that you covered the concept.

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

    after hours... i finally solved my problem and can go to sleep now.... thank you!

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

    You are a godsend, Subbed!

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

    It's the fifth time i watch this to help me start my projects, so a big thanks to share your knowlage with us. I just have allways a small issue : Does thats normal that my player (capsule) dosen't follow / rotate himself with the camera and the movement ? (he move and jump perfectly, its just on the visual the capsule dosen't rotate).

  • @question2779
    @question2779 2 роки тому +27

    for people who didn´t understand this part (1:38), the yRotation is the Axes that gonne rotation, and gonne encrease and dencrease using the xMouse, who will recive the value according the mouse movement, if you don´t understand yet, the yRotation, is a line on the Y axes and if you imagine a object rotation on the Y axes, you gonna see that the object gonna rotate on X coordinates Axes

    • @sillyninja65
      @sillyninja65 Рік тому +17

      cant really understand the comment tbh

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

      Thank you, that was helpfull. I think i got it now xD

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

      bro i dont understand the comment

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

      In case someone needs this in clearer English: the X axis of the camera is up and down, while the Y axis is left and right. When you add to the X axis of the camera, it moves up -- but the mouse y axis is "inverted", and moving the mouse up in this scenario would move the camera down. So you subtract instead of add, to make the directions match up. Since horizontal rotation is already matched, you just add. This works for both directions (i.e left AND right) since left is just a negative reference while right is a positive one. So for the x axis of your mouse, left = -, right = +, stationary = 0. The same concept applies to the vertical rotation, but can be a little confusing from the subtraction.

  • @user-bw7uu1xo5n
    @user-bw7uu1xo5n 5 місяців тому

    Dude, You are the best!!

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

    Thank you! :)

  • @stef9019
    @stef9019 2 роки тому +6

    It's probably something I did wrong, but I had issues with the groundcheck. Saw some fixes in the comments but didn't want to implement those. For other people having the same issue; make sure the raycast is being casted from roughly the middle of the character.
    For me, for some reason it was being casted form the bottom, which created some issues apparently. Probably something wrong with the playerheight * 0.5f + 0.2f. Still figuring out what though.
    I realized this by using the Debug.DrawRay method which is a really useful tool for debugging. I ended up adding 1.0f to the y coordinate of the origin variable from the Raycast method.
    I also had to set readytojump to true in Start() method.
    Thanks so much for this video!

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

      Thanks this was really helpful and a cool debug tool I will use in the future. I didn't add the 1.0f. Instead by seeing where the Raycast was being drawn from I could tell that both my PlayerObject and Orientation child Player objects had the wrong Y value. This was because I had a cube floor that set the Y value higher. So I reset the Y values to 0 and lowered the floor and boom working. Basically, the raycast was being drawn from the location of my Orientation object inside the Player.

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

      Thank you very much for your help ! I had the problem for the Y coordinate thanks to you it works! Thanks a lot !

    • @bloudy.x
      @bloudy.x Рік тому

      Thanks!!!

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

    I swear this is Brackeys, Also thanks so much! I'm doing a game jam and this series will help me so much! Thanks! (I subbed btw) I alos have a problem where my physics is on 0, -30, 0 but im still falling slow and when I hold space I jump in mid air. What do I do???

    • @holloe0
      @holloe0 Місяць тому

      try looking to grounded code because in my case grounded wasnt working and i did it my own way

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

    Really helpful tutorial. Thank you.

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

      are you a developer if you are i can give you any unity project or asset that is on my chanel for a very cheap price that we end up with after bargaining there is no one on youtube doing this and it would be with proofs and have a refund policy to if you have a better excuse

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

    hanks lot Sir.. You helping us..

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

    Great video, thank you so much!
    In the Update function, if you are ever stuck between two things and NOT grounded, you can insert this code to become unstuck and jump.
    // if movement hasn't changed since last frame, set grounded to False
    if (rb.velocity.x == 0 && rb.velocity.y == 0 && rb.velocity.z == 0)
    {
    grounded = true;
    // this is to prevent the player from becoming stuck
    }