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.
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!!!
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) :)
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!
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.
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 :)
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.
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!
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.
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.
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.
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.
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
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... :)
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.
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.
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.
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.
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!
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.
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?
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 :)
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
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.
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?
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?
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
@@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
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
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!
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!!
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
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.
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!
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
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'!
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.
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?
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?
@@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 =\
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?
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.
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?)
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.
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.
OnStateChanged?.Invoke(CurrentState); This will only invoke OnStateChanged if it exists, right? I never knew you could do this with the conditional operator. Where do you learn this stuff?
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*/)}, ...
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.
I generally don't have enough time to take on more work, but I can definitely recommend a few great developers I'd hire personally if you wanna send over details. :)
Thought I was getting discord notifications the entire video. Really liked the video, trying to learn as much as I can about AI.
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.
@@Grynjolf I'm sure it was a minor oversight is all.
I was still thinking that it was discord going crazy until I read your comment XD
I REALLY appreciate this video. I have been one of those "million if-statement" people for far too long.
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!!!
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
Would love to see more in-depth videos on this subject and the more advanced stuff. Great job on the video!
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) :)
The source code file on the website only contains the bad version, not the good one.
Great video!
True, and that is really annoying. Why offer the source at all if its only going to be the "bad" version?
1:02 you god damn tease, I wanted to see that fight.
Great tutorial too.
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!
Very complicated Topic, but I can tell already that this will be substantial to learn
Another advantage of using Type vs enum is that the default Dictionary hash comparer for enums casts to object, causing boxing everywhere.
Amazing! Learn more in this video than I did in any of my college classes about AI and Unity.
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.
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 :)
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.
thanks for making this kind of content.
explaining each label as you go is great.
excellent video, as usual. far *far* better than the official unity state machine tutorials.
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!
Hi Jason, amazing tutorial.
I'll have to gripe and say that the discord sounds are kinda distracting here tho.
These videos are so good, it's insane that they're available for free! Thanks!
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.
This just solved a problem I had with random movement I was pondering on all weekend
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.
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 ???
This video very Perfect and Important for Juniour. Big thanks from Russia.
Great, I've been waiting a long time for your posts on this topic.
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.
Thanks for the video. The more in-depth explanations are great, really helps me learn better coding practices.
Truly superb! Thank you. The detail is fantastic.
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.
damn, discord is lighting up !
lol ya this is what happens when i edit on my own! :) attempting to clean that up rq lol :)
Awesome video Jason!
Thank you so much!!!!! I am working on making a simulation and this greatly helps with defining agent behaviors!
Congrats 100k
World Builder, referring to Command and Conquer Generals's world builder! I caught it.
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
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... :)
Learned a lot, great video! Would like more deep dives into other topics. Maybe pathfinding?
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.
Great stuff. this channel always has top notch content. thanks 🤓
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.
thank you for this type of content, learning a lot
Flawless as always!
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.
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.
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!
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.
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?
"I'll do a little cut here... *clap clap*" xDD
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 :)
thanks dude, lovely work ^^ this was very helpful :D
Another great video! Thank you 👏🏼👏🏼
Wow this is awesome!!
The men who give me lightning
You really need to mute your discord dude :P Otherwise great vid!
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
I've done my best to transpose the scripts from screen, got the system working and shared them via dropbox in an above comment =)
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.
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?
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?
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
thank you for these!! I was looking for a more readable alternative than the video.
@@ravanin No problem man. =) They may need some tweaking because I'm making a 2D game ;-)
Thanks a lot for these, was trying to implement the code as in the video, but never got it right, thanks again :-)
@@kielblock No probs, good luck =)
@@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
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
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!
No I got that too
I've posted the scripts above ;-)
thats greate, please do more.
Helpful video! Thanks
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!!
Thank you for the great tutorial
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.
Great catch, I completely missed that! (anyone implementing this, take note and be more specific about the initial state when setting up) :)
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
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.
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!
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
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'!
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.
Is there a Behavior Tree Tutorial coming?? :D
thank you for teaching os stuff :)
Loved the video, but please turn off the notifications next time. It's incredibly distracting D:
That discord notifications :D
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?
Hi, how do you combine State Machine and Component approach? Because State Machine force you to write code into Tick methods. Or not?
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?
Memory footprint of a method is generally quite small compared to data it operates on. thus memory saved here would likely be minimal.
@@safwatahmad7672 thanks mate
Hi @Unity3dCollege I'd like to see you offer a master class on GOAP AI
Also do you think FSM can handle simple RTS unit AI or I need full Behavior Trees for this purpose? What about FPS AI?
I see you changed your mind about using underscores lol
I did :)
@@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 =\
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?
Great video!!
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.
Hey, Jason,
Now your private field are using underscore prefix :D
I am following the Raider's suggestions:
* without underscore for a [SerializeField] private field
* with underscore for a 'regular' private field
that coding styles are good, I am following too :D
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?)
Love you sir ❤️
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...
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.
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.
OnStateChanged?.Invoke(CurrentState);
This will only invoke OnStateChanged if it exists, right? I never knew you could do this with the conditional operator. Where do you learn this stuff?
Thank you for the great tutorial
Can you please make a one for 2d platformer ai pathfinding
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*/)},
...
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.
How to show those "usages" and "overrides" information on top of each function in JetBrains Rider?
Love your tutorials! Do you do freelance work? We really need help on our project.
I generally don't have enough time to take on more work, but I can definitely recommend a few great developers I'd hire personally if you wanna send over details. :)
@@Unity3dCollege thank you very much! I would love that. We are working on a title called INTERSTELLAR PRIME and need help with C# in general.
What final project, where is this final project? Is it the one in your $1500 dollar class?
Is there a way I can do something similar but for 2D? Mostly having enemies jump on top of platforms?
The download link doesn't seem to include all of the scripts :(
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 =(
@@JohnnyThousand605 write them yourself he goes in to great detail
@@taylorgriffin6269 I already have (a while ago) and have included a link to the scripts in another comment ;-)
@@JohnnyThousand605 I can't seem to find your other comment. Can you link to the improved scripts? If not, its fine.
@@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 =)
Hey thanks for teaching us! How to I get my IDE to say "Set By Unity" next to Serialized fields?