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
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.
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.
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.
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.
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.
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!✌️✨
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!
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?
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.
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?
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.
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.
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.
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.
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
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.
@@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.
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?
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
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.
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 😅.
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
@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.
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
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.
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?
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.
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.
@@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.
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!
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?
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.
@@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.
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.
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. >~
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.
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)
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?
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.
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
Happy Sunday everyone! If you're looking to build a more robust Player Controller, I hope this video helps you out!
Personally, I'd like Unity to designate your video as an official tutorial. It's really helpful.
Haha, well maybe one day they'll offer me a job. You never know...
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
Thanks, glad you found the channel and welcome back to the gaming industry!
wow... this is the cleanest player controller code i've ever seen...
Wow, thanks for that!
Yeah, a lot cleaner than the Monobehaviour-Monolyth provided with Unity's Third/First Person Controller sample package. 😁
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.
Always something new to learn in programming!
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.
Thanks! Maybe your comment will be the one to trigger the YT algorithm 😃 Lots more to come!
You just can't miss. This is awesome! 😎
Thank you!
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.
Noted!
Agreed!
I cant believe the quality of your work, well done mate!
Thank you! Cheers!
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
Great to hear! Thanks!
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.
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.
Very thankful for your commitment to advanced concepts! Thanks for all your hard work to make these videos for us :)
My pleasure!
I followed this tutorial on Godot, It worked wonderfully, Thank you!
Great to hear!
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!✌️✨
Thank you!
Such a great tutorial! It can't be easy to go over such dense material in such a small amount of time
Thanks! Yeah, it took a long time to record and edit!
Thanks for the high quality videos. Glad to discover this channel this week.
Glad you found it! Welcome!
Your channel is incredibly helpful. Thank you so much!
You're very welcome!
Thanks for the great Content! This gives great insight into how to design a clean and robust PlayerController!
Thank you, glad you liked it!
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
I've glad to hear that! Always good to fill knowledge gaps!
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!
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.
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?
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.
quality stuff, as usual!
Much appreciated!
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?
Thanks for the idea!
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.
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.
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.
Hm, that's a good idea. I'll write that down!
This is really helpful, solution is very engine agnostic and i think will apply this to my godot game.
Glad to hear that. Someone was just asking me 2 days ago if I'd make a Godot video... maybe agnostic is the way!
@@git-amend yup you can apply all of this in Godot without much hassle
Another banger dropped!
Thank you!
Thank you) very helpfull!
You're welcome!
great stuff keep it up please !
Thanks, will do!
Amazing video!!!! Will you have a Multiplayer course soon?
Thanks for the comment! Still brainstorming course ideas, multiplayer might be a good one.
ive never seen someone with such fast wpm, you're like a human gpu
Thank you, I think... 😃
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.
That's a good idea, I'll put that on the list.
Great video 🎉
Thank you 😁
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
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.
@@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.
hey, i dont know if i should use this implementation or the previous one from your 3d Platformer playlist
This one is just a more advanced version than the one used in the 3D Platformer
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?
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
Thanks! Can watch this video here to answer your question about caching the transform: th-cam.com/video/uTJe7M1E3Tg/w-d-xo.html
how can we handle walking on a planet/sphere using this floating capsule method. and applying rotation to movedir
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.
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 😅.
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
Nice!
Thank you! Cheers!
@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.
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
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.
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?
The next video will be about building a custom camera controller. I had not planned to get into combat.
Will the physics interpolation work if you modify linear velocity every fixed update?
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.
For people absolutely losing their minds about no linearVelocity, use velocity instead.
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.
@@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.
@@TheMystogrigen he just updated the Github source to include notes on this issue.
@@TheMystogrigen I appreciate that - I added a note in the description and the source code too.
thank you!
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!
I recommend Freya's video Math for Game Devs - th-cam.com/video/MOYiVLEnhrw/w-d-xo.html
@@git-amend Thank you bro
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?
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.
@@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.
i was LITERALLY just loosing my brain over stairs, step height and all and all , and you released a video , you are god sent
Nice, I hope this gives you some ideas!
Hey why do you prefer K&R Style over Allman style?
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.
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. >~
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.
@@git-amend Yay Thankyou so much, I really enjoyed the video, I'm looking forward to the next one ^-^
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)
I'll check it out!
Vector math 🤤
Well... I tried to make it easier with a VectorMath library, hopefully that helps...
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?
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.
First time witnessing you use this little amount of coding patterns I am shocked.
Well... I did manage to squeeze the State pattern in there at the end!
@@git-amend I noticed :)
Sidebar.. I know my scrum words
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
Hahaha... I'll check this out!
Is it a crime to adapt this to Unreal?
Go for it!