The Ultimate beginner's guide to AI with Unity & C#

  Рет қаралды 102,353

Blackthornprod

Blackthornprod

Күн бұрын

In this ultimate beginner's guide to AI with Unity and C# we'll create 5 unique character behaviors you can use for your game's npcs.
---------------
A* 2D pathfinding: arongranberg.com/astar/
---------------
Game Dev Courses:
1- Beginner's guide to Game Dev: www.udemy.com/course/make-you...
2- Online Multiplayer: www.udemy.com/course/beginner...
3- 2D Platformer: www.udemy.com/course/how-to-m...
4- Top Down Shooter: www.udemy.com/course/creating...
5- 2D Turn by turn Strategy: www.udemy.com/course/creating...
---------------
0:00 - Intro
0:43 - Follow AI
2:50 - Shoot and Retreat AI
6:09 - Patrol AI
9:36 - 2D Pathfinding AI
13:14 - Line of Sight AI
18:56 - Conclusion

Пікірлер: 107
@iHeartGameDev
@iHeartGameDev 2 жыл бұрын
Glad to see more tutorials from BlackThorn! Definitely enjoy learning from you two about the 2D side of Unity that I’m especially unfamiliar with 🍻
@ragerungames
@ragerungames 2 жыл бұрын
I have been following your channel too. I would like to see how you approach learning/researching about game dev topics and procedure in a dedicated video! :)
@AlexBlackfrost
@AlexBlackfrost 2 жыл бұрын
I couldn't have said it better myself
@itsfun2990
@itsfun2990 10 ай бұрын
I am a huge follower of you unity animation series...
@this-is-gamedev
@this-is-gamedev 2 жыл бұрын
Very beginner friendly indeed! Next step is to add a simple state machine to switch between patrol, chase, etc. Can be easily done with visual scripting, which is great for very beginners as well.
@robrobusa
@robrobusa Жыл бұрын
And afterwards I'd love to see some behavior trees.
@amandaflood
@amandaflood 2 жыл бұрын
Your tutorials go straight to the point, they really are excellent. I just coded an NPC who passes between patrol points depending on where the player is - would not have found it easy without this video as a jumping-off point. Thanks!
@NightRunStudio
@NightRunStudio 2 жыл бұрын
I love these tutorials. I use them a lot in my high school game dev course. Students love how visual and straight-to-the-point they are. Keep up the awesome work!
@petipois28
@petipois28 2 жыл бұрын
It's been a while, thank you for these tutorials. Really helpful, I'm going to try an improve an old 2D stealth game with this.
@sayankabir7958
@sayankabir7958 2 жыл бұрын
Noah and Liam are creating the most useful content related to gamedev. We are so thankful to you ❤️
@TheStigChristensen
@TheStigChristensen 2 жыл бұрын
Love to see the tutorials coming back! Can you make a 'The Ultimate intermediate guide to AI with Unity & C#' ? Would love to see more advanced use of the A* plugin, like bosses and state machine enemies
@ghiancarlostan8730
@ghiancarlostan8730 2 жыл бұрын
please dont stop making videos my dude !! I really love your tutorials
@leonaise7546
@leonaise7546 2 жыл бұрын
OMG DUDE YOU LITTERALLY SAVED ME! I'm a rookie game dev & my game idea revolves around AI but I don't have any AI experience. I'm so lucky you uploaded this particular vid at this time because I was about to re-design my whole game but you came in clutch-XD! Tho my game's 3D i think I can adapt this on my own or get help with ease. Love ya man! You're awesome👍❤️!
@ceciliacecchet5869
@ceciliacecchet5869 Жыл бұрын
thank you so much for this, it's so simple and considering how I'm a begginer it's just easier to understand than other tutorials
@tristancowen5636
@tristancowen5636 2 жыл бұрын
Nice, been wanting to see this for a while!
@KeyboardKrieger
@KeyboardKrieger 2 жыл бұрын
A free A* pathfinder is really a nice tool, which you can use all the time
@minhhoangtranhuy8730
@minhhoangtranhuy8730 2 жыл бұрын
wait I'm stuck with 2D AI for a few days now thank you a lot! this comes out just in time
@andreea23606
@andreea23606 2 жыл бұрын
This couldn't come at a better time Thanks
@waltergamedev3664
@waltergamedev3664 2 жыл бұрын
It is a very useful tutorial! I going to use everything in my game! Good job blackthorprod!
@DailyFootballEditsDFE
@DailyFootballEditsDFE 2 жыл бұрын
your sound has changed a lot btw, nice to see you again :)
@boycececil3727
@boycececil3727 2 жыл бұрын
Finally you update, I have been waiting sooooo long! Every day wondering why you still haven’t updated😂
@SoYo135
@SoYo135 2 жыл бұрын
Thanks for the tutorial, i see this helping me out well in future games :)
@Yipper64
@Yipper64 2 жыл бұрын
AI programming is my favourite thing to program (I just love seeing thing move when I said "move" in nerd talk) and im trying to learn C# so this will be an excelent video to watch when im done learning the basic basics of C#.
@ItsMePhoebe
@ItsMePhoebe 2 жыл бұрын
Saving this to my must watch later! Am really excited to start learning AI 😁
@harrington8
@harrington8 2 жыл бұрын
I was recently researching this topic
@pudgystump
@pudgystump 2 жыл бұрын
Definitely a very practical guide. Would be neat to see an intermediate guide where you create a* from scratch! While it would likely not be useful for a game (because it looks like that package is extremely comprehensive, even on the free tier), it would be an amazing learning experience for people... to see what goes into creating an algorithm and creating a more complex bit of AI on their own. Great guide, though! 10/10
@megateamaj
@megateamaj 2 жыл бұрын
Well done as always
@Gh0stzZ1
@Gh0stzZ1 2 жыл бұрын
definitely best channel, thank you so much
@BlueHat1
@BlueHat1 Жыл бұрын
Very helpful, thank you so much❤
@andymitchell2146
@andymitchell2146 2 жыл бұрын
Got a cold Noa? Nice video. Especially the pathfinding part.
@Govi-fu1ti
@Govi-fu1ti 2 жыл бұрын
I was Waiting for this 😃
@memez4life191
@memez4life191 2 жыл бұрын
Amazing!
@cre8tivemediavault72
@cre8tivemediavault72 2 жыл бұрын
Hey! I`ve been waiting for more tutorials from you! Hahahaha! Some of the best Unity tutorials on KZbin and very user-friendly. I`ve bought most of your courses. Do you have a good tutorial for making a character with a grappling hook or that target and chase like in Dashing Fire?
@licantropolobo1915
@licantropolobo1915 Жыл бұрын
Magnifico video, espectacular, gracias amigo.
@devalex1429
@devalex1429 2 жыл бұрын
I was waiting for months a vídeo o this
@numberlessguy3173
@numberlessguy3173 2 жыл бұрын
SOOOOO Helpful!!!
@ayushsidam289
@ayushsidam289 2 жыл бұрын
Thanks for the video.. 😀👍
@ashtwenty12
@ashtwenty12 Жыл бұрын
OK, I think I'll check out your other videos too
@supertenchoo4271
@supertenchoo4271 2 жыл бұрын
Great Video
@TurtleGuy1527
@TurtleGuy1527 2 жыл бұрын
WHY ARE YOU ALWAYS MAKING VIDEOS ON THE EXACT THINGS I NEED AT THE EXACT TIME??? WHAT??? HOW??? :D
@staroceaniii
@staroceaniii Жыл бұрын
NICE!
@ytakedown2278
@ytakedown2278 2 жыл бұрын
Love this will defenitely use it in my projects tahnks alot for doing this alot of people must be really thankful for this video thanks so much yall should sub to him!!!!
@noobcraft5712
@noobcraft5712 2 жыл бұрын
You are the best :)
@nikomu7256
@nikomu7256 2 жыл бұрын
Amaaziiinggg!!
@missingdev0948
@missingdev0948 2 жыл бұрын
Great video, and this may be my KZbin being broken or smth but the video is slightly rotated?
@yeeyee_anime
@yeeyee_anime 11 ай бұрын
best tutorial ever man
@yeeyee_anime
@yeeyee_anime 11 ай бұрын
@Blackthornpod like literally you make unity look alot easier to use then what it looks like from other people
@FelineRaptor-gv4te
@FelineRaptor-gv4te 2 жыл бұрын
Do you have any videos on 3D? all i can see are 2d tuts. This was very helpful but can't I get the enemy to follow the player using Navmesh agent and SetDestination? or is it only for 3d?
@random_precision_software
@random_precision_software 2 жыл бұрын
Hi in my project I have spiral staircase, Ive been using 2d effector on the collider it works if your going up but when you want to go down the effects wont work. Any idea on how to solve this ?
@shabanazia2933
@shabanazia2933 2 жыл бұрын
Wow you are senior Programmer too!
@jarrydoneill7834
@jarrydoneill7834 Жыл бұрын
For the pathfinding AI and line of sight AI, how would I implement a feature where if they're close to the player or they see the player they attack?
@tristanbluu
@tristanbluu Жыл бұрын
Hello! Thank you for the video you posted, and how simple it is. I have finished the code for the shoot and retreat section of your video, and Unity is yelling at me about the object reference not being set to the instance of an object. Any idea what this means?
@josejimenez-wd5rw
@josejimenez-wd5rw 2 жыл бұрын
You're the best
@CodingKricket
@CodingKricket 2 жыл бұрын
Great tutorial I just needed this and it came up in my feed, the quality of this is amazing and I love how well you explain everything! But I have a question, I tried to do the patrol AI and I am 99% sure I wrote the code correctly although when I start the game the enemy only goes to "Element 0" patrol point and doesnt go to "Element 1" after, wait time is 1 and speed is 0.75 does anyone know what I am doing wrong?
@Blackthornprod
@Blackthornprod 2 жыл бұрын
Hey :)! Have you made sure you drag and dropped all the patrol points in the array in the inspector?
@CodingKricket
@CodingKricket 2 жыл бұрын
@@Blackthornprod Thanks for helping! yeah but for some reason it wasn't working, I did find a solution though I changed the else statement to currentPointIndex = (currentPointIndex + 1) % patrolPoints.Length; and it worked! I still don't know what went wrong before though because I would put a debug.log in the else statement and it wouldn't come up, I didn't change anything to the script besides that one line and somehow it worked! Anyways thanks so much for this amazing tutorial! It was so well done and I am definetly going to be using a lot more of your tutorials in the future!
@m00m00m1lk
@m00m00m1lk 2 жыл бұрын
@@CodingKricket Bit of a late reply so you migth not care anymore, but I found that patrolEnemy would never actually reach the exact transform of the patrolPoint, so just added a distance check similar to how the follow and Shooting enemy checks for the player distance
@CodingKricket
@CodingKricket 2 жыл бұрын
@@m00m00m1lk Great idea! Yeah, I did get it to work, but I might use that method instead. Thanks a lot!
@bordexeditor5842
@bordexeditor5842 2 жыл бұрын
@@m00m00m1lk is it working for platformer in 2D ? i have issue that when my player reach the patrolPoint it glittches a bit and they goes to the other patrol point
@danielli6665
@danielli6665 Жыл бұрын
If the line doesn't show up, remember to get rid of the collider for the Enemy
@dcry1003
@dcry1003 2 жыл бұрын
hey! question how can i turn the target script to *instead of following a gameobject* follows a tag instead? *and is using a tag recommended?*
@Brawhallavlad
@Brawhallavlad 2 жыл бұрын
Well for Patrol Ai what if i want to have multiple AI's. i tried duplicating theme but they obviusly go to the same position, does anybody has any idea of how make theme choose antoher position?
@randomideationstudios2818
@randomideationstudios2818 Жыл бұрын
Hey Blackthornprod Nice Tutorial! But can you tell me how I can flip the character according to player's position
@shabanazia2933
@shabanazia2933 2 жыл бұрын
More AI tutorial plzzz
@ThiagoPrego
@ThiagoPrego 7 ай бұрын
Thank you so very much. May the Lord bless you always.
@miguelestacio2983
@miguelestacio2983 9 ай бұрын
For the Patrol AI, I am coming across an issue: I followed everything in the video exactly and for some reason the 'currentPointIndex' is not increasing. When I make the integer public and change it manually in the inspector it seems to work fine but when I run the script normally, the gameObject reaches "Element 0" patrol point and doesn't move. Is there any chance you are able to explain what I'm possibly doing wrong? Your videos are incredibly informative and easy to understand and I've been struggling with getting a working 'enemy AI' script working for the past week.
@kaiobarbosa2436
@kaiobarbosa2436 4 ай бұрын
probably the position z value is not 0, try changing the z value of the patrol points to zero or to the same value of the player.
@hernandeztorresederjairdej5564
@hernandeztorresederjairdej5564 2 жыл бұрын
How can we do the pathfinding with dynamic obstacles?
@godonholiday
@godonholiday 2 жыл бұрын
Whats the difference with using public or Serialized?
@sathyanarayananviswanathan3770
@sathyanarayananviswanathan3770 2 жыл бұрын
well I feel like your voice changed a lot compared to previous videos. Or maybe it is the different quality of mic. But I liked the previous one. Please reply!! but anyways nice tutorial.
@AzeliaIsill
@AzeliaIsill 10 ай бұрын
i would like to ask as to how to keep the projectile to continually shoot, as it shoots 1 and then doesnt shoot it again and deletes the game object?
@emilywilkins2922
@emilywilkins2922 2 жыл бұрын
hey! Awesome video, does anyone know how I can add animation to the sprite that is attached tp the line of sight AI? when I try to add animations it spins with the line and I need the sprite to stay still, and have an animation activated the the player goes into the line of sight any suggestions?
@feeney8715
@feeney8715 Жыл бұрын
this is why you add animations before functionality
@basvanzweden6273
@basvanzweden6273 Жыл бұрын
AIPath (script) only works when my enemy is already in the scene from the start. Butt when i instantiate a prefab (with the script attached) it doesn't move. Can anyone help me?
@tegomlee
@tegomlee Жыл бұрын
What is the game at 0:30. I'm interested in learning how to make the line between the two players.
@iamcayk
@iamcayk Жыл бұрын
does this not work with tile maps? its not detecting the walls its detecting the whole grid.
@rusticdude2376
@rusticdude2376 Жыл бұрын
Definitely not a beginner friendly tutorial but a comprehensive one nonetheless
@boycececil3727
@boycececil3727 2 жыл бұрын
The art style of ya share a lot of similarities with pixel art, both is simplified form of shape(Although we can see clearly ya want more detail in ya art style) thus people won't find flaws like they do with more "realistic" art style. And basically I even can say ya style is a kind of high-poly pixel art with your original style of color using.
@WhimzyInteractive
@WhimzyInteractive 2 жыл бұрын
my shooting enemy only fires for like a second and then gives a repeating error saying that im trying to acess my deleted GameObject, any solves?
@WhimzyInteractive
@WhimzyInteractive 2 жыл бұрын
I've fixed it but now the bullets delete after an arbetrary lifespan
@thegamersplus9996
@thegamersplus9996 Жыл бұрын
Can you make some for 2-D platforms
@mattiastheisentravaille1414
@mattiastheisentravaille1414 6 ай бұрын
Help, i combined the shoot ai and raycast one but did noy work
@beckyboy1
@beckyboy1 2 жыл бұрын
I'm having an issue with the patrolling AI. For some reason whenever the enemies get to point one they don't path find to point 2. I have all of the points put into the array in the inspector but it's still not working. Does anyone know what my problem might be.
@vctor3587
@vctor3587 2 жыл бұрын
Somebody pin this. I had the same issue. Thanks so much!
@nothanksyoujoey
@nothanksyoujoey 2 жыл бұрын
I had the same issue, I removed the rigidbody2D component and it worked for me.
@Bokaley
@Bokaley Жыл бұрын
If this will help someone: points' z axis should be the same as patroller's one
@Ylvanaar
@Ylvanaar 9 ай бұрын
In case someone finds this helpful: make sure you have not set the patrol points to be child objects for the patrol enemy (like Yours Truly did for some reason), that resolved the issue of patrol enemy not finding its way to the next patrol point for me.
@caravanhati9202
@caravanhati9202 2 жыл бұрын
make a video camera fit all resolution
@user-bt4jw5jk6p
@user-bt4jw5jk6p 9 ай бұрын
Coooooooooooool
@unknownworldhindi7592
@unknownworldhindi7592 2 жыл бұрын
Bro how to learn c# please bro suggest me
@caravanhati9202
@caravanhati9202 2 жыл бұрын
how to create cutscene
@sinsgal
@sinsgal 2 жыл бұрын
FOR GOD'S SAKE PLEASE HELP ME my touch input for UI is not working and i am using unity's new input system IDK why UI is only working when i am using mouse or keyboard i have been trying to find the answer everywhere but every answer is for the unity's stone age version and if i find tutorials or answers for the new version, THEY ARE TOTALLY IRRELEVANT BCUZ THEY KEEP ON SAYING IT IS DEFAULT AND I HAVE BEEN LOOKING FOR THE ANSWER FOR MORE THAN 3 WEEKS, 24/7 I AM THINKING HOW DO I FIX THAT MY BRAIN IS STARTING TO MELT
@sinsgal
@sinsgal 2 жыл бұрын
If you can not help me can you give an advise about it
@sinsgal
@sinsgal 2 жыл бұрын
UPDATE: my game was corrupted i am not even mad right now i dont even think i will ever feel this level of happiness and satisfaction
@kiroshi7364
@kiroshi7364 2 жыл бұрын
Im still trying to learn how to use unity’s new input system i dont know why im watching this lmao
@kiroshi7364
@kiroshi7364 2 жыл бұрын
Oh its not even that complicated. I dont know why i thought ai was going to be a 200 line script
@kzltilki6716
@kzltilki6716 11 ай бұрын
It gave me an error at "Player Controller"
@kiltas9901
@kiltas9901 Жыл бұрын
Object still folow if his dead
@gg_brolol2458
@gg_brolol2458 2 жыл бұрын
Hi
@Dan-yd2jq
@Dan-yd2jq 2 жыл бұрын
I thought you were Scottish? Why do you sound French all of a sudden?!
@dogmuncher_69
@dogmuncher_69 2 ай бұрын
got a question, when you have multiple enemies in one scene, their movement messes up because they share the same script. how do i fix this?
6 DEVS Compete to Make the BEST GAME for $3,000
46:29
Blackthornprod
Рет қаралды 686 М.
Learn C# with these 9 LINES OF CODE - Unity Tutorial!
25:16
Blackthornprod
Рет қаралды 338 М.
Make me the happiest man on earth... 🎁🥹
00:34
A4
Рет қаралды 6 МЛН
Pathfinding - Understanding A* (A star)
12:52
Tarodev
Рет қаралды 113 М.
9 DEVS Make a GAME without COMMUNICATING (Where did it go Wrong?)
21:33
Blackthornprod
Рет қаралды 1,1 МЛН
2D PATHFINDING - Enemy AI in Unity
23:13
Brackeys
Рет қаралды 800 М.
6 DEVS Compete to Make the BEST GAME for $10,000
38:22
Blackthornprod
Рет қаралды 358 М.
How to make a good platforming character (Developing 6)
14:50
Game Maker's Toolkit
Рет қаралды 410 М.
3 DEVS Make a Horror Game in 3 GAME ENGINES!
15:35
Blackthornprod
Рет қаралды 418 М.
How to make AWESOME Scene Transitions in Unity!
19:45
Brackeys
Рет қаралды 915 М.
How I learned Unity without following tutorials (Developing 1)
18:11
Game Maker's Toolkit
Рет қаралды 1,9 МЛН
Mortis on Heist💀#brawlstars #shorts
0:12
Kevinn64
Рет қаралды 7 МЛН
لعبه حبار 112
0:42
عبدو
Рет қаралды 28 МЛН
👆🏼 Full video here 👆🏼 Cars vs Me Part 1
0:42
BeamNG TRY
Рет қаралды 10 МЛН
ONE MORE SUBSCRIBER FOR 6 MILLION!
0:38
Horror Skunx
Рет қаралды 15 МЛН
Bananacat VS Gman in Card Battle #gmod 😹🍌🍎
0:56
MeCoDy
Рет қаралды 19 МЛН