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

Поделиться
HTML-код
  • Опубликовано: 11 май 2024
  • 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 года назад +69

    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 года назад +1

      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...

  • @amandaflood
    @amandaflood 2 года назад +4

    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 года назад +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!

  • @this-is-gamedev
    @this-is-gamedev 2 года назад +37

    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 Год назад +2

      And afterwards I'd love to see some behavior trees.

  • @petipois28
    @petipois28 2 года назад +6

    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 года назад +3

    Noah and Liam are creating the most useful content related to gamedev. We are so thankful to you ❤️

  • @TheStigChristensen
    @TheStigChristensen 2 года назад +7

    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

  • @leonaise7546
    @leonaise7546 2 года назад +3

    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 Год назад +1

    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

  • @ghiancarlostan8730
    @ghiancarlostan8730 2 года назад +1

    please dont stop making videos my dude !! I really love your tutorials

  • @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

  • @waltergamedev3664
    @waltergamedev3664 2 года назад +1

    It is a very useful tutorial! I going to use everything in my game! Good job blackthorprod!

  • @boycececil3727
    @boycececil3727 2 года назад

    Finally you update, I have been waiting sooooo long! Every day wondering why you still haven’t updated😂

  • @aureola00
    @aureola00 2 года назад

    This couldn't come at a better time Thanks

  • @pudgystump
    @pudgystump 2 года назад +1

    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

  • @Yipper64
    @Yipper64 2 года назад +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#.

  • @tristancowen5636
    @tristancowen5636 2 года назад

    Nice, been wanting to see this for a while!

  • @ItsMePhoebe
    @ItsMePhoebe 2 года назад +1

    Saving this to my must watch later! Am really excited to start learning AI 😁

  • @DailyFootballEditsDFE
    @DailyFootballEditsDFE 2 года назад +2

    your sound has changed a lot btw, nice to see you again :)

  • @SoYo135
    @SoYo135 2 года назад

    Thanks for the tutorial, i see this helping me out well in future games :)

  • @cre8tivemediavault72
    @cre8tivemediavault72 2 года назад

    Hey! I`ve been waiting for more tutorials from you! Hahahaha! Some of the best Unity tutorials on RUclips 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?

  • @harrington8
    @harrington8 2 года назад +1

    I was recently researching this topic

  • @andymitchell2146
    @andymitchell2146 2 года назад +1

    Got a cold Noa? Nice video. Especially the pathfinding part.

  • @KeyboardKrieger
    @KeyboardKrieger 2 года назад +3

    A free A* pathfinder is really a nice tool, which you can use all the time

  • @BlueHat1
    @BlueHat1 Год назад

    Very helpful, thank you so much❤

  • @Govi-fu1ti
    @Govi-fu1ti 2 года назад +1

    I was Waiting for this 😃

  • @licantropolobo1915
    @licantropolobo1915 Год назад

    Magnifico video, espectacular, gracias amigo.

  • @Gh0stzZ1
    @Gh0stzZ1 2 года назад +1

    definitely best channel, thank you so much

  • @megateamaj
    @megateamaj 2 года назад

    Well done as always

  • @TurtleGuy1527
    @TurtleGuy1527 2 года назад +1

    WHY ARE YOU ALWAYS MAKING VIDEOS ON THE EXACT THINGS I NEED AT THE EXACT TIME??? WHAT??? HOW??? :D

  • @devalex1429
    @devalex1429 2 года назад

    I was waiting for months a vídeo o this

  • @ashtwenty12
    @ashtwenty12 Год назад

    OK, I think I'll check out your other videos too

  • @numberlessguy3173
    @numberlessguy3173 2 года назад

    SOOOOO Helpful!!!

  • @memez4life191
    @memez4life191 2 года назад +1

    Amazing!

  • @ayushsidam289
    @ayushsidam289 2 года назад

    Thanks for the video.. 😀👍

  • @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!!!!

  • @nikomu7256
    @nikomu7256 2 года назад

    Amaaziiinggg!!

  • @noobcraft5712
    @noobcraft5712 2 года назад

    You are the best :)

  • @missingdev0948
    @missingdev0948 2 года назад

    Great video, and this may be my RUclips being broken or smth but the video is slightly rotated?

  • @supertenchoo4271
    @supertenchoo4271 2 года назад

    Great Video

  • @AzeliaIsill
    @AzeliaIsill 9 месяцев назад

    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?

  • @yeeyee_anime
    @yeeyee_anime 10 месяцев назад

    best tutorial ever man

    • @yeeyee_anime
      @yeeyee_anime 10 месяцев назад

      @Blackthornpod like literally you make unity look alot easier to use then what it looks like from other people

  • @ThiagoPrego
    @ThiagoPrego 6 месяцев назад

    Thank you so very much. May the Lord bless you always.

  • @staroceaniii
    @staroceaniii Год назад

    NICE!

  • @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?

  • @miguelestacio2983
    @miguelestacio2983 8 месяцев назад

    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 3 месяца назад

      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.

  • @randomideationstudios2818
    @randomideationstudios2818 Год назад

    Hey Blackthornprod
    Nice Tutorial! But can you tell me how I can flip the character according to player's position

  • @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?

  • @shabanazia2933
    @shabanazia2933 2 года назад

    Wow you are senior Programmer too!

  • @josejimenez-wd5rw
    @josejimenez-wd5rw 2 года назад

    You're the best

  • @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 ?

  • @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.

  • @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?

  • @CodingKricket
    @CodingKricket 2 года назад +5

    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 года назад +2

      Hey :)! Have you made sure you drag and dropped all the patrol points in the array in the inspector?

    • @CodingKricket
      @CodingKricket 2 года назад +1

      @@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

  • @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?*

  • @danielli6665
    @danielli6665 Год назад

    If the line doesn't show up, remember to get rid of the collider for the Enemy

  • @shabanazia2933
    @shabanazia2933 2 года назад

    More AI tutorial plzzz

  • @thegamersplus9996
    @thegamersplus9996 Год назад

    Can you make some for 2-D platforms

  • @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.

  • @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?

  • @hernandeztorresederjairdej5564
    @hernandeztorresederjairdej5564 2 года назад

    How can we do the pathfinding with dynamic obstacles?

  • @tegomlee
    @tegomlee Год назад

    What is the game at 0:30. I'm interested in learning how to make the line between the two players.

  • @godonholiday
    @godonholiday 2 года назад

    Whats the difference with using public or Serialized?

  • @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

  • @rusticdude2376
    @rusticdude2376 Год назад

    Definitely not a beginner friendly tutorial but a comprehensive one nonetheless

  • @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?

  • @iamcayk
    @iamcayk Год назад

    does this not work with tile maps? its not detecting the walls its detecting the whole grid.

  • @mattiastheisentravaille1414
    @mattiastheisentravaille1414 5 месяцев назад

    Help, i combined the shoot ai and raycast one but did noy work

  • @caravanhati9202
    @caravanhati9202 2 года назад +1

    make a video camera fit all resolution

  • @unknownworldhindi7592
    @unknownworldhindi7592 2 года назад

    Bro how to learn c# please bro suggest me

  • @user-bt4jw5jk6p
    @user-bt4jw5jk6p 8 месяцев назад

    Coooooooooooool

  • @kzltilki6716
    @kzltilki6716 10 месяцев назад

    It gave me an error at "Player Controller"

  • @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

  • @caravanhati9202
    @caravanhati9202 2 года назад

    how to create cutscene

  • @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 Год назад +2

      If this will help someone: points' z axis should be the same as patroller's one

    • @Ylvanaar
      @Ylvanaar 8 месяцев назад

      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.

  • @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

  • @kiltas9901
    @kiltas9901 Год назад

    Object still folow if his dead

  • @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

  • @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 Месяц назад

    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?