Тёмный

FULL 3D ENEMY AI in 6 MINUTES! || Unity Tutorial 

Dave / GameDevelopment
Подписаться 38 тыс.
Просмотров 631 тыс.
50% 1

FULL 3D ENEMY AI in 6 MINUTES! || Unity Tutorial:
Today I made a quick tutorial about Enemy Ai in Unity, if you have any questions just write a comment, I'll try to answer as many as I can :D
Also, don't forget to subscribe and like if you enjoyed the video! :D
See you next time.
Links:
➤ NavMesh Components: github.com/Uni...
➤ DOWNLOAD the SCRIPT: www.mediafire....
➤ DOWNLOAD the PROJECT (in the free-code-dave channel): / discord
➤ DON'T CLICK: bit.ly/2VcrDZt
If you want here's the series about the GUN SYSTEM USED in the video:
➤ • SHOOTING with BULLETS ...
🏹 Get Access to my RANGED COMBAT LAB! 🏹
➤ Trailer: • RANGED COMBAT LAB - Un...
➡️ Get Access to my full MOVEMENT LAB! ➡️
➤ Trailer: • MOVEMENT LAB - Unity P...
Other interesting videos :D
➤ Full WALL RUN tutorial: • Full WALL RUN TUTORIAL...
➤ My FIRST YEAR of game development: • My FIRST YEAR of UNITY...
Support me on Patreon:
➤ / davegamedevelopment
Music used:
➤ Elevate - LiQWYD: • Elevate - LiQWYD (No C...
➤ Night Out - LiQWYD: • Night Out - LiQWYD (No...
#UnityTutorial #EnemyAi #UnityEnemyAi

Опубликовано:

 

15 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 1,9 тыс.   
@shreerajkulkarni
@shreerajkulkarni 4 года назад
I was almost in tears listening to your voice because Brackeys has taken a break from youtube 😢😢😢😢😭😭😭😭
@virusocyrus
@virusocyrus 4 года назад
No he's done for good :'(
@RedCroissantGames
@RedCroissantGames 3 года назад
same buddy :(
@hunterc4881
@hunterc4881 3 года назад
"Good-bye and thanks for everything" doesn't sound remotely like a break tbh.
@monkeyrobotsinc.9875
@monkeyrobotsinc.9875 3 года назад
i was in tears listening to his voice for entirely different reasons..... :((((((
@h-aram1933
@h-aram1933 3 года назад
@@monkeyrobotsinc.9875 i guess feeling overwhelmed with how complicated coding seems? for me that was it
@safdaboss8645
@safdaboss8645 3 года назад
whoever followed through this tutorial without pausing the video once is a god
@HandleDisliker
@HandleDisliker 3 года назад
No joke, especially when this is my first time hearing his voice (not that it's bad at all just it wasn't anticipated) ...And I came back. For some foolish reason I thought I could follow through at 0.25 speed and You. Were. Not. Joking.
@P4rz1va1
@P4rz1va1 3 года назад
yeah, either this guy sped the video up so he could make the title "AI in 6 minutes" or he's just that fast, that's crazy.
@Shezza_1212
@Shezza_1212 3 года назад
@@P4rz1va1 it says 6 mins but it took me an hour to follow along, was a painful experience.
@soundzythedev
@soundzythedev 3 года назад
I paused every 5 seconds
@FINTHRTD
@FINTHRTD 3 года назад
The idea is to watch the video without doing anything, and then after watching it, try to do it yourself. Then it is possible.
@kburrrrr
@kburrrrr 4 месяца назад
Amazing tutorial, thank you!! Adding in notes on snags I hit for future reference: How To Add/Set Layer Masks: (1) Click on your game object, in inspector on the upper right is the Layer dropdown. Add twhatIsGround/Enemy/etc as new layers and set accordingly Enemies Not Moving: (1) Make sure your ground and player objects have colliders Projectile Problem: (1) Make sure your projectile has a Rigidbody component added Adding NavMesh Components: (1) You can now add them directly via Unity's Package Manager. Go to Window -> Package Manager -> Packages -> AI Navigation and install that
@kamartyr
@kamartyr 4 месяца назад
Thanks!
@axer1015
@axer1015 3 года назад
I feel like this guy might be our Brackeys from now on
@KingTubeAR
@KingTubeAR 3 года назад
But not for beginners
@keshav_trr
@keshav_trr 3 года назад
@MissYouBrackeys spam this line
@woutkrickx6455
@woutkrickx6455 3 года назад
never >:(
@baddiegaming758
@baddiegaming758 Год назад
@@KingTubeAR programmer moment
@davestone8766
@davestone8766 3 года назад
"in 6 minutes" ... *does tutorial in hyper speed*
@erdgerd9584
@erdgerd9584 3 года назад
Jup kinda hard to understand though like 10 minutes would have bbeen great
@Onek3i
@Onek3i 3 года назад
Kinda the point tho
@gamermazu8569
@gamermazu8569 2 года назад
Slow the speed of video
@Nebulaoblivion
@Nebulaoblivion 2 года назад
Its easier for people who need it slower, to pause after he says something, than it is for people who need it faster, to try to jump ahead through long silences, or useless chatter.
@davestone8766
@davestone8766 2 года назад
@@Nebulaoblivion my point being that if I make a video saying "make something in 6 minutes" but really I've just cut everything together in 6 minutes of video but the actual process takes hours and I also have to rewatch that 6 minute video 10 times to try and catch things due to you flying through it. Then the title is a lie, it has nothing to do with the pacing of the tutorial and everything to do with the claims of the title.
@kerduslegend2644
@kerduslegend2644 21 день назад
what. a. timeless. tutorial. literally as i write this comment this tutorial work even after 4 years later.. thanks unity for making such beginner friendly engine and thanks to you for making such comprehensible tutorial!
@acemoistman
@acemoistman 4 года назад
Bruh 6 minutes......im new to C# and I understood that perfectly, you're a fucking beauty
@davegamedevelopment
@davegamedevelopment 4 года назад
Haha thanks! :D
@brekol9545
@brekol9545 3 года назад
iam new too but i dont understand anything as alwyas :D but Daves tutorials are great :DD
@4ourhearts83
@4ourhearts83 3 года назад
it was so fast I had couldn't type anything of my own or Dave's code without having to pause or slow down to 0.5, and I type at god speed...
@Your_Sourav.
@Your_Sourav. 4 месяца назад
@@davegamedevelopment Hi sir please help me, actually i don not know how to downloaded the project from discord server. So I requested to you kindly tell me how to downloaded it🙏🙏🙏
@maxhrbobrndsted-nv3nz
@maxhrbobrndsted-nv3nz 4 месяца назад
@@Your_Sourav. same
@charlescaton
@charlescaton Год назад
To anyone having the player enemy fall or disappear... Make the empty Game Object that you put the Nav Mesh Surface on not a child object of your enemy. This worked for me, Best of luck!!!
@silent_reaper7461
@silent_reaper7461 9 месяцев назад
Thanks man. I’ve had so much trouble trying to figure that out
@dylancoles3314
@dylancoles3314 9 месяцев назад
thanks! this really helped!
@thomasbelk8745
@thomasbelk8745 7 месяцев назад
Thank you so much!!!!!
@lenardallen9770
@lenardallen9770 3 месяца назад
so do we make it a parent>?
@Derekstefan
@Derekstefan 20 дней назад
Thanks dude!!
@ayushsagar8074
@ayushsagar8074 4 года назад
Best Tutorial for Enemy AI on RU-vid
@davegamedevelopment
@davegamedevelopment 4 года назад
Thanks a lot! :D
@gaminganimator-qp2ir
@gaminganimator-qp2ir 4 года назад
agree
@Oliver-cr3nw
@Oliver-cr3nw 3 года назад
definetly
@fernandosilva9679
@fernandosilva9679 2 года назад
This tutorial is definitely one of the bests. The only thing I would probably add is the idling function. That way the enemy would stop for a sec or two instead of constantly running around
@mazenhassan2011
@mazenhassan2011 2 года назад
Can u tell me how to implement that ?
@gamdevgamdevpropro2781
@gamdevgamdevpropro2781 Год назад
@@MrNPCTHE THIRD CODE if (Time.time < lastDidSomething + pausetime) return; HAS A ERROR SMALL T IN WORD PAUSETIME. THE CORRECT ONE IS if (Time.time < lastDidSomething + pauseTime) return; JUST IN CASE SOMEONE WANT TO USE IT AND IS NOT WORKING,
@justgix7165
@justgix7165 Год назад
How does one get the nav mesh agent
@343guiltyspification
@343guiltyspification 9 месяцев назад
@@justgix7165 You go to your Packet Manager under 'Window' at the top. Then you select 'Unity Registry' insted of 'In Project' or 'My Assets' and search for the Nav Mesh Package. And then you install it.
@luciorojas4278
@luciorojas4278 3 года назад
This is how most of tutorials should be! I love everything about it. Directly to the point and explaining just what is needed. Awesome job and Thank you!
@axer1015
@axer1015 3 года назад
What about the fact he go faster den SANIC.
@gamermazu8569
@gamermazu8569 2 года назад
Slow the speed of the video
@carelesswhisker4155
@carelesswhisker4155 Год назад
yeah if "just what is needed" is "nothing at all"
@smokeback
@smokeback 2 года назад
This tutorial is amazing even if am not using unity, really opened up one thing i overlooked separating chase range and attack range .thanks for the breakdown of the base of ai before expanding how smart it behaves .just subbed
@georgeabidbol5180
@georgeabidbol5180 3 года назад
If you followed this tutorial and your Player is not recognised by the enemy so it never goes toward the player, it might be because your player doesn't have a collider. So, add a capsule collider or something like that to your player it could fix it. I've been struggling with that the past 15 min 😁
@mellemoomoo1701
@mellemoomoo1701 2 года назад
thank you for the tip it realy helps👍
@rprivateaccount5167
@rprivateaccount5167 Год назад
I found it was because my player wasn't named "playerobj"
@rprivateaccount5167
@rprivateaccount5167 Год назад
so I went to the script and changed it to the name of the player
@srujanpola3784
@srujanpola3784 Год назад
@@rprivateaccount5167 me too
@dahugo9740
@dahugo9740 Год назад
well what if he just goes up to the sky
@farisalmiqdad7146
@farisalmiqdad7146 9 дней назад
I keep coming back to this one. surprisingly simple, surprisingly effective.
@shayaanabbas2881
@shayaanabbas2881 4 года назад
I don't understand only one thing.... HOW ARE YOU SO GOOD?!
@davegamedevelopment
@davegamedevelopment 4 года назад
Haha thanks, but I'm not that good :D You can learn that too, just keep watching tutorials :D
@gaminganimator-qp2ir
@gaminganimator-qp2ir 4 года назад
@@davegamedevelopment i learned c# now
@davegamedevelopment
@davegamedevelopment 4 года назад
@@gaminganimator-qp2ir Nice
@gaminganimator-qp2ir
@gaminganimator-qp2ir 4 года назад
@@davegamedevelopment but gotta learn more:)
@damianuscraft
@damianuscraft 4 года назад
Same
@AlexraptorGameDev
@AlexraptorGameDev 2 года назад
Absolutely fantastic tutorial video! I found it absolutely invaluable as a starting point for creating my first Enemy AI. And I expanded it by adding behavior for patrol paths/waypoints, as well as definable 'Idle time' between WalkPoints, combined with a bool option to randomize idle time as well. :)
@KoopaD.WaterTroopa
@KoopaD.WaterTroopa 2 года назад
Hey just wondering how did you make that Idle time between walkpoints? I’m using a slime that jumps around randomly but also stops at times so i would like to have an idle function for it.
@AlexraptorGameDev
@AlexraptorGameDev 2 года назад
@@KoopaD.WaterTroopa Simple really. I create a standard timer variable ie: "Timer -= Time.deltaTime;", that runs in the Patroling function, under "if (distanceToWalkPoint.magnitude < 1f)" Then once the timer has hit zero, I allow "walkPointSet = false" to execute, triggering the AI to find a new walkpoint again. And to finish off I reset the timer when it executes FindWalkPoint();. You can either set the timer variable as a fixed value, or you can call the Random.Range(); function for more unpredictable behavior. I hope that made some sense. :)
@dak5327
@dak5327 Год назад
Yooo, just wondering how you made the waypoints / patrol paths to work with the code. Beginner coder here bahaha
@elixerprince_music
@elixerprince_music 2 года назад
If anyone is having trouble with the baking section you just have to set the areas you want to bake to static in the inspector.
@ryanxezter3910
@ryanxezter3910 2 года назад
thank you brotha was being so confused to what I was doing and y it wasn't baking lol ty tyty
@partishdarji26
@partishdarji26 Год назад
hey! can u tell what is projectile 4 and how to attach it???
@aokutor
@aokutor Год назад
@@partishdarji26 Hopefully this is not too late. The "Projectile 4" is whatever you want the enemy to instantiate. In the video, it was made into a prefab named Projectile 4.
@partishdarji26
@partishdarji26 Год назад
@@aokutor well thx for ur reply but i already got it!
@shauas4224
@shauas4224 Год назад
Nice script for enemy AI to completely kill all your hope for any tiny bit of performance as soon as your number of enemies is above 10. Good job
@obsidian2562
@obsidian2562 4 года назад
Damn right to the point. Very nice tutorial. You didn't waste a moment. Thx for this tutorial.
@davegamedevelopment
@davegamedevelopment 4 года назад
Glad you liked it! :D Thanks for watching
@001Camera
@001Camera 2 года назад
did it work for you? if so I need help. my enemy just stands there and does nothing I have no errors. pls help
@lonr_gsmo4583
@lonr_gsmo4583 3 года назад
Mans types so fast visual studio can’t keep up
@ShadaSomeGuyYT
@ShadaSomeGuyYT 4 года назад
This channel is so underrated
@davegamedevelopment
@davegamedevelopment 4 года назад
Thanks! Glad you like the videos! :D
@not_herobrine3752
@not_herobrine3752 3 года назад
@@davegamedevelopment brakeys 2.0
@TheAwesomeAlan
@TheAwesomeAlan 2 года назад
I have a weird, but small issue. When the enemy is attacking, the bullet spawns but it won't turn with the enemy. So it begins firing when I enter the attack range, but it's never facing me and never updates to my current position.
@micol04
@micol04 Год назад
i have same. how did you fix this?
@TheAwesomeAlan
@TheAwesomeAlan Год назад
@@micol04 Never did.
@micol04
@micol04 Год назад
I just did I added spawn point to a code I have and called in before transform.position .. instead of transform.position I used (spawnPoint.transform.Position)
@micol04
@micol04 Год назад
It spawns from wherever you put the spawn point game object irregardless of where it turns Use quaternion also instead of rotation
@Mcdoogs
@Mcdoogs 3 года назад
had a little trouble with figuring out layers but got it working after a little more research :) Thanks dude!
@mregghead9521
@mregghead9521 2 года назад
Im having trouble with the layers showing what did you do?
@joshuabauzon2341
@joshuabauzon2341 2 года назад
@@mregghead9521 Same here bro, did you find any solutions?
@ikkinu_1924
@ikkinu_1924 Месяц назад
@@mregghead9521 any of you got it working? plz help
@FunNooberCodingForBeginners
@FunNooberCodingForBeginners 3 года назад
This tutorial really helped! Thanks! I am working on FPS AI and a can't tell you how much this helped! Thumbs up!
@davegamedevelopment
@davegamedevelopment 2 года назад
Glad I could help!
@Your_Sourav.
@Your_Sourav. 4 месяца назад
@@davegamedevelopment Hi sir please help me, actually i don not know how to downloaded the project from discord server. So I requested to you kindly tell me how to downloaded it
@base4800
@base4800 3 года назад
Dave if you continue creating videos like this one you will be the next Brackeys on RU-vid or even bigger, congratulations and thanks for this amazing content. 👍
@sohamacharya171
@sohamacharya171 3 года назад
His voice is definitely Brackeys
@KaosWater
@KaosWater 2 года назад
I look away for one second and it's already the next video. Great tutorials btw.
@davegamedevelopment
@davegamedevelopment 2 года назад
Haha thanks :D
@strikelight1041
@strikelight1041 3 года назад
for anyone whos enemy is falling thru the floor, click window, ai, navigation, and then select the floor and anything else u want the enemy to walk on, then click bake and it should work
@time133
@time133 3 года назад
how to select the floor???
@strikelight1041
@strikelight1041 3 года назад
@@time133 click it? im not sure what you mean
@strikelight1041
@strikelight1041 3 года назад
@@time133 after you click navigation, you should be able to select the floor and then it will appear on the right, and then you click bake
@developer7046
@developer7046 2 года назад
My enemy is going down the ground when I go close to him, I tried playing with navigation settings, adding collider, adding rigidbody and non of these worked, any solution please? Also I have no console errors.
@budazenYT
@budazenYT 2 года назад
@@potato1947 same 😭
@SkyZizzle
@SkyZizzle Год назад
The “Nav Mesh Surface” script doesn’t appear the same way yours appears. Any way to fix?
@FOLDIK_UA
@FOLDIK_UA 6 месяцев назад
write your own script based on the logic of enemies. I don't see any other solution🥲
@TheDodoKing
@TheDodoKing 2 месяца назад
Did you install the package?
@ShawnGreyling
@ShawnGreyling 3 года назад
THIS IS AMAZING! Don't stop making these tutorials.
@davegamedevelopment
@davegamedevelopment 2 года назад
Thanks a lot! And well... I did stop :D But from now on I'll be uploading regularly again!
@Underarmour81
@Underarmour81 3 года назад
Awesome tutorial! This worked out amazing in my game.
@davegamedevelopment
@davegamedevelopment 2 года назад
Glad to hear that!
@Kasuga-
@Kasuga- 3 года назад
Player is'nt attacking and movin. Test everything not working. Any help will be appreciated
@miguelarocazarco5744
@miguelarocazarco5744 4 года назад
Your channel looks very very good, your voice reminds me brackeys too hahaha
@davegamedevelopment
@davegamedevelopment 4 года назад
Haha, thanks a lot! :D
@gaminganimator-qp2ir
@gaminganimator-qp2ir 4 года назад
@@davegamedevelopment wait are u .................................
@Shezza_1212
@Shezza_1212 3 года назад
@@gaminganimator-qp2ir no, his voice seems a bit too deep as well as the fact that brackeys was well serious about leaving RU-vid.
@TheDeathskull37
@TheDeathskull37 Месяц назад
There are a few changes I made to this. The AI needs to make sure that the path is complete before chasing or attacking the player. Otherwise, it will walk and float across gaps, walk through walls, and attack through walls. For enemies that shoot projectiles, I made them raycast towards the player to see if the player is within their line of sight, and if they don't see the player, they move closer until they can actually hit the player with the projectile. Otherwise, they get stuck trying to shoot a player from behind a wall.
@Poley12
@Poley12 Год назад
There no navmeshagent for me and it is driving me insane
@ScientObject40
@ScientObject40 3 месяца назад
I think you have to install it in the package manager.
@Poley12
@Poley12 3 месяца назад
Yeh it is not in package management for me
@berintandaniel1643
@berintandaniel1643 Год назад
Look into coroutines instead of invoking. Gives so much more flexibility and invoking is also more expensive. Amazing tutorials as always.
@michelmurr1949
@michelmurr1949 3 года назад
dude don't stop making videos you have some amazing content that A LOT of people can learn from
@BlackLoboGaming
@BlackLoboGaming Год назад
I don't know if you still read these but thank you!! this helped me so much. it was straight the point no chitter chatter. Greate video.
@iggythemad8701
@iggythemad8701 4 года назад
This is great! Straight to the point. I have a request please
@davegamedevelopment
@davegamedevelopment 4 года назад
Thanks for the idea, maybe I'll do that somewhen :D But with a bit of tweaking, you could split the attack state into "attack", "defense" and "approach". You only need to come up with some sort of logic when the enemy should do what :D
@iggythemad8701
@iggythemad8701 4 года назад
@@davegamedevelopment my main problem is how to make the ai strafe around, or move nearby the player, instead of just staying immobile infront of him.
@davegamedevelopment
@davegamedevelopment 4 года назад
@@iggythemad8701 For strafing just add transform.LookAt(player.transform) and move the enemy to the "transform.right" direction. By always looking at the player and walking right the enemy should walk in circles around the player :D
@iggythemad8701
@iggythemad8701 4 года назад
@@davegamedevelopment why didnt I think of this... i thought i had to use the navmesh or something
@davegamedevelopment
@davegamedevelopment 4 года назад
@@iggythemad8701 No problem, I think you should be able to use NavMeshAgents combined with other movements, just make sure to use the agent.ClearPath() function, otherwise the navMesh agent is constantly trying to get to the player :D
@Betruet
@Betruet 2 года назад
I love your video style and clear code. Subscribed!
@davegamedevelopment
@davegamedevelopment 2 года назад
Thanks a lot!
@GameDevNerd
@GameDevNerd 3 года назад
This was excellent. Clean, simple and concise explanation of how to use Unity's NavMeshAgent system. I've already got a 3D model of this demon-lord looking creature with movement and animation controls programmed, even did the IK adjustments to keep his feet perfectly on the terrain. Now I need to implement AI agents to control enemies and this showed me how to get that working. Gonna start with one simple ranged attack spell then hook up the whole game system for spells and weapons to AI agents based on what attacks they're able to use. 😄
@innerbladet
@innerbladet 2 года назад
Sounds like a Great game in development
@GameDevNerd
@GameDevNerd 2 года назад
@@innerbladet was more of a game prototype I was making migrating from DirectX to Unity and learning how things worked in Unity. I ended up getting hired by a company a couple months later to do this stuff in a commercial game. Unity is really easy if you've ever worked with OpenGL or DirectX and built small engines to power your own games. 80% of the hard work is done for you already and you only have to create the game. 🙂
@innerbladet
@innerbladet 2 года назад
@@GameDevNerd thx for the tips and hope everything goes good for you
@judetremblay-e6l
@judetremblay-e6l 9 месяцев назад
do you know how to get nav mesh
@spoogleh9813
@spoogleh9813 Год назад
so ur saying i could of just downloaded the script😐
@durgam_sumerian7815
@durgam_sumerian7815 3 года назад
I'm really happy to find your channel with all-new, simple, and specific videos, and I hope to find Oculus VR Rift tutorials as well, subscribe.
@Delvarn
@Delvarn 4 года назад
This is a brilliant tutorial, but I'm stuck on the layer masking. I've never done it before, how do I go about creating them properly?
@davegamedevelopment
@davegamedevelopment 4 года назад
Click on your enemy object, select the Layermask dropdown in the top right of the inspector (It should say "Default" there), then make a new Layermask called "whatIsEnemy" and make sure to select it instead of "Default" (on all your enemies) :D
@Delvarn
@Delvarn 4 года назад
@@davegamedevelopment Worked a treat, thanks!
@harryprettejohn5722
@harryprettejohn5722 5 месяцев назад
I am confused about this as well!
@harryprettejohn5722
@harryprettejohn5722 5 месяцев назад
I can't find the layermask
@tomatrix7525
@tomatrix7525 3 года назад
Best youtube on Game Dev hands down. Especially now that Brackeys gone, you will grow even more
@shanjohnkj6851
@shanjohnkj6851 3 года назад
This is Brackeys Channel. I think He is doing Side Business from this channel.... hahaha . Exact As Brackeys
@olliewackamo7367
@olliewackamo7367 Год назад
hi, when i use this script it works fine but my game becomes choppy / laggy. any help on how to fix this ?
@spielsuchtige5011
@spielsuchtige5011 3 года назад
Hey, it shows me an error at line 31: Object Reference not set to an Instance of an object? and my ai doesnt move, how do i fix those things?
@fezza2283
@fezza2283 3 года назад
have you made sure to reference the object its missing in the editor? If you want you can msg me on discord for more help. Fezza#4066
@kirby6844
@kirby6844 2 года назад
So I’ve been creating a game and this was really helpful. Though I am making a horror game. But still was helpful! Thanks!
@Galaxy_World
@Galaxy_World 3 года назад
btw u should do it like this: make it so if the enemy sees you with their own eyes with raycast and that they are in range of the sight, this would be infinitely more realistic.
@ray2dasherthedragon336
@ray2dasherthedragon336 Год назад
Yea thats what I need to be honest
@mrpotato8196
@mrpotato8196 Год назад
Nice! I spent a long time doing the detection, I wanted it to be like if the player is out of sight the enemy will move to where he was last seen, it took a long time because it was the raycasts being dumb, *nice tutorial tho*
@gamesdum4684
@gamesdum4684 Год назад
There is no Bake Button.. I cant bake
@transsatanic4591
@transsatanic4591 3 года назад
I literally just straight up assumed you ripped one of Brackey's videos I was so confident that was his voice! It's funny how two game development people on youtube sound so similar lol, thank you for the video!
@Dbdelaney4
@Dbdelaney4 3 года назад
I have 2 issues. One the enemy doesn't patrol it just kinda stands there. the walkpoint keeps changing but the enemy doesn't move. Also when the enemy reaches a certain point it just stops and refuses to move. Any help would be great.
@cbasx1887
@cbasx1887 2 года назад
happens same to me
@manishshrestha4263
@manishshrestha4263 2 года назад
This reply is for new watchers. Add This so it doesn't happens to you. " if (Physics.Raycast(walkPoint, -transform.up, 2f, whatIsGround)) walkPointSet = true;" In this view " 2f" is missing.
@the_chocolade
@the_chocolade 2 года назад
@@manishshrestha4263 what should i do?
@melder0487
@melder0487 2 года назад
@Chocolade YT It is posible your ground is not on the "WhatIsGround" Layer
@HappyPupx
@HappyPupx 2 года назад
For anyone has their AIs not patrolling, assigning the value walkPointRange will fix this problem
@ammonlikesalmon
@ammonlikesalmon 3 года назад
I can't find the NavMeshSurface option... can anyone help with this?
@deadasadodo1016
@deadasadodo1016 Год назад
How do you download the nav mesh
@Nemko77
@Nemko77 4 месяца назад
Maybe you know it already but it's ai navigation in the package manager.
@USBEN.
@USBEN. 2 года назад
Thankyou , this script acts as a nice base to build upon more complex behaviours.
@davegamedevelopment
@davegamedevelopment 2 года назад
Glad I could help! :D
@BtaraDev
@BtaraDev 2 года назад
Thank You, This really helped me learn more about NavMeshAgents. I modified the code and used it to make an AI for my Game.
@davegamedevelopment
@davegamedevelopment 2 года назад
Glad I could help!
@P4rz1va1
@P4rz1va1 3 года назад
I altered this to make an enemy that walks between its start point and a given point, after chasing and losing sight of you it returns to its start point.
@AkariK3
@AkariK3 3 года назад
Please, would you mind to share how you did it? TY in advance
@Kharabish
@Kharabish 3 месяца назад
dude u r awesome i was looking for this for a couple of days thank u so much ♥
@redsgaming4614
@redsgaming4614 2 года назад
Not sure what I am doing wrong, I downloaded your code and named layers to WhatIsEnemy, WhatIsGround etc. yet the layer masks are not working. I only have a ground to mask with right now so I gave it WhatIsGround and baked it. I have all the imports right in the Nav Mesh Agent yet the object is still falling through the ground. Originally the enemy was floating on the y axis, but now it is just falling through the ground.
@geoffreyaji8659
@geoffreyaji8659 Год назад
were you able to figure out why this was happening
@gabe8142
@gabe8142 Год назад
I seriously wonder if the creators of these types of tutorials actually feel like they're teaching something... no "whys" whatsoever - just having the viewer copy code.
@claudiodias0089
@claudiodias0089 4 года назад
hmm... the NavMeshSurface doesn't have the baking options or most of the others you have /: pls help
@davegamedevelopment
@davegamedevelopment 4 года назад
Did you import the nav mesh components correctly? :D
@GameEditMrCzopowski
@GameEditMrCzopowski 4 года назад
@@davegamedevelopment how do you import the nav mesh components correctly?
@CuriousCreatorsYT
@CuriousCreatorsYT 3 года назад
Make sure your GameObject is set to Static. Your NavMesh surface should be static to bake.
@yahyabzl1112
@yahyabzl1112 Месяц назад
I did everything like the tutorial but when i try to play the ai go to space any solutions?
@Emr3letzemre
@Emr3letzemre Год назад
help my ai IS FLYING AWAY
@foxfirefive
@foxfirefive 3 года назад
when i use it my enemy flys 100 billion miles in the air at lightspeed. how do i fix this????
@caulse4844
@caulse4844 3 года назад
No idea Here, Same problem
@bruhsoupy7700
@bruhsoupy7700 3 года назад
did you ever figue it out
@foxfirefive
@foxfirefive 3 года назад
@@bruhsoupy7700 no
@caulse4844
@caulse4844 3 года назад
@@bruhsoupy7700 i did. You gotta put the navmesh on an empty gameobject, but the code might be outdated or something. So you'll have to do some tweeking. The tweeking took me 3 days since i am a complete starter.
@bruhsoupy7700
@bruhsoupy7700 3 года назад
@@caulse4844 what tweeks did you make?
@ricardovicente9666
@ricardovicente9666 2 года назад
Amazing tutorial, but I was wondering how could a speed variable be implemented in the ChasePlayer function, so that different enemies may have different speeds
@davegamedevelopment
@davegamedevelopment 2 года назад
You can change the speed in the navmeshagent settings
@Nitzustaja
@Nitzustaja 2 года назад
if im right, you could do something like this: first make int ,string,scriptable object or anything that you could choose depending what "type of enemy you want". then do something like this public int enemyType; void Update(){ if(enemyType==1)agent.speed=1f; if(enemyType==2)agent.speed=2f; if(enemyType==3)agent.speed=3f; } then make prefab for enemy type 1,2 and 3(remember to change enemytype from the prefab )
@Nitzustaja
@Nitzustaja 2 года назад
thats how you could make the ai have stamina and start walking when stamina is low, hope that you understand what i mean with that
@robbytegd4347
@robbytegd4347 3 года назад
The only thing I can say about this video is you've got a new subscriber :)
@gamingthomas8146
@gamingthomas8146 2 года назад
Thanks for the tutorial but I have one question. When the enemy comes in sight it flies towards me and I keep getting this error: "SetDestination" can only be called on an active agent that has been placed on NavMesh.
@devxtreme259
@devxtreme259 2 года назад
Make sure you select navigation and bake
@angelchurrumais
@angelchurrumais 2 года назад
remember you need to creat a new empty GameObject and then add the component NavMeshSurface. In the NavMeshSuface, you have to bake your terrain or ground data.
@StanMangamer
@StanMangamer Год назад
Great tutorial, I followed all the steps but I have a slight issue. I made a capsule just so I can test it out, but it isn't moving. I copied and pasted the code and followed everything but I don't know what I could've missed. when I add the random walk, it does work.
@nico_739
@nico_739 Год назад
What do u mean by Random walk?
@atakankuloglu4877
@atakankuloglu4877 2 года назад
The voice is the same with Brackeys?
@davegamedevelopment
@davegamedevelopment 2 года назад
Haha no, only sounds similar :D
@M3g4t0n
@M3g4t0n 2 года назад
Very usefull tutorial! I've already used it to program some turrets to fire at me and a ground enemy to chase and attack me!
@davegamedevelopment
@davegamedevelopment 2 года назад
Thanks, glad I could help!
@rocketthab8.5
@rocketthab8.5 3 года назад
it doesnt work for me the enemy just flies into space like it has reversed gravity
@thediamondgauntlet8888
@thediamondgauntlet8888 3 года назад
same mine was glitched off the map and starts crazy flying help
@FuzzxBikes
@FuzzxBikes Год назад
I Wish He Was More Clear On The Installation For Navmesh!
@Drumdeedoo
@Drumdeedoo Год назад
yes please
@agamesjourney4292
@agamesjourney4292 3 года назад
Dave the enemy's aren't shooting with me how do i fix this aside that a great tuturial
@axer1015
@axer1015 3 года назад
Sorry, I have no knowledge on this, what you can try is re-watching the tutorial to check for errors or try a new tutorial.
@vidjey2597
@vidjey2597 2 месяца назад
probably because your player tag is not the same as in the script
@cpt.ghostriley735
@cpt.ghostriley735 9 месяцев назад
Very good videos but why you don't show hierarchy? please show so i can understand
@Hapi-lee
@Hapi-lee 3 года назад
followed this exactly and when i tried to play it he plummeted the earth at 350 mile per hour Edit: found the problem and it was how close he was to the ground just get him closer to the ground and it should work
@alecbeaton6862
@alecbeaton6862 3 года назад
This boi is helping me so much. You are amazing
@tyler7268
@tyler7268 3 года назад
This is exactly the kind of tutorial i need. And is the exact solution i was looking for. Thank you so much!
@x.4132
@x.4132 2 года назад
Great tutorial, but one big thing is missing. Sometimes the random walkpoint is set in a wall or some obstacle and the "AI-Object" doesn't move and is stuck....
@001Camera
@001Camera 2 года назад
Same it doesnt move when i do it!
@junaidjamshed8104
@junaidjamshed8104 2 года назад
@@001Camera Hey Set the roads sidewalks or any ground area to the Layer Ground don't set the walls and other objects like building or mountains to Layer Ground
@BurtBot
@BurtBot 3 года назад
Great tutorial! I also like how you say projectile. "Project tile". Totally going to steal that :D
@sapphirecorn3635
@sapphirecorn3635 2 года назад
Hey, so I'm completely new to coding and unity in general, and I'm having issues with my enemy falling through the map extremely quickly, and it says the walk point is what I'm assuming is the position of the entity. Any idea why?
@zypherone
@zypherone 2 года назад
Do you have an active rigid body on the enemy? Because if it’s just falling through then maybe the collision is off
@Emerald_Dev
@Emerald_Dev 2 года назад
Same I’ve been fiddling with it for a while now and it just keeps happening, not sure how to fix it.
@kevCjm6dhhihiujkbbhjhvcfyhuiij
Did you add the navmeshsurface to your ground? I added the navmeshsurface to the wrong thing, and when I applied it to my ground it stopped falling.
@hoiman7074
@hoiman7074 3 года назад
my enemy keeps shaking like it's drunk, and when i shoot it with a force, it goes back to the place it was before and continues to be drunk. what in the world is happening
@ashleyk9141
@ashleyk9141 3 года назад
Hello Dave, great video! I followed this tutorial for a game where a monster chases a first person player. Everything works great except the patrolling. I can see it setting new walk points in the inspector, but the monster does not go to them. Any idea how to fix this? Thanks!
@martinschifer3603
@martinschifer3603 3 года назад
Same here!! Did you find any solution?
@cooperswain3118
@cooperswain3118 2 года назад
hey just wondering if you found the solution, i am having the same problem.
@dralbintokomesemito8829
@dralbintokomesemito8829 2 года назад
Its most likely because the walkpoint is being set at a point that is unreachable. You should set a timer for the walkpoint instead of the walkpoint changing when one was reached
@HappyPupx
@HappyPupx 2 года назад
You must set the walkPointRange value so that the variables randomX and randomZ work properly
@epicdragon668
@epicdragon668 2 года назад
Great video but for me they just fall right through the floor, i did everything correctly with baking but it just doesnt work any idea on what the issue could be?
@fate70
@fate70 3 года назад
my enemy randomly sinks through the map edit: what i mean is that the Y value is going crazy - it will move a bit to the left, then shoot downwards in the space of around a millisecond as soon as the game starts, without travelling there. It just instantly warps below the map. I am using terrain that is very mountainous as the ground layer, though. maybe that is the problem? could you help me please? edit 2: the same thing happens with the exact same ground that you are using.
@lordzockt1853
@lordzockt1853 3 года назад
did you set the " What is Ground“ var right ?
@lordzockt1853
@lordzockt1853 3 года назад
I'm having the same problem, the only thing that is different after changing stuff up(So that he dosen't fall down) is that my enemy won't move a bit ;/
@someonenamedegg1844
@someonenamedegg1844 8 месяцев назад
I dont even have that which is annoying, it dosent show the "what is player" or "what is ground"@@lordzockt1853
@noony31122009
@noony31122009 2 года назад
ur really amazing iam really looking forward for ur next tutorials !!
@davegamedevelopment
@davegamedevelopment 2 года назад
Thanks, appreciate it!
@ScratchTuto
@ScratchTuto 3 года назад
Now I've downloaded the zip file but how I get those godes in the unity editor?
@not_herobrine3752
@not_herobrine3752 3 года назад
drag and drop into the assets folder... at least thats what i did
@ScratchTuto
@ScratchTuto 3 года назад
@@not_herobrine3752 It didn't work whit me
@not_herobrine3752
@not_herobrine3752 3 года назад
@@ScratchTuto are you sure you have downloaded the right version of the zip file? like the latest version for unity 2020 and so on?
@ScratchTuto
@ScratchTuto 3 года назад
@@not_herobrine3752 idk I dosen't need it any more but thx for the help
@cloakedd_
@cloakedd_ 3 года назад
@@not_herobrine3752 then what do I do?
@damvcoool
@damvcoool 2 года назад
I really like this because it's the only Tutorial I have found where ai patrols without multiple patrol points
@davegamedevelopment
@davegamedevelopment 2 года назад
Glad I could help!
@NastanielBabablueskee
@NastanielBabablueskee 3 года назад
Really enjoyed this tutorial. You've gotten my sub. I had two issues, one being my projectiles would only move in one direction, even if the enemy rotated. Two being the enemy would rotate on the X axis when shooting -- I only wanted it to rotate on the Y axis. These two were quite easy to fix. In AttackPlayer() Vector3 newPlayer = player.position;
@Bilallakho_
@Bilallakho_ 3 года назад
help, on the Rigidbody=rb line there is a problem on the May change part idk what to do help me pls, it just shows this assets\EnemyAiTutorial.cs(93,129): error CS1003: Syntax error, ',' expected
@Bilallakho_
@Bilallakho_ 3 года назад
please help me since it says that may Change does not exist in the ucrrent context. im new to unity pls help
@NandKumar-ex6mw
@NandKumar-ex6mw 3 года назад
@@Bilallakho_ can you comment the script you used...
@EvanStreblow
@EvanStreblow 3 года назад
Super helpful, man. Thanks!
@chrissiededeer7256
@chrissiededeer7256 3 года назад
Can someone help me out if n put the NavMeshSurface on an object it doesnt show me the same menu Theres an empty slot called NavMeshData and an agent type ID Edit and no bake option
@renatogenovese2718
@renatogenovese2718 4 года назад
hey dave i'm working on a 2d top down shooter and i'm using your script from the first projectile gun tutorial without reloading,the bulletsleft and the ray. when i do a burst gun instead of firing like RATATA, RATATA, it fires like RATATATA, RA, RATATATA, RA, maybe because it invokes resetshooting also with the burst projectiles. i'm also always shoting when i use the right analog because it moves with the left joystick and rotates with the right joystick. here is my code. can you help me?? using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class player : MonoBehaviour { //general Rigidbody2D rb; //movement public float movespeed; Vector2 movement; public FixedJoystick movejoystick; //rotation public float rotatespeed; public Joystick rotatejoystick; //shooting public GameObject bullet; GameObject bulletshotted; public Transform head; public float bulletspeed; public bool readytoshoot; public float timebeetweenshooting; public guncontainer gun; public int bulletspertap; public int bulletsshot; public float timebtwnshots; public bool allowinvoke; void Update() { //movement float horizontal = movejoystick.Horizontal; float vertical = movejoystick.Vertical; movement.x = horizontal; movement.y = vertical; //rotation Vector3 movevector = (Vector3.up * rotatejoystick.Horizontal + Vector3.left * rotatejoystick.Vertical); if (rotatejoystick.Horizontal != 0 | rotatejoystick.Vertical != 0) { transform.rotation = Quaternion.LookRotation(Vector3.forward, movevector); } //shooting if (rotatejoystick.Horizontal != 0 && readytoshoot || rotatejoystick.Vertical != 0 && readytoshoot) { Shoot(); bulletsshot = 0; } timebeetweenshooting = gun.timebetweenshooting; bulletspertap = gun.bulletspertap; timebtwnshots = gun.timebtwnshots; } void FixedUpdate() { rb.MovePosition(rb.position + movement * movespeed * Time.deltaTime); } public void Shoot() { if (bulletsshot < bulletspertap) Invoke(nameof(Shoot), timebtwnshots); readytoshoot = false; bulletshotted = Instantiate(bullet, head.position, head.rotation); Rigidbody2D bulletrb = bulletshotted.GetComponent(); bulletrb.AddForce(head.up * bulletspeed * Time.deltaTime, ForceMode2D.Impulse); Destroy(bulletshotted, 2); bulletsshot++; if (allowinvoke) { Invoke(nameof(Resetshooting), timebeetweenshooting); allowinvoke = false; } } void Awake() { rb = GetComponent(); readytoshoot = true; bulletsshot = 0; allowinvoke = true; } private void Resetshooting() { readytoshoot = true; allowinvoke = true; } } thanks dave!
@priyadaksheshpatel8384
@priyadaksheshpatel8384 4 года назад
I knew I saw this comment before!
@NeroForte_
@NeroForte_ 2 года назад
Now I understand the difference between blueprints and c#.
@davegamedevelopment
@davegamedevelopment 2 года назад
Haha :D
@blenderme7324
@blenderme7324 Год назад
would be cool if you showed us what the scripts you included did and what they are used for. Sounds like you had somewhere to be right after this video with how fast you were going and how little you explained 5/10 tutorial
@BAD_GAME_DEV
@BAD_GAME_DEV 5 месяцев назад
Great tutorial man, it’s a big help cause I’m very new to enemy ai
@cloakedd_
@cloakedd_ 3 года назад
How do I add those NavMesh Files? pls help :(
@axer1015
@axer1015 3 года назад
Hey @Toasted! Try going to your bot’s inspector and adding a NavMeshAgent to it. For best results, change the speed to 2, the acceleration to 20, and the Obstacle Avoidance Radius to 2 as well. Hope this works for you!
@breeze3104
@breeze3104 2 года назад
Thank you, even helped out in the discord.
@praisethemibbers8991
@praisethemibbers8991 3 года назад
Hello, thanks for the tutorial. Im very new to all this so im struggling a little. I made a sphere as the enemy, and i gave it all the scripts and stuff. I followed the tutorial until 5:27 basically. But my enemy is not moving, and it just shoots whenever it wants. it shoots at the player which is good, but i basically have a turret with infinite range in my game. How can i make the sphere actually move and act like an enemy? Also why does it just ignore the sight radius and stuff. (i dont have any errors in my console)
@_solar.
@_solar. 3 года назад
nav mesh? i suggest this discord: discord.gg/Ye6zzfQ
@axer1015
@axer1015 3 года назад
Hey, I suggest using the capsule if it is a ground enemy. If you want to make an enemy that can fly, this tutorial will not work.
@shang_psycho7414
@shang_psycho7414 2 года назад
Same, I didn't add a gun to mine, it's just not moving.
@Geckotr
@Geckotr 2 года назад
i couldn't make it move too
@Geapen8
@Geapen8 11 месяцев назад
same, can't make it move
@randonx6155
@randonx6155 4 года назад
Why is the ai shooting up
@davegamedevelopment
@davegamedevelopment 4 года назад
Remember that you can download the project file over my discord if you want :D
@gaminganimator-qp2ir
@gaminganimator-qp2ir 4 года назад
you can just search on yt on how to make a turret and use the turret as ur enemy his hands
Далее
AI Learns Insane Monopoly Strategies
11:30
Просмотров 10 млн
3 Hours vs. 3 Years of Blender
17:44
Просмотров 4,8 млн
New Race ? 🪽| Doge Gaming
00:12
Просмотров 1,6 млн
They Dared Me To Make A Game...
12:08
Просмотров 1,1 млн
1 Year of Learning Game Development In 6 Minutes
6:01
AI Learns to Play Tag (and breaks the game)
10:29
Просмотров 3,3 млн
How to code SMARTER A.I. enemies | Unity Tutorial
32:49
I Added Infinite Crafting to Minecraft (with AI)
13:08
AI Invents New Bowling Techniques
11:33
Просмотров 3,4 млн
I Made Among Us, but it's 3D
15:56
Просмотров 20 млн
New Race ? 🪽| Doge Gaming
00:12
Просмотров 1,6 млн