Anatomy of an Advanced Player Controller

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ธ.ค. 2024

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

  • @git-amend
    @git-amend  4 หลายเดือนก่อน +11

    Happy Sunday everyone! If you're looking to build a more robust Player Controller, I hope this video helps you out!

  • @정동우-n2x
    @정동우-n2x 4 หลายเดือนก่อน +43

    Personally, I'd like Unity to designate your video as an official tutorial. It's really helpful.

    • @git-amend
      @git-amend  4 หลายเดือนก่อน +13

      Haha, well maybe one day they'll offer me a job. You never know...

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

    Wow, an actual YT programming video that explains upfront what will be required and what will be done. That is so nice! I'm so tired of going over a 1h tutorial, just to hit the usual snag: "and now you can just do steps B to D by yourself, since I'm expecting you all are intimate at using this 3rd party asset you will be needing to do it".
    Just found your channel yesterday, but this seems like an absolute treasure trove of quality content for someone returning to Unity after a several years break from the gaming industry

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

      Thanks, glad you found the channel and welcome back to the gaming industry!

  • @bluzenkk
    @bluzenkk 4 หลายเดือนก่อน +20

    wow... this is the cleanest player controller code i've ever seen...

    • @git-amend
      @git-amend  4 หลายเดือนก่อน +4

      Wow, thanks for that!

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

      Yeah, a lot cleaner than the Monobehaviour-Monolyth provided with Unity's Third/First Person Controller sample package. 😁

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

    It's tutorials like this that make me realise just how much I have to learn. Hopefully I can come back to this in the future and actually understand it.

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

      Always something new to learn in programming!

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

    Having so few likes on this video and so few subscribers for the content you churn out is criminal. Been enjoying your content for a while now and look forward to more.

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

      Thanks! Maybe your comment will be the one to trigger the YT algorithm 😃 Lots more to come!

  • @Krechevskoy
    @Krechevskoy 4 หลายเดือนก่อน +6

    You just can't miss. This is awesome! 😎

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Thank you!

  • @crazyfox55
    @crazyfox55 4 หลายเดือนก่อน +11

    I would love to see more design videos where the implementation is left out of the video. I think I need more tutorials on design and critical thinking rather than a solution.

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

      Noted!

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

      Agreed!

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

    I cant believe the quality of your work, well done mate!

    • @git-amend
      @git-amend  หลายเดือนก่อน

      Thank you! Cheers!

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

    awesome content love the way yo deliver it its a bit above my current level but I have learned alot from the few videos I have watched, keep it up

    • @git-amend
      @git-amend  หลายเดือนก่อน

      Great to hear! Thanks!

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

    Thanks for this! I’m interested in why you put the logic for jumping and movement not into a move, jump state etc. and keep the controller class lightweight, e.g. have a physicshandler deal with the rigidbody etc. Great stuff.

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

      Thanks for the comment! You could abstract that logic into another layer if you wanted to, but I felt like the primary concern of the PlayerController should be to convert input into momentum and velocity. Making each state run a calculation though a physics handler on every FixedUpdate would work, so long as you ensure that every state does run that logic, and in this case all 5 states would have a new dependency. For me, I prefer the state machine to be the dependency of the class doing the physics logic and not the other way around.

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

    Very thankful for your commitment to advanced concepts! Thanks for all your hard work to make these videos for us :)

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      My pleasure!

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

    I followed this tutorial on Godot, It worked wonderfully, Thank you!

    • @git-amend
      @git-amend  3 หลายเดือนก่อน

      Great to hear!

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

    I appreciate your conversational teaching/lecture style. Its much more natural than some and keeps my brain engaged.
    This is valuable knowledge to have under the belt, even if Unity already handles a lot of this with its own plug-ins (NavMesh, Input System, and Cinemachine come to mind). Knowing how to isolate and exert finite control over the system as a whole is incredible! My guess is that it will also be more efficient code to run in the long run rather than snapping different bits together that weren't designed to communicate as effortlessly.
    Great tutorial, and thanks for sharing this with us!✌️✨

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

      Thank you!

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

    Such a great tutorial! It can't be easy to go over such dense material in such a small amount of time

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Thanks! Yeah, it took a long time to record and edit!

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

    Thanks for the high quality videos. Glad to discover this channel this week.

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Glad you found it! Welcome!

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

    Your channel is incredibly helpful. Thank you so much!

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

      You're very welcome!

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

    Thanks for the great Content! This gives great insight into how to design a clean and robust PlayerController!

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Thank you, glad you liked it!

  • @Abdulwahab-q2v
    @Abdulwahab-q2v 4 หลายเดือนก่อน

    i have never watch a vedio of you, on which i can say oh ok i know it before!
    every video is full of knowledge

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

      I've glad to hear that! Always good to fill knowledge gaps!

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

    Great video as always, Adam!
    Is this meant to be part of the 3D platformer series or is it its own thing? I'm just wondering if I'll miss anything if I haven't already gone through the 3D platformer one.
    Keep up the great work!

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

      Thank you. This is much more in depth than the one used in the 3D Platformer series, but some of the concepts will be similar.

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

    Nice! Feels like we're getting secrets of the pros! Looking forward to part 2! I hate to ask for anything because you give a lot, but could you show us how you would add some "juice" to your player?

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Thank you. Actually Juice is a great topic. I actually bookmarked a video I watch sometimes to remind me to Juice it or Lose it! th-cam.com/video/Fy0aCDmgnxg/w-d-xo.html
      But yes, good topic. I'll add it to the list.

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

    quality stuff, as usual!

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Much appreciated!

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

    Great tutorial as usual. If you're looking for video ideas, I'd like to see an update of your State Machine video to make it more flexible as a Hierachical State Machine that uses a version of your Blackboard to maintain state for easy access?

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Thanks for the idea!

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

    Another amazing video as always, Adam! Would you at some point make a video on how to escape the Singleton Manager architecture that many games fall into? I think it took me 2-3 years to escape it, because there really isn't many resources available for alternatives. I know Sasquatch has one, but I would love to see your version of it. I use Scriptable Objects now for managing stuff, but that also has its pitfalls and gotchas. Your tutorials on the static eventbus, event channels, and the dependency injection framework really helped to decouple my code, but I think a dedicated video on how to avoid Singletons would be gold for never game developers, like the ones you did for SOLID etc.

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

      Thanks for the comment! I think I have that topic on my TODO list already, but I'll double check that. We are definitely going to have a video this fall about using Scriptable Objects instead of Singletons, but of course there are other ways too.

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

    Any chance you will tackle climbing ledges at any point? Like in the old Thief games or Dying Light? It is perhaps one of the hardest things i personally had to do and was never satisfied with my results. Thank you for your great content.

    • @git-amend
      @git-amend  4 หลายเดือนก่อน +4

      Hm, that's a good idea. I'll write that down!

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

    This is really helpful, solution is very engine agnostic and i think will apply this to my godot game.

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

      Glad to hear that. Someone was just asking me 2 days ago if I'd make a Godot video... maybe agnostic is the way!

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

      @@git-amend yup you can apply all of this in Godot without much hassle

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

    Another banger dropped!

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Thank you!

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

    Thank you) very helpfull!

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      You're welcome!

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

    great stuff keep it up please !

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

      Thanks, will do!

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

    Amazing video!!!! Will you have a Multiplayer course soon?

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

      Thanks for the comment! Still brainstorming course ideas, multiplayer might be a good one.

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

    ive never seen someone with such fast wpm, you're like a human gpu

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Thank you, I think... 😃

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

    Really add a feature of relative velocity please, like standing still on a moving rigidbody platform like ships and being able to move around while the ship is moving. Couldnt find tutorial like that and it be really helpfull.

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      That's a good idea, I'll put that on the list.

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

    Great video 🎉

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Thank you 😁

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

    Talking about player controller and it's physics: Can you, please, someday make a video about advanced physics modification like you did with PlayerLoop?
    I belive it's possible to change physics code in Unity, even up until to make a Teardown one. I love it for it's correctness and very different materials, also with great collision detection.
    I think video from you about simple, but not janky voxel (Or anything else you prefer, the target here is the Unity modification) physics will be not just awesome, but humongously powerful

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

      Something to consider - I'll take note of this idea. But, I have the feeling that it will take a lot of effort to build and make a video about it as well. I'll give it some thought.

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

      @@git-amend that's why I'm asking you about it! Thank you for consideration.
      Almost nobody has the power of physics modification yet, all the people are complaining about unity's bad simulation. I think that is chalangable, because of engine's architecture and philosophy, which is understandable by their code.

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

    hey, i dont know if i should use this implementation or the previous one from your 3d Platformer playlist

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

      This one is just a more advanced version than the one used in the 3D Platformer

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

    Great tutorial and very helpful. I got one question. Since the collider is above the legs, how do you prevent the legs from clipping into stairs while going up?

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

    Awesome video!! Thank you so much
    Does anyone know why we would store a transform in a "tr" field instead of using transform tho? Like in the PlayerMover script

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Thanks! Can watch this video here to answer your question about caching the transform: th-cam.com/video/uTJe7M1E3Tg/w-d-xo.html

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

    how can we handle walking on a planet/sphere using this floating capsule method. and applying rotation to movedir

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Watch the video about the Gravity Well - th-cam.com/video/M7MRg0YvdSs/w-d-xo.html
      You can use the center point as the origin of the Sphere/Planet and reverse the UP direction to be down instead.

  • @abuDA-bt6ei
    @abuDA-bt6ei 4 หลายเดือนก่อน

    Do you have any advice on connecting Unity with a backend database, IE for a multiplayer game? There seem to be a lot of different options like hosting your own server with a db and requesting from it using a rest api, having your own backend server that communicates with it, or using a service like firebase. There just isn’t a lot of info when it comes to using Unity and db’s so you have to dive into the webdev side of things where there’s just a million different ways to go about it. It would be nice to know what you believe would be the proper way to implement a database into a unity game, even better if you could make a video on it 😅.

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      This is a complex topic, and it might make a good video. There are not a lot of resources about it. UGS is generally considered to be quite good these days though, and pretty cheap for most scenarios. Check out this page as well: www.dragonflydb.io/game-dev/databases

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

    Nice!

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Thank you! Cheers!

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

      @git-amend, I wanted to ask if you're familiar with the built-in component called Character Controller. This component includes essential features for a controller, such as step handling and slope management. What really sets it apart, though, is its collision detection-it works exceptionally well straight out of the box, making it a reliable choice for many projects.

  • @ПавлоК-з9н
    @ПавлоК-з9н 4 หลายเดือนก่อน

    Content is brilliant. Thank You. But I've been thinking of what a massive chunk of work player controller is. There is no way it must be recreated for each game. Things like this should be a part of the engine in 2k24

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Yeah, I agree it is a lot of work - I almost always start a project with the player controller because inevitably it is the system that will take the longest and require the most tweaking.

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

    Spent today working on a new HSM version of KCC but yours looks much simpler. I'm aiming for something I can mix with a button combo -triggered - attack system, will your next video handle attack states?

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

      The next video will be about building a custom camera controller. I had not planned to get into combat.

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

    Will the physics interpolation work if you modify linear velocity every fixed update?

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      If you're applying forces or setting the velocity in a continuous and predictable manner, the interpolation will effectively smooth out an object's movement.

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

    For people absolutely losing their minds about no linearVelocity, use velocity instead.

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

      Thanks for pointing that out, you must be on an earlier version of Unity. The velocity property is now [Obsolete], as with a few others such as drag and angularDrag.

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

      @@git-amend Yeah, the project I'm using is at 2022. I caught it right away, as this happened to me before when I used a more current unity. I figured I should say something to save someone from what I went through.

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

      @@TheMystogrigen he just updated the Github source to include notes on this issue.

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

      @@TheMystogrigen I appreciate that - I added a note in the description and the source code too.

    • @mihaitza165
      @mihaitza165 12 วันที่ผ่านมา

      thank you!

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

    I am new to your channel. This video is great, but I am unable to understand the calculations you use in it. Can you suggest any resources to learn math so that I can understand this video completely? I am confused about how to calculate capsule height, center, and more. Thank you!

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

      I recommend Freya's video Math for Game Devs - th-cam.com/video/MOYiVLEnhrw/w-d-xo.html

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

      @@git-amend Thank you bro

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

    Im a bit confused, if you have a statemachine, why do you not move the controller parts to the states, isnt that the point of the SM? To only execute the code that is relevant for the current state?

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      This is a design choice, I want my Player Controller to be responsible for all momentum and velocity calculations, and the State Machine to be responsible for maintaining the state and any hooks that are event based such as leaving the ground.

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

      @@git-amend i see, may I ask the reasons for this design choice? because I always thought that merging movement controller and the state machine kinda makes sense, so youre controller logic doesnt need to know the current state.

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

    i was LITERALLY just loosing my brain over stairs, step height and all and all , and you released a video , you are god sent

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Nice, I hope this gives you some ideas!

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

    Hey why do you prefer K&R Style over Allman style?

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

      I prefer the K&R style because I find it clean and concise. I don't want to waste an entire extra vertical line for a curly bracket when we already use indentation as a cue to indicate a block.

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

    First time seeing sensor ??= new RaycastSensor(tr) is this just checking if senser is == null and if so setting it to new RaycastSensor(tr) also is the tr in RaycastSensor(tr) being used to set the Transform named tr to the player? Sorry if its a dumb question Im still learning. >~

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

      Yes, you are correct on both counts. The null-coalescing assignment operator in C# checks if sensor is null, and if it is null it will assign a new RaycastSensor, and yes tr is the same value we set in the constructor, which is the transform of the `Hero` in this case.

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

      @@git-amend Yay Thankyou so much, I really enjoyed the video, I'm looking forward to the next one ^-^

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

    This video will be incredibly helpful for me, thanks Adam. I'm not sure if you're familiar with the capsule theory, but it involves a capsule floating a few inches above the ground. If you're curious, you can see an example of this concept in the game 'Very Very Valet', there is a video around in youtube with the explanation.
    PD this is the video (th-cam.com/video/qdskE8PJy6Q/w-d-xo.html)

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      I'll check it out!

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

    Vector math 🤤

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

      Well... I tried to make it easier with a VectorMath library, hopefully that helps...

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

    what are your thoughts on using the overide method for state machines and is there any considerations I should have when porting this to work with them. Also I don't quite get how your getting keypresses with this, if there just default from the input system?

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      I'm not quite sure what you mean about override, but the links to the other videos about the state machine used in this video and the new Unity input system can be found in the description.

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

    First time witnessing you use this little amount of coding patterns I am shocked.

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

      Well... I did manage to squeeze the State pattern in there at the end!

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

      @@git-amend I noticed :)

  • @V-post
    @V-post 4 หลายเดือนก่อน

    Sidebar.. I know my scrum words

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

    Like you, I usually cache the transform. I actually got into an online "nerd war" debate over whether or not there's any benefit to doing so - lol
    th-cam.com/video/uTJe7M1E3Tg/w-d-xo.html

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

      Hahaha... I'll check this out!

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

    Is it a crime to adapt this to Unreal?

    • @git-amend
      @git-amend  4 หลายเดือนก่อน

      Go for it!