Dude, what you do on youtube.. teaches people for free is just too much...,I'm very grateful to you, all my skills with unity and even learning English I'm getting into these classes, thank you.
If anyone has a set destination error, follow these steps 1. Select your ground and check static on the top right corner of the inspector. 2. Keep your ground selected, and go to the Navigation tab. (Window>AI>Navigation) Then you should see a tab in Navigation called bake. Select it, and click bake on the bottom. 3. Play test your game. It might work it might not. If it doesn't work, follow the next steps. If it does, you are good to go. 4. Move your enemy ai closer to the ground. 5. Play test your game again. It might work it might not. If it doesn't work, follow the next steps. If it does, you are good to go. 6. If your enemy gets stuck in the ground, select your enemy, and in the NavMeshAgent, play around with the base offset. You should see a cylinder. Make that cylinder touch the ground.
mate you are simply the best everytime i watch a tutorial elsewhere they jugle theyre scripts between episodes so that you have to watch every of theyre episodes but you do a complete video where you explain everything regarding one topic. i love your videos :) you are the best mate keep up the good work you made my day
7:32 The type or namespace name 'Interactable' could not be found (are you missing a using directive or an assembly reference?), I am getting this error
im getting an error: "SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.AI.NavMeshAgent:SetDestination(Vector3) EnemyController:Update() (at Assets/EnemyController.cs:25)
It's the map you use to move you're character You can locate it on you're Scene Sorry guys i'm late :o The method I gave is not universal but maybe it's work for you
The type or namespace name 'CharacterCombat' could not be found (are you missing a using directive or an assembly reference?) The type or namespace name 'CharacterCombat' could not be found (are you missing a using directive or an assembly reference?) please help
just discovered this series now im trying to integrate the parts of these scripts with your tower defense tutorial series to make a 3d kingdom rush type of game, thank a lot for these vids. btw im so new to game development so im really grateful
Not to sure why but my target location isnt updated after start. So the enemy will move to the initial player position but not follow the player after the player moves (or if the player is out of the lookRadius). I followed the video, any suggestions?
if anyone else had the thing that said "SetDestination can only be called on an active agent that is on a NavMesh." I set the ground as static went to window- AI- Navigation then bakedif that helps
6:45 why slerp, and not lerp? i know that slerp makes spherical path to the target, but i made 2 ai agents, and put lerp in one and slerp in the other, and saw no difference, it worked nice for me, but i just want to know why, ty Brackeys
The type or namespace name 'Interactable' could not be found (are you missing a using directive or an assembly reference?) The type or namespace name 'Interactable' could not be found (are you missing a using directive or an assembly reference?) how can i fix it §?
Assets\scripts\Enemy.cs(5,22): error CS0246: The type or namespace name 'Interactable' could not be found (are you missing a using directive or an assembly reference?) what am i doing wrong pls answer this time
I am getting an error "Set Destination" can only be called on an active agent that has been placed on the NavMesh. UnityEngine.AI.NavMesh:SetDestination(Vector3). How to fix this and what is the mistake? Please help me.
I love this series. I don't know how far you want to take it, but topics I would love to see covered are amongst others: - changing scene without losing the inventory and stats etc. - saving and loading the game (maybe even with savepoints like in some JRPGs like Final Fantasy) - trading with NPCs or maybe even have dialogue with different options or even different outcomes - a simple system to level up and customizing stats with each level up - day/night cycle or weather effects I know a lot of these things are probably covered in other videos or you could read up on those topics somewhere online etc. but it would be fun to learn these things in the context of this little RPG series :) Of course this list could be endlessly long haha there's so much you could do! Anyways, keep up the good work :)
i keep getting this error "SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.AI.NavMeshAgent:SetDestination(Vector3) EnemyController:Update() (at Assets/EnemyController.cs:25)
You go to Window>AI>Navigation and once you have the navigation window open, click on the objects that you want to bake a NavMesh and in the bake tab click bake. Hope this helps!
Can someone help me? I have a problem with the nav mesh agent. I checked my script to be like brackeys' but it don't work. Unity says: SetDestination can only be called on an active agent that has been placed on a NavMesh. UnityEngine.AI.NavMeshAgent:SetDestination(Vector3)
sumerian ozzyz i fixed it. Make a group for the floor and go to window then navigation and its gonna open a bonus window next to the inspector. Then go to objects select mesh renderer and select the floor group(the y axis should be the same) then do this group static - yes for all children and then go back to navigation and bake the floor. Ask if you havent understand
have you dragged it into the inspector (when you create for example public GameObject player you need to drag the object - the player in the inspector)
Great tutorial as always! Easy to follow and really helped me out except for the fact that it doesn't work. I keep getting this error: Failed to create agent because it is not close enough to the NavMesh. Then whenever I get in range i get this error : "SetDestination" can only be called on an active agent that has been placed on a NavMesh. Anybody know what to do? I already baked the floor and stuff.
"SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.AI.NavMeshAgent:SetDestination(Vector3) EnemyController:Update() (at Assets/EnemyController.cs:27) can someone help me?
@@monkeyballs188 How i do that? In my Console apears this : "SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.AI.NavMeshAgent:SetDestination(Vector3) AgarrameSiPodes:Update() (at Assets/AgarrameSiPodes.cs:38) Pleas answer the soon as you can :c
@@mateodemicheli2420 Go to the windows tab at the top and find the navigation panel(should be in the AI section). Then click over to the bake tab and bake.
Can someone help. I keep getting this error: "Failed to create agent because there is no valid NavMesh". I've tried baking it but it still doesn't work! What is wrong???????????
hello, to make this work you need to set your ground to static(and your obstacles) then bake turn off Auto lightning if still doesn't and set your obstacles in the scene as "Navmesh Obstacles".
any ideea why my enemy is coming exactly into me , i mean after he reaches me he stays exactly where i am ( on top of me ) and i cant move . If i put a rigidbody on him , after he reaches me and i attack him or he just touches me he go away and never come back xD . Any help pls ?
Before brackeys tutorial was a little bit boring like the intro was just "today we are going to make the A.I." Bur now we have a mlittle joke in almost every intro Brackeys really changed in a good way
When did the altar object get added? At the start of this video the altar area / ritual area with torches has a platform on it now? Did I miss something?
@@gaddgames you go to the windows tab then head to ai then navigation. go to objects then click on your ground then press navigation static. then go back to the bake tab and hit bake. hope that helps
Hey there! I'm making AI for a school project. I'm not interested in making the whole RPG, just the AI part. Can anyone tell me why i get an error when i change the public class of the enemy to Interact? I assume it because it was created in a previous episode, but i'm not great with Unity yet so i have no clue how to make that.
@@juniorasare9769 Hey I dont understand this part " open the navigation window, select the floor, go on object and turn on navigation static" could you help me out pls
@@overwhelming9212 any obstacles or walls you have set it as "Navigation Static" on the inspector (top right corner). In Unity, NavMesh generation is handled from the Navigation window (menu: Window > AI > Navigation). Do the same with the Enemy AI object. I think. Try it and let me know if it worked!
Hello. Is it somehow possible to handle rotation on raycast hit as you did for FaceTarget() method? Its buggy and not working as same as clicking on object once facing the target (handling rotation without navmesh agent)
I was wondering if anyone could help me on my problem. I have typed in all of the code up to 5:35 and I attempted to run the code and I got this error: "Failed to create agent because there is no valid NavMesh" My player has a NavMeshAgent component on it, so I am not sure what I am doing wrong. Thanks.
I’m getting the error “MissingComponentException: There is no ‘NavMeshAgent’ attached you the “Enemy” game object, but script is trying to access it.” Any way to fix this?
I have one problem and it's : NullReferenceException: Object reference not set to an instance of an object EnemyController.Update () (at Assets/Scripts/Controllers/EnemyController.cs:22) can someone help me please ?
I tried to attempt this but form some reason I keep getting two errors: NullReferenceException: Object reference not set to an instance of an object EnemyController.Start () (at Assets/Scripts/Controllers/EnemyController.cs:15) NullReferenceException: Object reference not set to an instance of an object EnemyController.Update () (at Assets/Scripts/Controllers/EnemyController.cs:22) Anybody have any idea whats wrong?
Ok, apparently I had a few errors. My transform for my graphics was offset, and my capsule collider was to tall/wide. Seems to be operating just fine now.
Can someone help me? i have the same coding as Brackeys has for the enemy AI but it doesn't work. Like it doesn't give me any errors at all but the enemy doesn't move
i did a project but when i am going to red gizmos unity give me this error : " MissingComponentException: There is no 'NavMeshAgent' attached to the "Enemy" game object, but a script is trying to access it. You probably need to add a NavMeshAgent to the game object "Enemy". Or your script needs to check if the component is attached before using it. UnityEngine.AI.NavMeshAgent.SetDestination (UnityEngine.Vector3 target) (at C:/buildslave/unity/build/artifacts/generated/bindings_old/common/AI/NavMeshAgentBindings.gen.cs:35) Enemy.Update () (at Assets/Codes/Enemy.cs:20) " Could you help me guys
I followed this tutorial to the T, same scripts exactly but the cube would not move. I took off the rigid body, and it works perfect now. Anyone with same problem , try messing with the rigid body
Thank you for your videos! But i encounter some problem. It is working. but when i put a new enemy not the first one. there's an error "SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.AI.NavMeshAgent:SetDestination(Vector3) enemyController:Update() (at Assets/enemyController.cs:35) It is the same as the first enemy it have rigidbody, navmesh agent and the scripts that works in the first enemy . somebody help me :3
I have a script that can help you!!! this script using UnityEngine; using UnityStandardAssets.Characters.FirstPerson; using UnityEngine.AI; public class AiExample : MonoBehaviour { public enum WanderType { Random, Waypoint }; public float damage = 16f; public GameObject fpsc; public WanderType wanderType = WanderType.Random; public float wanderSpeed = 4f; public float chaseSpeed = 7f; public float fov = 120f; private bool isAware = false; private Vector3 wanderPoint; public Transform[] waypoints; private bool Attacking = false; public GameObject radgollZombie; public GameObject NPC; [SerializeField] private float health = 100f; public float viewDistance = 10f; private NavMeshAgent agent; private Renderer renderer; public float wanderRadius = 7f; private int wayPointIndex = 0; private Animator anim; public void Start() { agent = GetComponent(); renderer = GetComponent(); wanderPoint = RandomWanderPoint(); anim = GetComponentInChildren(); } public void Update() {
if (isAware) { agent.SetDestination(fpsc.transform.position); anim.SetBool("Aware", true); agent.speed = chaseSpeed; //renderer.material.color = Color.red; } else { SearchForPlayer(); wander(); anim.SetBool("Aware", false); agent.speed = wanderSpeed; //renderer.material.color = Color.green; } } private void OnTriggerEnter(Collider other) { if (hit.GetComponent()) { GetComponent().ApplyDamage(damage); } Attacking = true; anim.SetTrigger("Attack"); } private void OnTriggerExit(Collider other) { Attacking = false; } public void SearchForPlayer() { if (Vector3.Angle(Vector3.forward, transform.InverseTransformPoint(fpsc.transform.position)) < fov / 2f) { if (Vector3.Distance(fpsc.transform.position, transform.position) < viewDistance) { RaycastHit hit; if (Physics.Linecast(transform.position, fpsc.transform.position, out hit, -1)) { if (hit.transform.CompareTag("Player")) { OnAware(); } } } } } public void OnAware() { isAware = true; } public void wander() { if (wanderType == WanderType.Random) { if (Vector3.Distance(transform.position, wanderPoint) < 2.5f) { wanderPoint = RandomWanderPoint(); } else { agent.SetDestination(wanderPoint); } } else { if (waypoints.Length >= 2) { if (Vector3.Distance(waypoints[wayPointIndex].position, transform.position) < 2f) { if (wayPointIndex == waypoints.Length - 1) { wayPointIndex = 0; } else { wayPointIndex++; } } else { agent.SetDestination(waypoints[wayPointIndex].position); } } { Debug.LogWarning("Please Assign more than 1 waypoint to the me!!" + gameObject.name); } } } public Vector3 RandomWanderPoint() { Vector3 randomPoint = (Random.insideUnitSphere * wanderRadius) + transform.position; NavMeshHit navHit; NavMesh.SamplePosition(randomPoint, out navHit, wanderRadius, -1); return new Vector3(navHit.position.x, transform.position.y, navHit.position.z); } public void ApplyDamage(float damage) { health -= damage; if (health
Finlay Fulton drag a prefab that look exactly like the model you are using as a enemy then exclude it from any thing attached to it except the rigid body meaning you need to remove the animator and the Ai script then make it rag doll by right clicking it in the hierchey and press 3D model then press rag doll and assign the bones to it for the fpsc just drag the playable character to it Edit: btw when you make it rag doll and making it as a oregano drag it to the zombie rag doll sorry for calling it zombie but because I was using it for my zombie game
i am using your script and i get the following error: Assets/EnemyController.cs(15,2): error CS0246: The type or namespace name `CharacterCombat' could not be found. Are you missing an assembly reference? Can someone help me?
I downloaded the zip from github and I tried opening the finished project and it opens but it has a compilation errors. Assets\Environment\PostProcessing\Editor\PropertyDrawers\MinDrawer.cs(6,34): error CS0104: 'MinAttribute' is an ambiguous reference between 'UnityEngine.PostProcessing.MinAttribute' and 'UnityEngine.MinAttribute'. What is this? can anyone help I'm such a noob. I really want to know how to put enemy AI into models!! Please help
Hi Brackeys, great tutorial. Just one question: Is there any reason why did not use a trigger collider to figure out if the player is within your desired radius?
dextrex Victor you could also just store two positions, and always have the camera at one position. This would probably prevent small lag spikes on the other guys method.
even though I copy everything you do it still doesnt work, "SetDestination" can only be called on an active agent that has been placed on a NavMesh, please someone help me.
My enemy stops following the player after some time. and also on that line "using UnityEngine.AI;" i'm geting an error so, when i want the script to work i have to disable that line. I'm using Unity 5.0.1f1. is it because my unity version is older?
i follow the instructions and it came up with this. "SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.AI.NavMeshAgent:SetDestination(Vector3) EnemyAI:Update() (at Assets/EnemyAI.cs:28) ? what does it mean
You and Sebastian help a lot. Thanks for the videos and tutorials. I do not know if they stopped creating videos, and if you still have a chance to collaborate on patreon.
Sebastians AI for the animations kinda suck bcs he didn't showed how he puted the animations to the enemy I tried it several times and it doesn't work. Like the enemy is attacking but am getting errors for the attack animation
Seems when I instantiate the player it doesnt work. If I drag and drop the player into the scene it works fine. This isnt a huge deal but im wondering if there is a way to do it with instantiate? and yes I drag and drop the correct prefab into the player spot.
Sir. NullReferenceException: Object reference not set to an instance of an object Pointing this line of code: float Distance = Vector3.Distance(target.position, transform.position);
Ondřej Karbaš usually you store it in xml and load the data. You see that most games have their own file, id be interested too to see how he does it with unity.
RandomSilly i know how to do it in simple games (mobile games for example) where you just need to save money, finished levels and stuff like that, but in a gamd where you can save whenever you want it will be much harder
You can make a binary .dat file storing your data with a System namespace. Unity has a tutorial for this. Google it, persistance and duration Unity tutorials I guess you will find it that way.
Dude, what you do on youtube.. teaches people for free is just too much...,I'm very grateful to you, all my skills with unity and even learning English I'm getting into these classes, thank you.
Technically it isn't free. The video is monetized by ads. So, it costs you your time.
James which is more valuable than money if you think about it
@Big Smoke PINEAPPLE ON PIZZA IS AMAZING
@@andrewnagengast2349 the pineapples on pizza part got me lol
Mds, achei um BR! Aleluia!!!
If anyone has a set destination error, follow these steps
1. Select your ground and check static on the top right corner of the inspector.
2. Keep your ground selected, and go to the Navigation tab. (Window>AI>Navigation) Then you should see a tab in Navigation called bake. Select it, and click bake on the bottom.
3. Play test your game. It might work it might not. If it doesn't work, follow the next steps. If it does, you are good to go.
4. Move your enemy ai closer to the ground.
5. Play test your game again. It might work it might not. If it doesn't work, follow the next steps. If it does, you are good to go.
6. If your enemy gets stuck in the ground, select your enemy, and in the NavMeshAgent, play around with the base offset. You should see a cylinder. Make that cylinder touch the ground.
Thanks so much lol
ya thank you
Thanks !!
Thank you so much!
thanks a lot
"if we get closer to our enemy, it will start to chase us, *AWESOME* "
"Hehe boi u have got some knowledge" - words of an old dog
After all these years I still come back to your videos..... Awesome Job my man !!! Mad Respect !!!
mate you are simply the best everytime i watch a tutorial elsewhere they jugle theyre scripts between episodes so that you have to watch every of theyre episodes but you do a complete video where you explain everything regarding one topic. i love your videos :) you are the best mate keep up the good work you made my day
Man, I love your videos. Especially these RPG ones 👌
6 years later and this video is still doing better than most recent videos
My days goes awesome when he says "AWESOME!"
Man, thank you for making these tutorials! They're top notch quality and very interesting! Keep it up!
yes
Love this series. It's been a great help with my current project. Keep the coming!
7:32 The type or namespace name 'Interactable' could not be found (are you missing a using directive or an assembly reference?), I am getting this error
Same here There is no class Named Interactable Its maybe Changed
im getting an error: "SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination(Vector3)
EnemyController:Update() (at Assets/EnemyController.cs:25)
Bake the map again
(Map > Navigation > Bake > Bake)
Or put your Enemy more close to the map
@@Floyna thx
I’ve hit bake and nothing happened
@@Floyna where is the "map" tab??
It's the map you use to move you're character
You can locate it on you're Scene
Sorry guys i'm late :o
The method I gave is not universal but maybe it's work for you
when you just want a simple enemy ai and then have to spend a few hours watching his entire series, only for it to break your game
lol
The type or namespace name 'CharacterCombat' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'CharacterCombat' could not be found (are you missing a using directive or an assembly reference?)
please help
Let's start to create deep-learning AI enemy.
Yeah! You know any good resources for that?
Why is he always Smiling?
Adarsh s because he is happy helping us
Adarsh s Lol
@@ezpz4646 yak
the sniper would be angry if he didnt
it woudnt look good if he was frowning
just discovered this series now im trying to integrate the parts of these scripts with your tower defense tutorial series to make a 3d kingdom rush type of game, thank a lot for these vids. btw im so new to game development so im really grateful
Not to sure why but my target location isnt updated after start. So the enemy will move to the initial player position but not follow the player after the player moves (or if the player is out of the lookRadius). I followed the video, any suggestions?
if anyone else had the thing that said "SetDestination can only be called on an active agent that is on a NavMesh." I set the ground as static went to window- AI- Navigation then bakedif that helps
6:45 why slerp, and not lerp? i know that slerp makes spherical path to the target, but i made 2 ai agents, and put lerp in one and slerp in the other, and saw no difference, it worked nice for me, but i just want to know why, ty Brackeys
The type or namespace name 'Interactable' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'Interactable' could not be found (are you missing a using directive or an assembly reference?)
how can i fix it §?
Sorry I'm a bit late, but to anyone else who has this problem:
Make sure to watch this video first
--ruclips.net/video/9tePzyL6dgc/видео.html
i can help u if u still want it
For some reason Unity shows an error when I try to do Enemy : Interactable...is there a way to fix the interactable error here?
same here did you find a fix?
I like that u speak fast and dont waste our time 👊👊👊
for me when i write OnDrawGizmosSelected it pops up a warning that the (OnDrawGizmosSelected) is declared but never used pls someone help
Thank you so much, Brackeys! I am looking forward to the next part! :D
Assets\scripts\Enemy.cs(5,22): error CS0246: The type or namespace name 'Interactable' could not be found (are you missing a using directive or an assembly reference?) what am i doing wrong pls answer this time
Pry a spelling error
I am getting an error "Set Destination" can only be called on an active agent that has been placed on the NavMesh. UnityEngine.AI.NavMesh:SetDestination(Vector3). How to fix this and what is the mistake? Please help me.
Berwin Singh i have this too.
I love this series. I don't know how far you want to take it, but topics I would love to see covered are amongst others:
- changing scene without losing the inventory and stats etc.
- saving and loading the game (maybe even with savepoints like in some JRPGs like Final Fantasy)
- trading with NPCs or maybe even have dialogue with different options or even different outcomes
- a simple system to level up and customizing stats with each level up
- day/night cycle or weather effects
I know a lot of these things are probably covered in other videos or you could read up on those topics somewhere online etc. but it would be fun to learn these things in the context of this little RPG series :)
Of course this list could be endlessly long haha there's so much you could do!
Anyways, keep up the good work :)
I can't believe how good you are at explaining!
@Brackeys
How do I point to my player that I spawned at runtime? I can't use the public method player that you show in the tutorial.
is there another place I can put the player manager beside the game manager since I only need the ai and not the entire
Great work Brackeys!
When everyone makes half hour long ai vids but ya boi asbjørn got ai down
Wow what a great channel this is. I've been subbed for sometime and coding interests me. Thanks for the awesome channel! :)
I'm stiil wondering how to 'collapse' when using regions in the c# scripts. I looked up keyboard shortcuts but nothing helps.
Somebody pleasre help...
there is a - sign in leftside where the region starts click it
Najeeb Ur Rehman Oh ok thanks, helps a lot
@@tssper3488 maybe you should look closer
it is Control + M + M I think?
Lol me too
i keep getting this error
"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination(Vector3)
EnemyController:Update() (at Assets/EnemyController.cs:25)
same
Same.. Any solutions ?
Maybe you NavMeshAgent is inactive? Or you forgot to add the component to the cube?
You go to Window>AI>Navigation and once you have the navigation window open, click on the objects that you want to bake a NavMesh and in the bake tab click bake. Hope this helps!
@@arcadeboy7503 Thannkksss
I couldn't add navmeshagent at the start, it didn't show up from 'navigation > navmeshagent' and searching didn't work
Can someone help me? I have a problem with the nav mesh agent. I checked my script to be like brackeys' but it don't work. Unity says: SetDestination can only be called on an active agent that has been placed on a NavMesh. UnityEngine.AI.NavMeshAgent:SetDestination(Vector3)
i have the same problema!! please help !!
sumerian ozzyz i fixed it. Make a group for the floor and go to window then navigation and its gonna open a bonus window next to the inspector. Then go to objects select mesh renderer and select the floor group(the y axis should be the same) then do this group static - yes for all children and then go back to navigation and bake the floor. Ask if you havent understand
im trying thanks
its done but now it appears object reference not set to an instance of na objetc .. : s
have you dragged it into the inspector (when you create for example public GameObject player you need to drag the object - the player in the inspector)
Great info on NavMeshes... I was able to get the right information quickly and easily!! Thank you for all of your tutorials.
Great tutorial as always! Easy to follow and really helped me out except for the fact that it doesn't work.
I keep getting this error: Failed to create agent because it is not close enough to the NavMesh.
Then whenever I get in range i get this error : "SetDestination" can only be called on an active agent that has been placed on a NavMesh.
Anybody know what to do? I already baked the floor and stuff.
i had this problem but when i baked the terrain it worked smoothly
Yes bro I got the same error....
"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination(Vector3)
EnemyController:Update() (at Assets/EnemyController.cs:27)
can someone help me?
generate a navmesh for your floor
@@monkeyballs188 How i do that? In my Console apears this :
"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination(Vector3)
AgarrameSiPodes:Update() (at Assets/AgarrameSiPodes.cs:38)
Pleas answer the soon as you can :c
I also got this error. I think I fixed it by placing my character on the ground or at least closer to it.
@@mateodemicheli2420 Go to the windows tab at the top and find the navigation panel(should be in the AI section). Then click over to the bake tab and bake.
@@chosengames4172 thank you sooooo much
This is amazing bro!
Can someone help. I keep getting this error: "Failed to create agent because there is no valid NavMesh". I've tried baking it but it still doesn't work! What is wrong???????????
hello, to make this work you need to set your ground to static(and your obstacles) then bake turn off Auto lightning if still doesn't and set your obstacles in the scene as "Navmesh Obstacles".
icoder Unity Thanks 🙏🏻 it works now 😄
No problem, i had that issue too. :)
something to note is that if its not working, try going into the PlayerManager script and change (GameObject player) into (Transform player).
any ideea why my enemy is coming exactly into me , i mean after he reaches me he stays exactly where i am ( on top of me ) and i cant move . If i put a rigidbody on him , after he reaches me and i attack him or he just touches me he go away and never come back xD . Any help pls ?
did you changed "stopping distance" in navMeshAgent component?
@@dron5734 I tried but not working so well
Before brackeys tutorial was a little bit boring like the intro was just "today we are going to make the A.I."
Bur now we have a mlittle joke in almost every intro
Brackeys really changed in a good way
I'm very new at this, so I don't know if you've answered this b4 but how do you make the enemy have an angle for line of sight
When did the altar object get added? At the start of this video the altar area / ritual area with torches has a platform on it now? Did I miss something?
error CS0506: 'Enemy.Interact()': cannot override inherited member 'Interactable.Interact()' because it is not marked virtual, abstract, or override
help!
Have you made a function for it?
just a great tutorial overall, even though I cannot donate currently I will be sure to share your channel as much as possible
Can you help me , An error appear says ""SetDestination" can only be called on an active agent that has been placed on a NavMesh"
same
@@gaddgames you go to the windows tab then head to ai then navigation. go to objects then click on your ground then press navigation static. then go back to the bake tab and hit bake. hope that helps
6:34
tyty
oldcommentyoutuber
???
Thank you so much for this series! I am actually not using this series to make a RPG. Instead, I am using them, to make a MOBA-style game!
Hey there! I'm making AI for a school project. I'm not interested in making the whole RPG, just the AI part. Can anyone tell me why i get an error when i change the public class of the enemy to Interact? I assume it because it was created in a previous episode, but i'm not great with Unity yet so i have no clue how to make that.
:( exactly the same problem here. Did you ever manage to find out about it? I also did not watch previous episodes D:
Decided to speed watch all his episodes until I find the reason, then the second episode hit me haha. It's all in Episode 2.
I got this error "SetDestination" can only be callrd on an active agent that has been placed onna NavMesh. Any help?
@@juniorasare9769 Thank you
@@juniorasare9769 Hey I dont understand this part " open the navigation window, select the floor, go on object and turn on navigation static" could you help me out pls
@@overwhelming9212 any obstacles or walls you have set it as "Navigation Static" on the inspector (top right corner). In Unity, NavMesh generation is handled from the Navigation window (menu: Window > AI > Navigation). Do the same with the Enemy AI object. I think. Try it and let me know if it worked!
@@overwhelming9212 also bake them
@@juniorasare9769 thank you ❤️
Hello.
Is it somehow possible to handle rotation on raycast hit as you did for FaceTarget() method? Its buggy and not working as same as clicking on object once facing the target (handling rotation without navmesh agent)
I was wondering if anyone could help me on my problem. I have typed in all of the code up to 5:35 and I attempted to run the code and I got this error: "Failed to create agent because there is no valid NavMesh"
My player has a NavMeshAgent component on it, so I am not sure what I am doing wrong.
Thanks.
@@juniorasare9769 Thank you!! this helped
I’m getting the error “MissingComponentException: There is no ‘NavMeshAgent’ attached you the “Enemy” game object, but script is trying to access it.” Any way to fix this?
add NavMeshAgent to Enemy if you haven't already
Got it thanks!
I have one problem and it's : NullReferenceException: Object reference not set to an instance of an object
EnemyController.Update () (at Assets/Scripts/Controllers/EnemyController.cs:22)
can someone help me please ?
same
This is great! I really love your videos!
I tried to attempt this but form some reason I keep getting two errors:
NullReferenceException: Object reference not set to an instance of an object
EnemyController.Start () (at Assets/Scripts/Controllers/EnemyController.cs:15)
NullReferenceException: Object reference not set to an instance of an object
EnemyController.Update () (at Assets/Scripts/Controllers/EnemyController.cs:22)
Anybody have any idea whats wrong?
You ever figure out what was wrong?
I have it fixed. Apparently the Awake function just wasn't capitalized.
@Yaq I got you fam
NullReferenceException: Object reference not set to an instance of an object
EnemyController.Update ()
I am getting this error in enemyController
For some reason, the enemy is not following or moving when the player comes within the distance. Any ideas?
Apparently my Enemy object keeps sinking into the ground on start... Seems to be preventing it's movement.
Ok, apparently I had a few errors. My transform for my graphics was offset, and my capsule collider was to tall/wide. Seems to be operating just fine now.
Can someone help me? i have the same coding as Brackeys has for the enemy AI but it doesn't work. Like it doesn't give me any errors at all but the enemy doesn't move
You gotta bake it, see the first comment above. Might be a little late though:)
i did a project but when i am going to red gizmos unity give me this error :
" MissingComponentException: There is no 'NavMeshAgent' attached to the "Enemy" game object, but a script is trying to access it.
You probably need to add a NavMeshAgent to the game object "Enemy". Or your script needs to check if the component is attached before using it.
UnityEngine.AI.NavMeshAgent.SetDestination (UnityEngine.Vector3 target) (at C:/buildslave/unity/build/artifacts/generated/bindings_old/common/AI/NavMeshAgentBindings.gen.cs:35)
Enemy.Update () (at Assets/Codes/Enemy.cs:20)
"
Could you help me guys
ChlodWin did you try adding a NavMesh?
I followed this tutorial to the T, same scripts exactly but the cube would not move. I took off the rigid body, and it works perfect now. Anyone with same problem , try messing with the rigid body
u was the best person and u will be on our hurts.
Awesome video as always. Would loooove to see this be converted to a multiplayer / coop.
it wont let me derive enemy from interactable pls help!
i have the same problem did you ever fix it? i cant change monobehaviour to Interact able, did you ever find out how to fix it?
Thank you for your videos! But i encounter some problem. It is working. but when i put a new enemy not the first one. there's an error "SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination(Vector3)
enemyController:Update() (at Assets/enemyController.cs:35)
It is the same as the first enemy it have rigidbody, navmesh agent and the scripts that works in the first enemy .
somebody help me :3
I have a script that can help you!!! this script
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
using UnityEngine.AI;
public class AiExample : MonoBehaviour {
public enum WanderType { Random, Waypoint };
public float damage = 16f;
public GameObject fpsc;
public WanderType wanderType = WanderType.Random;
public float wanderSpeed = 4f;
public float chaseSpeed = 7f;
public float fov = 120f;
private bool isAware = false;
private Vector3 wanderPoint;
public Transform[] waypoints;
private bool Attacking = false;
public GameObject radgollZombie;
public GameObject NPC;
[SerializeField] private float health = 100f;
public float viewDistance = 10f;
private NavMeshAgent agent;
private Renderer renderer;
public float wanderRadius = 7f;
private int wayPointIndex = 0;
private Animator anim;
public void Start()
{
agent = GetComponent();
renderer = GetComponent();
wanderPoint = RandomWanderPoint();
anim = GetComponentInChildren();
}
public void Update()
{
if (isAware)
{
agent.SetDestination(fpsc.transform.position);
anim.SetBool("Aware", true);
agent.speed = chaseSpeed;
//renderer.material.color = Color.red;
}
else
{
SearchForPlayer();
wander();
anim.SetBool("Aware", false);
agent.speed = wanderSpeed;
//renderer.material.color = Color.green;
}
}
private void OnTriggerEnter(Collider other)
{
if (hit.GetComponent())
{
GetComponent().ApplyDamage(damage);
}
Attacking = true;
anim.SetTrigger("Attack");
}
private void OnTriggerExit(Collider other)
{
Attacking = false;
}
public void SearchForPlayer()
{
if (Vector3.Angle(Vector3.forward, transform.InverseTransformPoint(fpsc.transform.position)) < fov / 2f)
{
if (Vector3.Distance(fpsc.transform.position, transform.position) < viewDistance)
{
RaycastHit hit;
if (Physics.Linecast(transform.position, fpsc.transform.position, out hit, -1))
{
if (hit.transform.CompareTag("Player"))
{
OnAware();
}
}
}
}
}
public void OnAware()
{
isAware = true;
}
public void wander()
{
if (wanderType == WanderType.Random)
{
if (Vector3.Distance(transform.position, wanderPoint) < 2.5f)
{
wanderPoint = RandomWanderPoint();
}
else
{
agent.SetDestination(wanderPoint);
}
}
else
{
if (waypoints.Length >= 2)
{
if (Vector3.Distance(waypoints[wayPointIndex].position, transform.position) < 2f)
{
if (wayPointIndex == waypoints.Length - 1)
{
wayPointIndex = 0;
}
else
{
wayPointIndex++;
}
}
else
{
agent.SetDestination(waypoints[wayPointIndex].position);
}
}
{
Debug.LogWarning("Please Assign more than 1 waypoint to the me!!" + gameObject.name);
}
}
}
public Vector3 RandomWanderPoint()
{
Vector3 randomPoint = (Random.insideUnitSphere * wanderRadius) + transform.position;
NavMeshHit navHit;
NavMesh.SamplePosition(randomPoint, out navHit, wanderRadius, -1);
return new Vector3(navHit.position.x, transform.position.y, navHit.position.z);
}
public void ApplyDamage(float damage)
{
health -= damage;
if (health
@Yaman what should I drag into the NPC ragdoll zombie and Fpsc ?
And thanks for the script
Finlay Fulton drag a prefab that look exactly like the model you are using as a enemy then exclude it from any thing attached to it except the rigid body meaning you need to remove the animator and the Ai script then make it rag doll by right clicking it in the hierchey and press 3D model then press rag doll and assign the bones to it for the fpsc just drag the playable character to it
Edit: btw when you make it rag doll and making it as a oregano drag it to the zombie rag doll sorry for calling it zombie but because I was using it for my zombie game
Check "navmeshagent.enable = true;:" maybe you have coded disable navmeshagent
Hi i tried it but it is showing "setdestination can only be called on an active agent that has been placed on a Navmesh"
Who else got a little spooked when he suddenly plays the music
You're really cool! I love your work. keep up :)
i am using your script and i get the following error:
Assets/EnemyController.cs(15,2): error CS0246: The type or namespace name `CharacterCombat' could not be found. Are you missing an assembly reference?
Can someone help me?
I downloaded the zip from github and I tried opening the finished project and it opens but it has a compilation errors. Assets\Environment\PostProcessing\Editor\PropertyDrawers\MinDrawer.cs(6,34): error CS0104: 'MinAttribute' is an ambiguous reference between 'UnityEngine.PostProcessing.MinAttribute' and 'UnityEngine.MinAttribute'. What is this? can anyone help I'm such a noob. I really want to know how to put enemy AI into models!! Please help
Hi Brackeys, great tutorial. Just one question: Is there any reason why did not use a trigger collider to figure out if the player is within your desired radius?
Brackeys you dont have Crafting system video right?
i was trying to ... but hard to apply to my inventory its kinda confusing
I have a player object but its a prefab, and the ai wont go to me because theres no way to set target to the prefab
Hey!!
I'm making this game and want switch camera! Do you have any video were you show how to do that? Great videos, keep it up!!
Just have a reference to both cameras, and simply enable & disable them as needed.
dextrex Victor you could also just store two positions, and always have the camera at one position. This would probably prevent small lag spikes on the other guys method.
Store 2 empty gameObject and use transform.Translate. You can also use camera.LookAt with the right range.
Use Vector3.lerp() instead of transform.Translate().
Yes! That's a good idea ^^.
even though I copy everything you do it still doesnt work, "SetDestination" can only be called on an active agent that has been placed on a NavMesh, please someone help me.
you will need to bake nav mesh on the ground they are standing on, its been over an year lol ik, i hope you found it
My enemy stops following the player after some time. and also on that line "using UnityEngine.AI;" i'm geting an error so, when i want the script to work i have to disable that line. I'm using Unity 5.0.1f1. is it because my unity version is older?
i follow the instructions and it came up with this.
"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination(Vector3)
EnemyAI:Update() (at Assets/EnemyAI.cs:28)
?
what does it mean
dose this tutorial work for other games and not just the one hes making
im making an fps and i can confirm that it works for my ai enemies most of these tutorials can be implemented into and type of game
thank you so much this is really helpfull
Hi, i keep getting errors about the enemy scripts saying Interactable. Any fix?
Thanks
You and Sebastian help a lot. Thanks for the videos and tutorials. I do not know if they stopped creating videos, and if you still have a chance to collaborate on patreon.
Sebastians AI for the animations kinda suck bcs he didn't showed how he puted the animations to the enemy I tried it several times and it doesn't work. Like the enemy is attacking but am getting errors for the attack animation
Seems when I instantiate the player it doesnt work. If I drag and drop the player into the scene it works fine. This isnt a huge deal but im wondering if there is a way to do it with instantiate?
and yes I drag and drop the correct prefab into the player spot.
I followed your first code but no wiresphere seen. How to fix this?
Make sure you have gizmos applied in scene window
How do i increase the speed of the enemy?
how did u collapse it the code ?
Man, I love your videos thank you
This is the only video that I've watched that you rushed without explaining much
Great Work man ...............
Sir. NullReferenceException: Object reference not set to an instance of an object
Pointing this line of code: float Distance = Vector3.Distance(target.position, transform.position);
Thank you so much,
Where is the video that makes the enemies fight? I couldnt find it
Love these videos, inspirational!
so the game I am trying to make, is a sort of zombie wave game, so will all of this stuff still work if I haven't followed any of the other tutorials?
So I am getting an error where nothing is working, the enemy just doesnt move?
If anyone just so happens to have the issue where their player wont focus on the enemy, remember to remove the boxcollider from the enemy GFX
5 years later and the community still coming through
@@hamandswizz yup!!
i want to create array of players in PlayerManager script...but when i do.....some transform error is showing in enemy script......anybody know why?
Will you also do saving? That's the only part i don't know how to do
Ondřej Karbaš usually you store it in xml and load the data. You see that most games have their own file, id be interested too to see how he does it with unity.
RandomSilly i know how to do it in simple games (mobile games for example) where you just need to save money, finished levels and stuff like that, but in a gamd where you can save whenever you want it will be much harder
Ondřej Karbaš make game objects from the XML?
Ondra English i didn't know if there was a more optimised way
You can make a binary .dat file storing your data with a System namespace. Unity has a tutorial for this. Google it, persistance and duration Unity tutorials I guess you will find it that way.