I realised that I had modified the StateMachine class and added a GetGizmoColor that I don't show in the video. This to make it easier to debug, so do as you please. Here is the code that would go into StateMachine.cs: public Color GetGizmoColor() { if (currentState != null) { return currentState.GizmoColor(); } return Color.grey; }
@REALHARIBO10 ай бұрын
please help NullReferenceException: Object reference not set to an instance of an object EnemyState_RunToCover.OnEnter () (at Assets/Enemy/Enemy Scripts/EnemyState_RunToCover.cs:20) StateMachine.SetState (IState state) (at Assets/Enemy/Enemy Scripts/StateMachine.cs:36) EnemyBrainV2.Start () (at Assets/Enemy/Enemy Scripts/EnemyBrainV2.cs:32) ive followed yout tutorial till the 27 min mark and have ebeen stuck sorting out errors for about 8 hours now finnaly down to 1 and i cant understand as to why im getting this problem i have done everything you have mentioned but yet still no progress
@this-is-gamedev10 ай бұрын
@@REALHARIBO the issue here is a reference is null, so either a variables os not initialised or you did not link all the things in the editor. My guess from your error pasted, is the CoverArea is null but could be something else
@xaloit89399 ай бұрын
You need to drag CoverArea Script to 'Covers' GameObject in hierarchy@@REALHARIBO
@rock8science5 ай бұрын
@@REALHARIBO I Guess stateMachine = new StateMachine(); is to be initialized in RunToCover State
@cmvr1003Ай бұрын
As someone who's been self teaching game dev as a hobby it's really refreshing to find content that focuses on not just how to achieve a result, or implement something in the most basic sense, but instead focus on how to achieve a result that's good, or implement a feature with polish. I'm pretty sure i've learnt most of the basic implementation methods, so thank you so much for taking the time to create such high quality videos that are for a more intermediate/advanced audience.
@this-is-gamedevАй бұрын
Hey thanks! Appreciate it!
@mook_10 Жыл бұрын
this is exactly what i was looking for. please please please make more. SO many tutorials on here covering the "stupid" AIs but really nothing covering enemies who even pretend to have a sense of strategy
@this-is-gamedev Жыл бұрын
Thanks! That’s the plan :D
@l.halawani4 ай бұрын
This is a really high quality content, not only is everything explained really well theoretically and demonstrated practically, but also you leave us with specific keywords to find out more where relevant. Feels like a paid course, and a good one on that note.
@armandopaez8882 Жыл бұрын
Definitely worth the length of the video. Your way of explaining is simply wonderful. It's almost like going to school. Thanks, master!
@this-is-gamedev Жыл бұрын
Thanks Appreciate it! 🤓
@halivudestevez22 ай бұрын
better than school :)
@gun8737 Жыл бұрын
you are not a live saver, you are the embodiment of divine intervention. i was looking to pick up unity to develop a payday 2 type game, where the ai bassicaly just throws itself at the player. you cant even imagine how many tutorials ive watched to try and find what i need. thanks so much man
@this-is-gamedev Жыл бұрын
You’re welcome :D I am happy it’s helpful :D
@senorcarlito-611924 күн бұрын
Thank you for the wonderful explanation, as someone who is eager to get into AI, this is extremely helpful.
@this-is-gamedev15 күн бұрын
Awesome! There is a lot to learn in this subject! Happy if this hells you start!
@this-is-gamedev Жыл бұрын
The video became a bit long. I usually aim for 10 minutes. Anyway, I hope you enjoy and let me know what you like and what you hate. I have many more tutorials in the pipeline :D
@arisaek7764 Жыл бұрын
Thanks for the class
@Koniving Жыл бұрын
I was wondering, without access to editable scripts or ability to use new scripts... Is there any way we can use ultimate events to make them seem smarter or exhibit new behaviors?
@this-is-gamedev Жыл бұрын
Event system can help yes, but you will need to write some code, at least to raise the events at the right moment.
@Koniving Жыл бұрын
@@this-is-gamedev Alright. Thank you. The reason I was asking is I'm trying to get some desirable behaviors out of the AI in Bonelab, but those developers thought it was a great idea to not permit their edited SDK for unity and their game to use scripts that weren't included in the base game, so most of us are stuck trying to force ult events to do things that it wasn't meant to do. Technically we do have their base scripts, but no access to see what is inside of them.
@ahmaddalao7 ай бұрын
I just want to say thank you. It is kind of advanced topic and not for my beginner level but I didn't see anyone explain it in your way or event hight light some of these advanced topics. Even if I didn't understand everything I still find it useful and helpful.
@this-is-gamedev7 ай бұрын
I happy you find it useful! Give it some time and try to use it in a simple way like just 2-3 states to get started.
@travisgarrisonihdlive Жыл бұрын
Great tutorial but one thing I did find an issue with after adding more then one ai you have to do a check if the cover is taken or not or the ai will trip out trying to get in the same position as another. After adding a check for this it worked perfectly.
@this-is-gamedev Жыл бұрын
Yes, with more than one, you probably want a manager / commander that will tell where each agent should go. That can then also be a statemachine with different strategies etc based on the player’s actions :D
@user-fz4er7yi9y5 ай бұрын
Just an FYI. NavMesh 'Helping an enemy find its way to its destination without running into anything' is using an A* algorithm.... which is actually one of the first Ai algorithms people learn.
@l.halawani4 ай бұрын
It's more ML than AI, not all ML is AI
@user-cs5hv7rb8n5 ай бұрын
프로젝트에서 적을 구현하는 것에 큰 도움이 됐습니다. 감사합니다.
@kalpolproductions8558 Жыл бұрын
Fuck you for being late to post this on the internet 😂. No cap this is *THE* thing i was looking for 1.5+ years, this tutorial is a hidden gem ❤. you earned a subscriber
@this-is-gamedev Жыл бұрын
Haha, that’s awesome. I am happy it’s helpful :D
@ShyVortexYT2 ай бұрын
I've followed through everything but I run into an issue at the very end, it works but the target's position isn't updated every tick like one would expect. If I move around the agent keeps shooting at my initial position
@DionteHelm9 ай бұрын
This was really informative. Thanks man.
@this-is-gamedev9 ай бұрын
Thanks!
@am-apps-games Жыл бұрын
Very well done! Thank you
@this-is-gamedev Жыл бұрын
Thanks! I am glad you like it!
@Ranger874424 күн бұрын
Uhhh, He called me dedicated... I'm touched🥺!
@OrdeBaruMilenial5 ай бұрын
Rockstar must hire this guys.. for the next evolve game think..
@venkatswaraj3054 Жыл бұрын
Thank you. This is what I am looking for.
@this-is-gamedev Жыл бұрын
Nice! Happy it’s helpful :)
@sklintergames66629 ай бұрын
Great tutorial , thanks 🎉
@this-is-gamedev9 ай бұрын
Thanks! 🙏
@thebestcelep6358 Жыл бұрын
High quality!
@androvictrayo-dy7eh Жыл бұрын
This is a fantastic tutorial
@this-is-gamedev Жыл бұрын
Thanks! Happy you like it!
@squirrelzar10 ай бұрын
Overall a useful tutorial- but it would have been better to see it more compartmentalized. Adding all the animations and such in complicates what was the interesting part of the video which is the enemies behavior.
@this-is-gamedev10 ай бұрын
Thanks! That’s true. I’ll see what I can do. Could make another video showing different use cases and just focusing the FSM
@squirrelzar10 ай бұрын
@@this-is-gamedev for sure! I mean no shade, I don’t have the courage to post videos so either way - it’s your style! I’ve been a dev for a while now but newer to C# and Unity - and I’ve always personally preferred highly specific videos as gluing the pieces together usually isn’t too bad once you know how the individual pieces work. But that’s just me and I know I don’t speak for everyone. Was a very useful video overall
@this-is-gamedev10 ай бұрын
@@squirrelzarNo worries. I am listening to all feedback and ideas. :D
@technicalm.t.b52514 ай бұрын
Sir you Dummie character is not showing in scene and also on demo and also when pick it up from models to in heirarchy still just showing colliders
@user-dc2qk9hh3x10 ай бұрын
12:03 - genius mem
@muhammadzubairirshad67245 ай бұрын
Just Amazing
@user-wk5hr1vx1gАй бұрын
3:01 if it blue it good got me so hard 😂😂😂😂 ( btw i really liked the way that he speaks and it is understandable course also he's really cute (i am not gay just being honest) )
@everythingcouldbesimplify818 Жыл бұрын
Learn Animancer and you will never want to look back to animator ever again
@this-is-gamedev Жыл бұрын
I’ll take a look. Thanks!
@LagowiecDev Жыл бұрын
Thanks for making tutorial for noob like me! :D
@flixlcookie82229 ай бұрын
Hey! Great Video but when using this in my schoolprojekt i've run into some troubles. In my scene everything works just fine but as soon as i put the enemys into the main scene they move around for no reason at all. Even when put in the coverstate from the beginnig on they start spinning and moveing around the map. Is there any way you could help me out with this problem?
@this-is-gamedev9 ай бұрын
Hi, thanks! Difficult to say what is the cause, is it maybe a loose rigidbody?
@President_PunchLines5 ай бұрын
hey man great tutorial i just ran into this error that my trail render is visible but they tend to go downward rather than following the ray they tend to go to the bottom of the player
@this-is-gamedev5 ай бұрын
Thanks! Mmm, this might be some pivot issue
@President_PunchLines5 ай бұрын
@@this-is-gamedevthanks man I already solved it it was a code issue
@technicalm.t.b52514 ай бұрын
my enemy not following my player there are no errors on console why it just happened to me :"(( i checked everything is correct i have also added player in enemy target and my player has collider so now what should i do, i have created a empty game object in hierarchy and added navmeshsurface component in and i baked and after that everything just fine just like your and i got a problem after backed navmesh detect my player as a obsticles and made border around my player just like other object and i solve by adding layer mask as player and navmesh ignore that it fixed bu still not following enemy my player at 11:46 ?
@user-ur3cw2bf9s4 ай бұрын
Amazing tutorial i just ran into a problem my enemy is reloading but the ducking animation is not playing along with the reloading animation
@this-is-gamedev4 ай бұрын
Thanks! To play both, you need to split them on 2 animation layers and setup the avatar to mask the bones for the second layer
@havoc-blazeАй бұрын
The word you're looking for is "Navigable".
@President_PunchLines5 ай бұрын
Hey man I ran into this new issue, the code error says there is nothing called func for statemachine and also I am getting a new error it says that statemachine don't have get gizmos color function, how can I solve it
@this-is-gamedev4 ай бұрын
The gizmo thing can be added, it was an example. The code is in the pinned comment.
@President_PunchLines4 ай бұрын
Thanks
@Linguin_4 ай бұрын
Does it still work? I can only bak the Mesh in "Navigation Obsolete "
@this-is-gamedev4 ай бұрын
Yes, just the AI navigation is now a unity package. But its API is the same.
@Linguin_4 ай бұрын
Ok thx
@praisethesun261210 ай бұрын
Thanks!
@this-is-gamedev10 ай бұрын
You’re welcome :D
@Abdullahkhan-lk5zl8 ай бұрын
Hey man, GREAT Video. Where can i get your code.
@ruisilva598 ай бұрын
I don't know what I did but I'm having problems with the project, from EnemyBrain_Smart to EnemyState_Delay, one tells me it's StateMachine and the other is IState, I really needed a little help starts in 25:19 please i need help
@this-is-gamedev8 ай бұрын
EnemyBrain_Smart has the state machine inside. You can’t use a transition -> you have to ->
@vladaslittleparadise4402 Жыл бұрын
is there a way to add a "patrol function"? i tried everything but it eighter ignores it or the code breaks
@this-is-gamedev Жыл бұрын
Yes, you have to create a new script that implements IState and then where the state machine is create, you create a new instance of your state and make sure it is either the starting state or you transition to that state.
@iliagusarov86629 ай бұрын
What should I do, if I have a big open world? Or I can do the same stuff?
@this-is-gamedev9 ай бұрын
Usually, the enemies act local to a part of the world. You can’t really have tons of enemies active at ones. Or you can. You might have to look into ECS maybe or other ways to manage open world games. But state machine can be used for everything, yes :D
@user-dw5ku8bq3z Жыл бұрын
What is your version of Unity? I am using Unity version (2022, personal) I don't have AI please help me
@poonamagrawal447211 ай бұрын
On unity 2022.2+ you need to install AI navigation package from the package manager.
@6Abdellah9 Жыл бұрын
thx so much, ur a life saver im using this for a school project, however I came across a little bug start reload gets called but it never reloads any idea why and do u have the scripts anywhere so I can better see the difference
@this-is-gamedev Жыл бұрын
It might be that the Reload layer on the animator does not have the weight to 1. Or that the transition is not well configured.
@6Abdellah9 Жыл бұрын
@@this-is-gamedev yes that was it thx
@LION303200Ай бұрын
Great Video But, that yellow background makes people blind... 😵😵😵😵
@this-is-gamedevАй бұрын
Thanks. First time I get this feedback! It’s a fair point :D
@RSilva-ic8qv10 ай бұрын
hello , can you help me ? i cant find the link for the bullet tracer ...
@this-is-gamedev10 ай бұрын
Search “liamacademy bullet” it’s the first hit.
@RSilva-ic8qv7 ай бұрын
ty:) @@this-is-gamedev
@afrodidcraft Жыл бұрын
merci frerooo
@this-is-gamedev Жыл бұрын
De rien 😉
@user-dw5ku8bq3z Жыл бұрын
Very good but I can't add nav mesh because I haven't AI in my Unity What's your version of Unity Is it possible with version (2022 ,personal)?
@this-is-gamedev Жыл бұрын
I missed that news with 2022. It seems you have to installed from the package manager. It should be called “AI Navigation”
@user-dw5ku8bq3z Жыл бұрын
@@this-is-gamedev Thank you so much..❤ Im from Iran, and there is no one to ask him, and I get lost
@VOR4DORS_RAVEN Жыл бұрын
would any of this work/apply in a VRChat world?
@this-is-gamedev Жыл бұрын
If you can write code, you can write state machines
@cosmotect5 ай бұрын
Smarter every day reference?)
@this-is-gamedev5 ай бұрын
If that’s the case, not done on purpose 😌
@faded87 Жыл бұрын
Will this work with multiplayer like photon
@this-is-gamedev Жыл бұрын
Yes. But I am not that familiar with photon, so you have to just intergrate it with whatever photon uses to sync data across clients
@follyscrolly1345 Жыл бұрын
onto my 30th time watching the vid done everything but for some reason the states stop switching after going grey 😥
@this-is-gamedev Жыл бұрын
Mmmm, add some Debug.Log to be sure that 1) all states enter and exit correctly 2) monitor the values that are used to transition from 1 state to another
@follyscrolly1345 Жыл бұрын
@@this-is-gamedev heres my enemy cover script i think it is the main problem as i am getting an error that The local function 'Any' is declared but never used using System; using System.Collections.Generic; using UnityEngine; public class EnemyCover : IState { private EnemyReferences enemyReferences; private StateMachine stateMachine; public EnemyCover(EnemyReferences enemyReferences) { this.enemyReferences = enemyReferences; stateMachine = new StateMachine(); // STATES var enemyShoot = new EnemyShootState(enemyReferences); var enemyDelay = new Delay(1f); var enemyReload = new EnemyReloadState(enemyReferences); // TRANSITIONS At(enemyShoot, enemyReload, () => enemyReferences.shooter.ShouldReload()); At(enemyReload, enemyDelay, () => !enemyReferences.shooter.ShouldReload()); At(enemyDelay, enemyShoot, () => enemyDelay.IsDone()); // STARTSTATE stateMachine.SetState(enemyShoot); // FUNCTIONS & CONDITIONS void At(IState from, IState to, Func condition) => stateMachine.AddTransition(from, to, condition); void Any(IState to, Func condition) => stateMachine.AddAnyTransition(to, condition); } public void OnEnter() { enemyReferences.animator.SetBool("combat", true); } public void OnExit() { enemyReferences.animator.SetBool("combat", false); } public void Tick() { stateMachine.Tick(); } public Color GizmoColor() { return stateMachine.GetGizmoColor(); } }
@follyscrolly1345 Жыл бұрын
@@this-is-gamedev please help bro
@this-is-gamedev Жыл бұрын
Looks correct. Are you sure the animator is correctly setup? That all parameters match. lowercase and uppercase is important
@follyscrolly1345 Жыл бұрын
@@this-is-gamedev yeah it was that i forgot to actually start the reload function when the ammo was empty but thx
@Damian_h8 ай бұрын
bro do u know how to implement G.O.A.P? for enemy or bosses
@this-is-gamedev8 ай бұрын
Didn’t touch GOAP, yet. It’s a lot of work and ideally you will need some custom tools to debug everything, since enemies are a kind of “free”
@Damian_h8 ай бұрын
@@this-is-gamedev Jesus christ man im just an artist trying to survive programming subjects but the things they ask sometimes are ridiculously difficult. BTW Great video super interesting!
@this-is-gamedev8 ай бұрын
Oh wow. Check LliamAcademy, he has a good series on GOAP
@Damian_h8 ай бұрын
@@this-is-gamedev Will do asap bro thanks a lot.
@reinhpash Жыл бұрын
dunno why but my transitions not work
@this-is-gamedev Жыл бұрын
Check the conditions and check that when you call methods on the animator that the strings match 1 to 1. It is case sensitive
@reinhpash Жыл бұрын
@@this-is-gamedev thanks for help u got one sub from me :)