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 - Игры
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 🍻
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! :)
I couldn't have said it better myself
I am a huge follower of you unity animation series...
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!
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!
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.
And afterwards I'd love to see some behavior trees.
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.
Noah and Liam are creating the most useful content related to gamedev. We are so thankful to you ❤️
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
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👍❤️!
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
please dont stop making videos my dude !! I really love your tutorials
wait I'm stuck with 2D AI for a few days now
thank you a lot! this comes out just in time
It is a very useful tutorial! I going to use everything in my game! Good job blackthorprod!
Finally you update, I have been waiting sooooo long! Every day wondering why you still haven’t updated😂
This couldn't come at a better time Thanks
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
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#.
Nice, been wanting to see this for a while!
Saving this to my must watch later! Am really excited to start learning AI 😁
your sound has changed a lot btw, nice to see you again :)
Thanks for the tutorial, i see this helping me out well in future games :)
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?
I was recently researching this topic
Got a cold Noa? Nice video. Especially the pathfinding part.
A free A* pathfinder is really a nice tool, which you can use all the time
Very helpful, thank you so much❤
I was Waiting for this 😃
Magnifico video, espectacular, gracias amigo.
definitely best channel, thank you so much
Well done as always
WHY ARE YOU ALWAYS MAKING VIDEOS ON THE EXACT THINGS I NEED AT THE EXACT TIME??? WHAT??? HOW??? :D
I was waiting for months a vídeo o this
OK, I think I'll check out your other videos too
SOOOOO Helpful!!!
Amazing!
Thanks for the video.. 😀👍
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!!!!
Amaaziiinggg!!
You are the best :)
Great video, and this may be my RUclips being broken or smth but the video is slightly rotated?
Great Video
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?
best tutorial ever man
@Blackthornpod like literally you make unity look alot easier to use then what it looks like from other people
Thank you so very much. May the Lord bless you always.
NICE!
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?
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.
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.
Hey Blackthornprod
Nice Tutorial! But can you tell me how I can flip the character according to player's position
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?
Wow you are senior Programmer too!
You're the best
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 ?
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.
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?
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?
Hey :)! Have you made sure you drag and dropped all the patrol points in the array in the inspector?
@@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!
@@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
@@m00m00m1lk Great idea! Yeah, I did get it to work, but I might use that method instead. Thanks a lot!
@@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
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?*
If the line doesn't show up, remember to get rid of the collider for the Enemy
More AI tutorial plzzz
Can you make some for 2-D platforms
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.
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?
How can we do the pathfinding with dynamic obstacles?
What is the game at 0:30. I'm interested in learning how to make the line between the two players.
Whats the difference with using public or Serialized?
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?
this is why you add animations before functionality
Definitely not a beginner friendly tutorial but a comprehensive one nonetheless
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?
does this not work with tile maps? its not detecting the walls its detecting the whole grid.
Help, i combined the shoot ai and raycast one but did noy work
make a video camera fit all resolution
Bro how to learn c# please bro suggest me
Coooooooooooool
It gave me an error at "Player Controller"
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?
I've fixed it but now the bullets delete after an arbetrary lifespan
how to create cutscene
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.
Somebody pin this. I had the same issue. Thanks so much!
I had the same issue, I removed the rigidbody2D component and it worked for me.
If this will help someone: points' z axis should be the same as patroller's one
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.
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
If you can not help me can you give an advise about it
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
Object still folow if his dead
Im still trying to learn how to use unity’s new input system i dont know why im watching this lmao
Oh its not even that complicated. I dont know why i thought ai was going to be a 200 line script
Hi
I thought you were Scottish? Why do you sound French all of a sudden?!
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?