Thought I was getting discord notifications the entire video. Really liked the video, trying to learn as much as I can about AI.
@Grynjolf5 жыл бұрын
Ya that was really getting on my nerves. Could have just not recorded desktop audio, or at least muted it in post. There wasn't any reason to be recording that.
@FullMe7alJacke74 жыл бұрын
@@Grynjolf I'm sure it was a minor oversight is all.
@darkstorm4963 жыл бұрын
I was still thinking that it was discord going crazy until I read your comment XD
@RafaelColladoLemon5 жыл бұрын
I REALLY appreciate this video. I have been one of those "million if-statement" people for far too long.
@Woodythehobo4 жыл бұрын
Love that rush of suddenly understanding something. This will be really damn useful and clean up my code a lot. Love these no nonsense deep dives. Thanks dude!!!
@dilp793 жыл бұрын
I like intensity of information per minute of video, enough to get all details and you don’t loosing time. Thanks for sharing your expertise
@aldigangster1234 жыл бұрын
Love your deep-dive tutorials. You are the only one I know who goes into the necessary details, without any rambling or getting himself lost. Really like that you record your videos being prepared and not just start talking into the blue. That said, I've could have listened another 2 hours to you talking about state machines (but maybe without the background beeps) :)
@SebastiranLoL4 жыл бұрын
The source code file on the website only contains the bad version, not the good one. Great video!
@Me__Myself__and__I Жыл бұрын
True, and that is really annoying. Why offer the source at all if its only going to be the "bad" version?
@Bramoldinho5 жыл бұрын
Would love to see more in-depth videos on this subject and the more advanced stuff. Great job on the video!
@sadunozer22413 жыл бұрын
Hey man, I'm a pretty experienced programmer, which not much time in my hands, and having good/best practices like this helps a lot! I'm not so good with Unity, so going through good example projects isn't really and option for me since I get confused by small things like animations etc. But I'm very good with sys admin stuff micro services etc. Seeing content on youtube where %30-50 of it is just garbage code but has this cool little bit is a waste of time. Since we all respect your experience, please keep doing videos like this where you take a concept and do it how the industry does. Thanks!
@keilvid2 жыл бұрын
Very complicated Topic, but I can tell already that this will be substantial to learn
@gamedevshrish76022 жыл бұрын
Hi Jason, amazing tutorial. I'll have to gripe and say that the discord sounds are kinda distracting here tho.
@tonychristney27283 жыл бұрын
Another advantage of using Type vs enum is that the default Dictionary hash comparer for enums casts to object, causing boxing everywhere.
@alec_almartson4 жыл бұрын
Thank you Jason. This is amazing stuff. I've always wanted to know HOW gameplay programmers made those NPC/CPU characters to 'think', and to fight against us - human players (I have wondered that since I was 6 years old, playing 'Beat 'Em All' games (e.g.: Brawl Brothers, Final Fight I, II, III, etc.) because I was amazed by the complexity of the characters' behaviour in some cases). It is funny somehow that it can be accomplished by solution so simple as: a SWITH - CASE STATEMENT(or some IF - ELSE IF - ELSEs) with a ENUM Variable for all the possible Enemies' States. Please, don't hesitate to make more in-depth videos about State Machines, A.I., and Machine Learning Tips and Tricks. Your videos are really great.
@Animaniac-vd5st5 жыл бұрын
I like how your videos evolve and where you are now. Showing simple solution - show better version and discuss some decisions and where you would improve from there on.
@Unity3dCollege5 жыл бұрын
Thanks! Happy to hear it :) I thought that may be a good format to demonstrate something like this, otherwise it's really easy to justify sticking w/ the simplest solution (which of course works great sometimes too though :)
@rickhernandez83015 жыл бұрын
Amazing! Learn more in this video than I did in any of my college classes about AI and Unity.
@PS-vj6jz2 жыл бұрын
This video very Perfect and Important for Juniour. Big thanks from Russia.
@unlockener5 жыл бұрын
Great tutorial. Next could be about FSM that have decision logic outside the states (I think they are called hierarchical FSM, but I might be wrong) and then about behavioral trees. Next approach could be unit AI -> group AI -> player AI (like RTS opponent). This would cover the topic nicely. Btw, what I like about your tutorials is that you are using a lot of syntactic sugar, more advanced syntax and c#4,5,6,7 features. As I am mathematician and not a coder this is super enlightening.
@Kramlets5 жыл бұрын
public Team Team { get { return _team; } } public Team Team => _team; Woww, that is so useful. I had no idea you could do that with the lambda operator. This is so much more readable than what I've been using.
@dvandamme005 жыл бұрын
excellent video, as usual. far *far* better than the official unity state machine tutorials.
@FractalPrism.3 жыл бұрын
thanks for making this kind of content. explaining each label as you go is great.
@MrStonedLover5 жыл бұрын
Very good video. My FSM was a bit different and this video gave me the one thing that was missing to make my FSM much smoother and expendable. I like your videos. It helps me a lot! Appreciate your work! Keep going!
@speedrob4 жыл бұрын
1:02 you god damn tease, I wanted to see that fight. Great tutorial too.
@darryljf72155 жыл бұрын
I don't know if i'm being thick or something, but the link to the project only has one script: Drone.cs and it's got the enum AI version ???
@Urasawa924 жыл бұрын
These videos are so good, it's insane that they're available for free! Thanks!
@TheDiggidee4 жыл бұрын
Really love the advanced stuff you're covering and this seems really cool but I just have 1 gripe with it. Each of your states has knowledge of the other state. I think I'd prefer extracting out the decision making into a Chain of Responsibility that gets called in Update and just have the state perform the action that it is instructed to do. This way your states are decoupled, so is the decision making and this would then facilitate pulling this data from a datasource. Cool stuff any way
@arthurmarquis7645 жыл бұрын
Awesome lecture man. Thank you so much for helping me understand this concept. Need this for my own use and glad I get the chance to understand the concepts and not just rewriting someone else's code.
@pixelb0i2554 жыл бұрын
Jason, as always thank you for the awesome guidance. I am interested in diving into AI more and like your previous way of coding AI states I too did the same thing i find it hard to enhance down the road. What I am looking for help with is a more modern day A.I. where the entity isn't so much patrolling or wandering, but guarding an area or zone until acted up on. Then it does the normal chase/hunt, attack/destroy. What I don't see a lot of included is: Flee, Call for Support, and destroying potential places a player might be hiding. The latter I would like to see how you incorporate into your A.I. Much appreciated and as always - thank you.
@phobos2077_5 жыл бұрын
Nice example, but I have a couple of questions based on me trying to use FSM for the first time in a game: 1. How would you recommend passing instance-specific settings to a State class? I had to write a bunch of serializable POCO classes and put them into a MonoBehavior that controls AI and owns the state machine. Then pass those to State classes that I instantiate in that "controller". Worked but felt a little messed up. 2. State transitions are hard-wired into State classes. What if I wanted more reusable states, how would I go about with transitions and triggers separate from State classes? 3. (related) What if I want to have a variable "default" state. Let's say "patrol" state or "idle" state instead of a "wander" state in some cases... For now I only have one default state, but still wondered how would I go about it. I'd probably inherit WanderState and PatrolState from the same base (common logic) then use Wander as the default with a transition into Patrol only if we have Patrol waypoints set up... Not so sure about Idle state... :)
@martygusto30564 жыл бұрын
Thank you so much!!!!! I am working on making a simulation and this greatly helps with defining agent behaviors!
@CheeseChuckie5 жыл бұрын
You really need to mute your discord dude :P Otherwise great vid!
@TheDiggidee4 жыл бұрын
This just solved a problem I had with random movement I was pondering on all weekend
@zekiozdemir4203 жыл бұрын
thank you for this type of content, learning a lot
@scottev9545 жыл бұрын
Thanks for the video. The more in-depth explanations are great, really helps me learn better coding practices.
@Dxpress_5 жыл бұрын
25:42 I'm curious as to why you have a public setter for Target here when earlier in the video you mentioned how you made it's property use a private set because you don't want it to be set from outside the class.
@parthpandya0085 жыл бұрын
Hey, Many thanks for this tutorial. I have implemented this pattern in one of my project. It will be great if you can show a simple demo of ECS (hybrid) with Finite State Machine.
@JumpingCow5 жыл бұрын
Truly superb! Thank you. The detail is fantastic.
@imteajsaimun41344 жыл бұрын
Congrats 100k
@darkogotal2785 жыл бұрын
damn, discord is lighting up !
@Unity3dCollege5 жыл бұрын
lol ya this is what happens when i edit on my own! :) attempting to clean that up rq lol :)
@moishirand53245 жыл бұрын
Great, I've been waiting a long time for your posts on this topic.
@matthewjaffe35073 жыл бұрын
This video helped me a lot. For my purposes though I think it's actually better to make the states MonoBehaviours because I have a bunch of data that I want to serialize on each state and I don't want some other MonoBehaviour to have to serialize all that data and pass it in to the constructor of each state. Having a bunch of states thrown on a gameobject is a little annoying but I am putting all of them on a child gameobject of my AI called states so it is a bit more organized.
@vima9046 Жыл бұрын
Hello Jason! I have a couple of doubts. First i want to make sure that i didn't miss anything in this video for mine inattention but it looks like in the StateMachine class you are not using OnStateChanged event because anything has subscribed that event. Am i wrong? Second just to notify i dont't know why but in the downloadable project all scripts are missing! It contains only the old Drone.cs. Apart this i love your way to explain and i definetly would like to see more about state machines. Maybe even more complex AI behaviour in order to see the most of the potential of state machines! Great content and great teacher!
@pablo173495 жыл бұрын
Awesome video Jason!
@TheCrXe4 жыл бұрын
Flawless as always!
@zapposh5 жыл бұрын
The download contains your previous switching method from part 1. Will you also be making the state machine scripts from part 2 available to follow along? Would be of great help.
@fast_harmonic_psychedelic5 жыл бұрын
World Builder, referring to Command and Conquer Generals's world builder! I caught it.
@Alluvian5674 жыл бұрын
Very nice. Like this a lot. I think I would prefer an enum of some type for the states though, this is the kind of thing where I am CONSTANTLY forgetting what I named stuff.
@BatgioK5 жыл бұрын
Learned a lot, great video! Would like more deep dives into other topics. Maybe pathfinding?
@FitnessEat5 жыл бұрын
Great stuff. this channel always has top notch content. thanks 🤓
@synystersocks42754 жыл бұрын
thanks dude, lovely work ^^ this was very helpful :D
@Programm4r5 жыл бұрын
So I managed to make it so my states have modular conditions. The conditions are inherited objects, each have an abstract bool called "EvaluateCondition()." If the condition returns true, then the current state will transition to the next state. I can add as many conditions as I like before firing the actions. I can also set it so All, Any, or None of the conditions must be met before firing the action. I simply drag and drop the conditions into each state's condition properties, modify the conditions, and set the action. I'm thinking about adding this to a library name space and building it into Unity itself so my finite state machine acts as a real component.
@pimpace5 жыл бұрын
Awesome tut Mate! Can you point me in the right direction what coding pattern should I follow for strategy game? (space simulations, war between two fraction, battles between groups, etc) Is there a video you've already made for this maybe? Or maybe a tutorial for strategy games coding style/pattern/practice? Thanks in advice!
@joaniepepin49685 жыл бұрын
Thank God you did not use the animation state machine for the AI, this horrible practice makes me want to throw my monitor every times I see it shown in a 'tutorial'!
@ForgottenMovieGems4 жыл бұрын
Loved the video, but please turn off the notifications next time. It's incredibly distracting D:
@kidsteveee5 жыл бұрын
Right now ChaseState returns the typeof AttackState. If you were to implement something more data driven, how would you go about returning a more generic indicator so that one type of drone could dance after "catching" the target vs attacking? Would you return an OnCaughtState enum, and then add or depending on the drone? Or is there a better way to handle this using callbacks or something?
@jose_develaw90215 жыл бұрын
First of all, thank you for such a great work and congrats! Now one question. Maybe Im loosing the basics, but I dont get why you didnt use the Animator for building the state machines. Thanks in advance and please, keep bringing nice content!!
@alberto-martino5 жыл бұрын
Another great video! Thank you 👏🏼👏🏼
@danielsturton47934 жыл бұрын
Jason Weimann The download link seems to just have one file in still? I am in the process of building the scripts from the video but would love to see the originals to compare how I did :) Thanks
@johnlane4405 жыл бұрын
another great Video, learning so much, But quick Question, in WanderState script , line 85 private Transform CheckForAggro(), is there anything after line 104, since getting error not all code paths return a value. Tried to download project but only shows first AI in video for 2 bots
@JohnnyThousand6055 жыл бұрын
I've done my best to transpose the scripts from screen, got the system working and shared them via dropbox in an above comment =)
@In-N-Out3335 жыл бұрын
I see you changed your mind about using underscores lol
@Unity3dCollege5 жыл бұрын
I did :)
@JohnnyThousand6055 жыл бұрын
@@Unity3dCollege Hi Jason, cool video, not sure if you'll see this but can you have a look at the question I've posted up the top? My implementation is hanging at run time =\
@mohokhachai Жыл бұрын
The men who give me lightning
@trookie21793 жыл бұрын
Hey Jason, are you able to please edit the link to include the "good project"? Currently, only the "bad project" is linked Cheers for everything you do btw, I'm really enjoying your course, haven't had time to check the updates to it yet, but I'm keen as! :D
@maxim25o23 жыл бұрын
thats greate, please do more.
@blind_neighbourhoodNerd4 жыл бұрын
Wow this is awesome!!
@jakobjenbo87802 жыл бұрын
thank you for teaching os stuff :)
@SendarkWoW5 жыл бұрын
Hi Jason - Yet another great tutorial, as usual, and definitely helped me a lot in breaking my own monster FSM Update() class down into something a bit more manageable. One question: I noticed that you store variables related to each state within the state (for example, the _attackReadyTimer variable). How would you handle a case where you needed to show this information on the screen (e.g., an indicator showing how much time is left until the drone is ready to attack again?) One way to handle it would be to put the _attackReadyTimer variable into the Drone.cs class, but that could potentially lead to bloating the "main" class with variables specific to each state, thereby reintroducing a lot of the complexity you wanted to avoid in the first place.
@XRCADIA5 жыл бұрын
I watch your videos when taking a break between coding sessions, I really pref bit sizes videos that last no more than 10mins even if they are broken up into parts. For me, a 30min video is as painful as a script 800 lines long. I really appreciate the work you put into your content and realize you take a much more casual approach than channels like Infallible Code; Would really like to see a balance between the production overhead of that channel's videos and your more casual approach. For instance, I like how Infallible code breaks his content up into phases/parts but I don't like how there are a long intro and outro for each. I also appreciate the casual way you explain and fix things as they come up. It's not a simple request but might be worth it in the long run, noticed a trend of longer videos and made me a bit sad and happy at the same time when I could have just been happy and filled with anticipation for the next part/video.
@connorwendt86835 жыл бұрын
Awesome tutorial! I noticed that the download only contains the first scene you presented with the single "Drone" script not the full FSM example. Figured I'd check to see if it was a problem on my end or yours. Thanks!
@JohnnyThousand6055 жыл бұрын
No I got that too
@JohnnyThousand6055 жыл бұрын
I've posted the scripts above ;-)
@moha09615 жыл бұрын
Thank you for the great tutorial
@JohnnyThousand6055 жыл бұрын
Great video. I've been struggling with State Machines and saw it as 'too hard, I'll do it later' type of thing, but your example and descriptions are really good. Will you be uploading the final scripts to your website?
@JohnnyThousand6055 жыл бұрын
Here's my version of the scripts in the above video. +Unity3D College let me know if you want me to take this down ;-) I've changed some of the variable/class names to suit my purposes and also, as my game is 2D, I've modified the movement from transform.forward to transform.up. Without being rude, if you're looking at this level of scripting you should be able to figure what equates to what. That being said EnemyStateMachine, Drone and IndividualAISettings all go on your drone/enemy. I've also included a couple of new states that I need, Retreat and Escape. You'll probably need those in your project even if you're not using them or you'll have to modify the dictionary. Anyway, hope this helps. www.dropbox.com/sh/de47ghhhrd8r6a0/AAAfumYQYgCr5C6GPxKBTamwa?dl=0
@ravanin5 жыл бұрын
thank you for these!! I was looking for a more readable alternative than the video.
@JohnnyThousand6055 жыл бұрын
@@ravanin No problem man. =) They may need some tweaking because I'm making a 2D game ;-)
@kielblock5 жыл бұрын
Thanks a lot for these, was trying to implement the code as in the video, but never got it right, thanks again :-)
@JohnnyThousand6055 жыл бұрын
@@kielblock No probs, good luck =)
@CyberMan144 жыл бұрын
@@JohnnyThousand605 Thank you so much for your help, I really appreciate it :) Just wanted to ask how to implement the "NPCWeaponSystem" if I wanna shoot projectiles? Again thank you so much
@joshodom90465 жыл бұрын
There's a bit of a hidden bug: CurrentState = _availableStates.Values.First(); The issue with this, is a Dictionary doesn't have a guaranteed order.
@Unity3dCollege5 жыл бұрын
Great catch, I completely missed that! (anyone implementing this, take note and be more specific about the initial state when setting up) :)
@SealDev4 жыл бұрын
Helpful video! Thanks
@ravanin5 жыл бұрын
At various points in the video you mention using initialization/constructors for data caching to increase performance. Is there some recomended reading on this topic? I kinda wanna understand more about that.
@ZoidbergForPresident5 жыл бұрын
Interesting, but is it a good idea to have references to BaseState children types in each state? I guess, you could add a parameter to the constructor for a default switch over to type then? What do you think?
@danixadem2 жыл бұрын
You're doing an absolutely great job in explaining the stuff. I have a question, and will appreciate if you reply: what if we seperate data and logic of State classes; then keep the StateData instances unique for each drone game object (because each drone will be chasing different targets etc), and make state logic methods (which takes StateData and game object parametres) as static methods? Would static StateLogic classes provide some memory saving, compared to creating multiple instances for each drone object?
@safwatahmad7672 Жыл бұрын
Memory footprint of a method is generally quite small compared to data it operates on. thus memory saved here would likely be minimal.
@danixadem Жыл бұрын
@@safwatahmad7672 thanks mate
@longlevan925 жыл бұрын
Hey, Jason, Now your private field are using underscore prefix :D
@dalton-lima5 жыл бұрын
I am following the Raider's suggestions: * without underscore for a [SerializeField] private field * with underscore for a 'regular' private field
@longlevan925 жыл бұрын
that coding styles are good, I am following too :D
@Kreesty4 жыл бұрын
Honestly, this method is almost impossible for debugging. The more complex the AI gets, the harder it is to work with. Also if you need Coroutines and such, you're gonna have to create them in the main enemy script anyway, so there's not much reusability after that (that being the main goal of this method). It also makes a lot of scripts in your assets folder which gets messy. And you'll want to implement your own Start and OnDisable-like methods for each state if you want to really make this usable. At least that's my view on it, feel free to correct me if i'm wrong.
@Bramoldinho5 жыл бұрын
Just a question: Why would you use the GameSettings thing over something like a scriptable object? Is it faster? Or just a different way to essentially do the same thing?
@iguessimagamer30183 жыл бұрын
Love you sir ❤️
@DerClaudius3 жыл бұрын
Not bad... but I'd probably want configurable States, so I can reuse StateTypes multiple times per Machine.. So you can't use the type as the key of the state dictionary .. but something like this: {States.Idle, new WaitState(this, 3/*seconds*/)}, {States.Sleep, new WaitState(this, 30/*seconds*/)}, ...
@thienhai87684 жыл бұрын
how i can get material like that ground's ????
@liamhouston80015 жыл бұрын
Love you videos, have you ever considered making like a bigger game system process rundown/implementation and making it into a Udemy course or something. I'd buy it, just saying.
@hosseinse40792 жыл бұрын
LOVE YOU
@holoemiter5 жыл бұрын
Quick question, on Awake within the GameSettings class, should the else condition be removed? It appears we are destroying the instance if it happens to not be null but never replacing it
@chadm6777 Жыл бұрын
Hi @Unity3dCollege I'd like to see you offer a master class on GOAP AI
@autorotate18035 жыл бұрын
Is there a Behavior Tree Tutorial coming?? :D
@Ferenc-Racz3 жыл бұрын
Hi! What is I introduce the DamagedState and the drone get damaged by a drone, but the drone also do attack an other drone? How should I handle dris mixed state? (Literally how should I compose different states?)
@aoberthuer5 жыл бұрын
Great video!!
@containedhurricane4 жыл бұрын
How to show those "usages" and "overrides" information on top of each function in JetBrains Rider?
@DavidPatMathis815 жыл бұрын
This is a great video, but it would be infinitely easier to follow if you didn't include all the drone code and just showed changing of states at the press of a button.
@had1t1x855 жыл бұрын
"I'll do a little cut here... *clap clap*" xDD
@Unity3dCollege5 жыл бұрын
lol i think i figured out how to remove it finally without replacing the video :) should be gone soon (sorry for everyone who wanted to see me clapping like a goofball :)
@Tymon00005 жыл бұрын
That discord notifications :D
@ravanin5 жыл бұрын
About this type of state, im thinking of making a point'n'click state machine that has diferent interfaces like Iattackable, Iinteractable, Italkable, is it possible to make all these inculde an onclick type? my original idea was to use a string identifier and use that to switch to the correct state.
@NaruHinn5 жыл бұрын
Thank you for the great tutorial Can you please make a one for 2d platformer ai pathfinding
@tophatx45985 жыл бұрын
The download link doesn't seem to include all of the scripts :(
@JohnnyThousand6055 жыл бұрын
Yeah, I noticed that too. It's got the 'basic' scripts from the beginning of the tut but not the new & improved ones from the end =(
@taylorgriffin62695 жыл бұрын
@@JohnnyThousand605 write them yourself he goes in to great detail
@JohnnyThousand6055 жыл бұрын
@@taylorgriffin6269 I already have (a while ago) and have included a link to the scripts in another comment ;-)
@luckyducky78194 жыл бұрын
@@JohnnyThousand605 I can't seem to find your other comment. Can you link to the improved scripts? If not, its fine.
@JohnnyThousand6054 жыл бұрын
@@luckyducky7819 Not sure how to link to the specific comment but if you sort the comments by date my comment is about 8 months ago =)
@RaPL1235 жыл бұрын
Hi, how do you combine State Machine and Component approach? Because State Machine force you to write code into Tick methods. Or not?
@phobos2077_5 жыл бұрын
Also do you think FSM can handle simple RTS unit AI or I need full Behavior Trees for this purpose? What about FPS AI?
@benjamingerd47034 жыл бұрын
21:46 How would we subscribe to the OnStateChanged event from another script, given that neither the StateMachine class, nor the OnStateChanged event are static?
@beredan83214 жыл бұрын
I was wondering the same. He said he would talk about that but never did :> Considering there is only one state active anyway I use the method described in this older blog unity3d.college/2017/05/26/unity3d-design-patterns-state-basic-state-machine/ and just call OnStateEnter() and OnStateExit() which are virtual methods of BaseState.
@hiltonvarian47353 жыл бұрын
Love AI Make some More Complicated AI For Games Development . Could you Show Me How to Make a Game Characters Canvas in your Next Video. So When you Click on Your Game Character, In the Game A separate Canvas loads in with all your Charters Stats and Image of Your Characters and Allow you to change your Characters Stat according. To the Amount of Experance you Get would Appreciate it. Thanks for all the info that you have Put out There. It Really has Helped me a lot. I am Making a RPG game Myself. Unity is Great program to youse Love it a lot. It Makes Coding and Visual coding so much easier. On KZbin Could you do a talk on Character and Game Kinematics witch has to Do with C# Scripting a character. Thanks. James appreciate what you have Shown on KZbin. All your talks about C# are so Easy to understand. Thanks Again.
@josemodz47135 жыл бұрын
Please do a video explaining how to do a truck with trailer with hinge joints, I've been trying for a long time to do it and it's impossible for me...
@Irategamefan3 жыл бұрын
I have to ask why give us the Simple code when you talk about your complex one so to speak? I've been trying to fallow along with your AI and when I got stuck and went to read it, and all that's in the "Download" link was the simple code. Is there something I'm missing or what?