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; }
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
@@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
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 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.
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
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 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.
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.
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
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
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?
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
<a href="#" class="seekto" data-time="181">3:01</a> 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) )
@@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!
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.
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
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.
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 <a href="#" class="seekto" data-time="706">11:46</a> ?
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-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
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 <a href="#" class="seekto" data-time="1519">25:19</a> please i need help
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.
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
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.
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
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
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
@@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(); } }
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