Godot 4 Sourcelike FPS Character Controller Tutorial | Smooth Movement, Bhop, Surf, And More

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.ย. 2024

ความคิดเห็น • 80

  • @MajikayoGames
    @MajikayoGames  3 หลายเดือนก่อน +5

    Hi everyone! Thanks for watching. If you enjoyed this video, make sure to check out the full FPS tutorial playlist where we will add many other features to the FPS controller we built in this video.
    Full Playlist: th-cam.com/play/PLbuK0gG93AsHID1DDD1nt4YHcdOmJvWW1.html

  • @joshkgw9504
    @joshkgw9504 หลายเดือนก่อน +7

    This is easily the best first person character controller tutorial for godot on TH-cam, seriously! You have no idea how helpful this was, cheers.

  • @servingcurnt
    @servingcurnt 3 หลายเดือนก่อน +8

    omg u have no idea how incredibly helpful this was!! i’ve been struggling to find good tutorials like this where there’s actually explanations instead of someone just adding random code without explaining it at all. especially since there’s not that many people that make 3d tutorials of godot in the first place. but anyways, this was amazing and i can’t wait to watch more of your videos :D keep up the good work !!

  • @Potato6153
    @Potato6153 4 หลายเดือนก่อน +7

    You are quickly becoming one of the best tutorial creators, as You are going very in depth and it's great not only for beginners

  • @fluttershy3642
    @fluttershy3642 4 หลายเดือนก่อน +5

    Are you serios, I've spent so long trying to code source style movment and failing. You're a god's send!

    • @MajikayoGames
      @MajikayoGames  4 หลายเดือนก่อน +2

      Glad I could help :D let me know if you have any questions about it. I'm also going to be doing some more videos soon to get sourcelike stair handling, ladders, water, and some more stuff.

    • @fluttershy3642
      @fluttershy3642 3 หลายเดือนก่อน +1

      @@MajikayoGames Really intresting, will you try and get the ladder speed bost thing aswell? When you look up sideways on the ladder while holding (A or D) + W it dobbles the speed. You know what I am talking about? And isen't stair handeling usually just an invisible hitbox that is sloped for smooth ups and downs?

    • @MajikayoGames
      @MajikayoGames  3 หลายเดือนก่อน

      @@fluttershy3642 I think I've seen videos of the ladder boosting, but I'm not 100% sure what it is. If you want, I can send you the current build of what I'm working with and planning on doing the next few videos on. Then you could tell me if it is correct behavior or not. My discord is @majikayogames

    • @blossomcherrypink
      @blossomcherrypink 3 หลายเดือนก่อน

      ​@@fluttershy3642 Bro you just reminded me so hard of CS 1.6 surf maps

  • @Jetiix
    @Jetiix 3 หลายเดือนก่อน +2

    Amazing work, your solutions are much more elegant than mine, with the same principles! You are a real pro at this!
    I tried to make the crouch jump by moving one collision box into another, and the stair stepping with an area cast, but they were both really buggy, your tutorials have been helping me a lot, I hope your channel grows a lot.

    • @MajikayoGames
      @MajikayoGames  3 หลายเดือนก่อน +1

      Appreciate your comment! Glad you enjoyed :) I'm gonna be making a lot more videos so hopefully people will continue to find my tutorials and code useful.

  • @Kolbiathan
    @Kolbiathan 4 หลายเดือนก่อน +2

    You are a LEGEND! Thank you so much for your clear and in-depth explanations of these topics.

  • @Marandal
    @Marandal 4 หลายเดือนก่อน +2

    Awsome. i love me some Source movement. Thank you Maj

  • @tuxhome3686
    @tuxhome3686 4 หลายเดือนก่อน +1

    Was looking to learn 3d in Godot, will be following this tutorial!

  • @sinecure5
    @sinecure5 4 หลายเดือนก่อน +2

    Excellent stuff, you're a great teacher.

  • @Reznovelty
    @Reznovelty หลายเดือนก่อน +2

    You probably have the best tutorial style for fps games right now. I love how you get to the point while also explaining everything really well. Also well done for using proper variable standards and using built in functions, another tutorial i was watching was jumping all over the place haha

  • @wifelessyt
    @wifelessyt 2 หลายเดือนก่อน +2

    This video is a hidden gem

  • @PastaMaster115
    @PastaMaster115 3 หลายเดือนก่อน +1

    I did something a little extra. I made it so sprinting isn't used unless there is forward velocity. If you're moving backwards or directly sideways, sprint doesn't work. Only forward. 👍

  • @ok3739
    @ok3739 หลายเดือนก่อน +1

    thanks loved learning this!

  • @mirage3dee
    @mirage3dee 3 หลายเดือนก่อน +1

    Wonderful content. Thank you for your time and effort.

  • @tedmosby1235
    @tedmosby1235 3 หลายเดือนก่อน +1

    Ooooh nice bro ! helping a lot !

  • @traumwelt1975
    @traumwelt1975 3 หลายเดือนก่อน +1

    might be too advanced for me but thanks a lot for the share of knowledge.

  • @TRUFANATIC
    @TRUFANATIC 4 หลายเดือนก่อน +1

    THIS IS INSANE

  • @RamS-xz6ku
    @RamS-xz6ku 3 หลายเดือนก่อน +3

    Amazing vid rly helpful, do you think there would be a way to combine surfing and titanfall style wallrunning code ?

    • @MajikayoGames
      @MajikayoGames  3 หลายเดือนก่อน

      Yeah this sounds like a pretty fun idea for a high skill cap movement fps game. I had a similar idea before. It's pretty easy to check when in surf mode. Probably just checking if clip velocity was called on a wall of some angle. Maybe some walls you can only surf, and others are too steep so you can wallrun, if that's what you mean.

    • @RamS-xz6ku
      @RamS-xz6ku 3 หลายเดือนก่อน +2

      @@MajikayoGames yeah exactly provided you have enough momentum to wallrun but also are there any similarities between wallrunning and surfing logic

    • @MajikayoGames
      @MajikayoGames  3 หลายเดือนก่อน +1

      @@RamS-xz6ku I haven't implemented wallrunning before, but I guess it would depend on how you implement it. Off the top of my head, with how I have this controller currently set up, maybe you would add a _handle_wallrun function like the others, which would run in the case of maybe having a sufficient amount of some wallrun which gets depleted, and exits right away if not is_on_wall() and the wall is not a correct angle. You could do wall_normal.angle_to(Vector3.UP) and wallrun if it's between like deg_to_rad 85 and 95 degrees or so. I would think wallrun code would be a bit different as you want the play to stick to wall more cleanly and not just slide based on gravity vs strafe as we do here. Could be a fun tutorial, I'll add it to my ideas list.

    • @RamS-xz6ku
      @RamS-xz6ku 3 หลายเดือนก่อน +1

      ​@@MajikayoGamesthx for explaining how i could go about it I'll try it out, looking forward to ur vids tho

    • @RamS-xz6ku
      @RamS-xz6ku 3 หลายเดือนก่อน +2

      Umm also I noticed that if ur jumping forward in air and click the s key all your forward momentum just stops would there be a way for momentum to change more naturally?
      Edit nvm I'm dumb changing that makes it feel more natural yes but i can't do those fast look around boost things anymore so... Smh

  • @jotao2345
    @jotao2345 หลายเดือนก่อน

    excellent video and explaining, will you in the future make a video showing how to create a gun with animations?

  • @nvvv_
    @nvvv_ 28 วันที่ผ่านมา

    39:45 I know you have updated tutorials but it seems like this is still your solution. Since I don't need full on surfing in my project, I'm gonna omit this. Definitely find a new solution if you can though, I can easily imagine a bug that gets you stuck in floating mode.
    Look up the Red Letter Day skip in Half-Life 2 if you want to understand why this can be a SMALL issue.
    Fast Edit: It's not explicitly Red Letter Day I guess. Watch a Half-Life 2 speed run, it's very early on. You're looking for them to jump off a roof onto a street that should definitely kill the player, and then they'll rub up against a car for a little bit. Then something MAGICAL happens.

  • @saveborg1091
    @saveborg1091 3 หลายเดือนก่อน +2

    i have a question... does the "hide child" by switching layer mask would let me setup a multiplayer game? i have this issue where I CANT find a way to hide myself and not the other player.
    Edit: fucking god this video it's insanely well done! the snippet codes explaination... for example what .basis it's litterally the best thing you could've done. PLEASE continue like this.

    • @MajikayoGames
      @MajikayoGames  3 หลายเดือนก่อน +1

      Yes later in the tutorial series (which may take some time to get the videos out) we will use the layer mask feature to help us create a multiplayer game. What you would do here, is only call the code to hide each player's model, on their own machine in _ready(). You can use is_multiplayer_authority() for that, if each client is given authority over their own CharacterBody3D which is probably the approach I'll go with. Then, only the local player model will be hidden and the rest will be shown. You can also just set the nodes to invisible in _ready() depending on which client the code is executing on. Super glad the basis explanation was well received! Goal was to make it accessible to new learners.

  • @Imirui
    @Imirui 23 วันที่ผ่านมา

    since this is an FPS tutorial series, will there ever be a weapon system, or will it just be movement related?

  • @SoulofStorm333
    @SoulofStorm333 หลายเดือนก่อน

    hello ! great tutorial, but i feel like a simple jump after walking make you jump really far away, how would you tweak the specific amount you can jump when pressing forward while jumping ? i feel like it shouldn't be the same initial velocity as walking, maybe normalized since you are going up and front. so where would that be added ?

  • @redpz
    @redpz 4 วันที่ผ่านมา

    I'm a little confused as to how the air_cap, air_accel and air_move_speed variables are affecting the air strafing. Right now it feels like I can accelerate way too fast and turn way too far without a speed penalty.

  • @Go_Coup
    @Go_Coup 18 วันที่ผ่านมา

    If I wanted to make strafing and back-stepping at two different speeds than the forward movement, what would be your method to change the code? I did it my own way, but I don't believe it's anywhere near the ideal method (I changed the accel, decel, and speed values based on the inputs in the get_move_speed function. I also have a walk variable, making the code lengthy with 12 elif statements.) On the bright side, the way I did it allows for a highly refined movement system (I thought changing the friction would be redundant, but I'm thinking about changing the jump height.)

  • @leoman7787
    @leoman7787 3 วันที่ผ่านมา

    how do i turn while jumping with just mouse movement? i dont want to hold strafe keys while doing this

  • @PastaMaster115
    @PastaMaster115 3 หลายเดือนก่อน +2

    Is there a benefit to nesting your if statements instead of just using "and"? Especially if there isn't expected to be an elif or else.

    • @MajikayoGames
      @MajikayoGames  3 หลายเดือนก่อน +1

      Nope no difference. Sometimes I do it in my own code if I feel it makes it more clear and easier for me to read, or if I'm planning to add some more code there later.

  • @empMerp
    @empMerp 27 วันที่ผ่านมา

    Great tutorial, The only problem I have is when ever I land after surfing or run into a wall while bhoping my character gets stuck in MOTION_MODE_FALLING.

    • @empMerp
      @empMerp 27 วันที่ผ่านมา

      nvm just a very small typo

  • @Lily-kv3rb
    @Lily-kv3rb 3 หลายเดือนก่อน +1

    I'm running into some issues with the "Advanced ground movement with friction/bhop" section. I copied exactly what was in the video but unless I decrease the ground_friction var from 6.0 to atleast 5.0 or lower my character doesn't move when I press forward. I even downloaded the starter project file from github and copy pasted the _handle_ground_movement func from their (except for the headbob piece, I didn't want to add headbob) and I'm still frozen when the friction value is set at 6.0. This wouldnt be a problem if setting the friction value lower also made my base speed extremely fast. Any ideas on fixing this issue?

    • @MajikayoGames
      @MajikayoGames  3 หลายเดือนก่อน

      It's hard to say without seeing your code, those accel/decel/friction vars are pretty sensitive though. I would try with my values first, copying exactly from my code. Then adjust one by one. Yes if friction or decel is higher than accel or walk speed, probably you won't be able to move. I don't have a clear explanation for each, other than it's just the quake/source movement recipe. Not super intuitive but it gets the exact same movement style so it's important that these variables are used how they are. So I would try copying exactly from my code and changing one by one adjusted until you get your desired move speed/feel. Also check if the properties are changed in the editor inspector on your character, if you change them once, they will stay the same even if you change them in code I think. If you can't figure it out, you can pastebin your code and message it to me on twitter and I could take a look if you want.

  • @JosephAlejandroAguilarFlores
    @JosephAlejandroAguilarFlores 2 หลายเดือนก่อน

    Hello, very good tutorial but I have a doubt, when I stick to a straight wall the speed increases, how can I prevent that?

  • @nataliereilly7895
    @nataliereilly7895 3 หลายเดือนก่อน +1

    👍🏽👍🏽👍🏽

  • @Imirui
    @Imirui 23 วันที่ผ่านมา +1

    How would I go about removing b-hopping if I didn't want my game to have it?

    • @MajikayoGames
      @MajikayoGames  23 วันที่ผ่านมา

      I think it's kind of hard to remove completely and keep source style movement. You can try things like increasing friction, and decreasing the air_accel and other air movement variables to help prevent movement exploits like bhop. For a more simple version, I'd recommend LegionGames FPS tutorial and take the air movement code from there which is much simpler and should help prevent bhop.

  • @gronko_chug_butter
    @gronko_chug_butter 3 หลายเดือนก่อน +2

    Is there any reason to use the self keyword, or is it just for readability.

    • @MajikayoGames
      @MajikayoGames  3 หลายเดือนก่อน +1

      nope it is implicit for all variables/funcitons in scope of current node but I like to put it there to make it more clear for myself personally

  • @raminkuntopolku8636
    @raminkuntopolku8636 3 หลายเดือนก่อน +2

    How would one implement ramp sliding like in source games? Like when you hit a slant/ramp straight on at a high speed, you just keep sliding. Currently in this project the player character just slows down aggressively. Also it seems like bunnyhopping without airstrafes seems to slow you down because the friction is applied from the first frame you touch the ground. How could i make bunnyhopping conserve the speed i have?

    • @MajikayoGames
      @MajikayoGames  3 หลายเดือนก่อน

      Not sure what you mean about bunnyhopping without airstrafes slowing you down. I'm not sure exactly how source does it, do they actually wait a frame before applying any friction? I though they just applied a small amount of friction each frame you're on the ground, so if you gain speed faster than the friction by air strafing, you can speed up. You can adjust the character's ground friction to change how this behaves.
      The issue of sliding on slopes, I'll make a note of that, I already have a similar issue here on github that I want to look into. Looks like a few mechanics depend on slope angle:
      github.com/majikayogames/SimpleFPSController/issues/1

    • @raminkuntopolku8636
      @raminkuntopolku8636 3 หลายเดือนก่อน

      @@MajikayoGames I mean just hopping straight (simply holding space with autobunnyhop) should let you conserve all of your speed and not slow down a little bit each time you touch the ground. I don't know how source does it but that's what cs bunnyhop and surf servers feel like.
      I don't want to lower the friction since that would make the regular ground movement slippery right? and that wouldn't eliminate the issue completely either.

    • @MajikayoGames
      @MajikayoGames  3 หลายเดือนก่อน +2

      @@raminkuntopolku8636 i think they just have less friction than this controller does by default. try lowering the ground_friction and ground_decel values a bit. yes it is more slippery but source games are more slippery than this controller by default too. also in source there is a different crouch friction which i didnt add yet.

    • @lethn2929
      @lethn2929 3 หลายเดือนก่อน

      @@raminkuntopolku8636 I'm late to the the video but in case your looking for a bit more detail or anyone is wondering the character controller itself has settings on angles which dictate whether or not it can even slide on them and I found it was interfering with my attempts at implementing vent crawling awhile back, following settings will likely affect things a bit.
      . Wall min slide
      . Max Angle
      . Stop on slope boolean
      Hope this helps people

  • @Iyad-i3j
    @Iyad-i3j 25 วันที่ผ่านมา +1

    Is there any way for me to directly copy and paste all the code because it’s taking me way to long to write it down

    • @MajikayoGames
      @MajikayoGames  25 วันที่ผ่านมา

      the github link in the description has the completed project

    • @Iyad-i3j
      @Iyad-i3j 25 วันที่ผ่านมา

      @@MajikayoGames thx and your amazing at what u do btw

  • @WeirdGrunkovic
    @WeirdGrunkovic หลายเดือนก่อน

    I've been having an issue where godot does not recognise the the function get_move_speed() , despite it being used in the advanced movement + friction section of the video, do you know why this could be happening and do you have any advice that could help? Thanks

    • @WeirdGrunkovic
      @WeirdGrunkovic หลายเดือนก่อน

      Also thanks a lot for this tutorial! its very informative and its helped me understand how movement and physics work in this engine, despite the one hiccup ive had (which is probs my fault lol) everything ive interpreted from the video has worked flawlessly

  • @JuJuR
    @JuJuR 27 วันที่ผ่านมา

    I’m guessing it would work the same for 3rd person?

  • @jamesoneill4607
    @jamesoneill4607 4 หลายเดือนก่อน +1

    What about those stairs though? 😁

    • @MajikayoGames
      @MajikayoGames  4 หลายเดือนก่อน +3

      Tutorial for those should be out in a few days as part of this series :) have 1 short vid to make before that

  • @vmGrymm
    @vmGrymm 2 หลายเดือนก่อน

    Are you god?

  • @skerra
    @skerra 7 วันที่ผ่านมา

    I want to limit the players bhop speed but keep the speed in air uncapped so surfing etc isn't effected. The player should still be able to exceed the max speed cap in air through strafing but be set back to the threshold after touching the ground.
    Tried to implement it myself but it felt unsmooth as the change in speed was really noticeable.
    Dont want the player to go to fast.

  • @christophereberhart7487
    @christophereberhart7487 19 ชั่วโมงที่ผ่านมา +1

    So this video is already deprecated due to the experimental nature of Godot, rotate_x is no longer a supported method.
    It is now rotate(), E.G. $Camera3D.rotate(Vector3(1, 0, 0), -event.relative.y * look_sensitivity)
    would have been nice, if they slowly phased out old methods, instead of dropping them next update lmao

    • @MajikayoGames
      @MajikayoGames  19 ชั่วโมงที่ผ่านมา +1

      From what I can tell both are available still? At least in 4.3: docs.godotengine.org/en/stable/classes/class_node3d.html#class-node3d-method-rotate-x

    • @christophereberhart7487
      @christophereberhart7487 18 ชั่วโมงที่ผ่านมา

      @@MajikayoGames it throws an error as a null reference

    • @christophereberhart7487
      @christophereberhart7487 18 ชั่วโมงที่ผ่านมา

      @@MajikayoGames you know what, I think it's a mistake on my part, because it's not referencing the camera object for some reason.
      embarrassing.

    • @christophereberhart7487
      @christophereberhart7487 18 ชั่วโมงที่ผ่านมา

      Yeah, it was an error on my part, I deeply apologize for any misinformation I may have spread.

    • @MajikayoGames
      @MajikayoGames  18 ชั่วโมงที่ผ่านมา

      @@christophereberhart7487 no worries everyone makes mistakes.

  • @lethn2929
    @lethn2929 2 หลายเดือนก่อน +1

    Since people were understandably asking about ladders I thought I'd post something up that I hacked together.
    if isTouchingLadder == false:
    self.velocity.x = wishDirection.x * getMoveSpeed()
    self.velocity.z = wishDirection.z * getMoveSpeed()
    elif isTouchingLadder == true:
    self.velocity.x = 0
    self.velocity.z = 0

    var inputDirection = Input.get_vector("Right", "Left", "Backward", "Forward").normalized()
    wishDirection = self.global_transform.basis * Vector3(-inputDirection.x, 0, -inputDirection.y)

    if isTouchingLadder == true && Input.is_action_pressed("Forward"):
    self.velocity.y = 1
    if isTouchingLadder == true && Input.is_action_pressed("Backward"):
    self.velocity.y = -1
    if isTouchingLadder == true && Input.is_action_just_released("Forward") || Input.is_action_just_released("Backward"):
    self.velocity.y = 0
    elif isTouchingLadder == true && Input.is_action_just_pressed("Jump"):
    isTouchingLadder == false
    Seems to work alright, I prefer having more control on ladders when it comes to my movement so on this one you can go up and down I think there's a bit of a bug where the jump key doesn't seem to quite work right away but that's potentially just my character clipping through the ladder and not colliding correctly because when I crouch and jump instead it comes off the ladder which I kind of like anyway lol.
    The IsTouchingLadder is simply a boolean, I had it change based on whether or not I triggered an Area3D in this case on the ladder and then that allowed the ladder movement to happen, if you want to do it with a keypress just edit the code to your liking, everyone's got their preferences.

    • @MajikayoGames
      @MajikayoGames  2 หลายเดือนก่อน +1

      Looks great! I have a more comprehensive video on ladders as well if anyone is interested: th-cam.com/video/uW01u_1PldI/w-d-xo.html

  • @YourZoneX
    @YourZoneX หลายเดือนก่อน

    wish_dir = self.global_tranform.basis * Vector3(-input_dir.x, 0., -input_dir.y)