Simple Pathfinding Tutorial
Ever wondered how that enemy AI manages to move through a level, navigating around corners, skipping dead-ends, and finding that shortest route to the player through a maze? I’m griffpatch, and today we will be delving into the world of enemy AI pathfinding and learn how to code a simple path finding script using Scratch to solve a maze.
We will cover:
• creating a simple maze or level in the costume editor
• Setting a goal
• Working backwards from the goal to create a pathway map of the level
• Teaching Scratch cat to follow the map
• A quick and smooth rotate towards block
• Add in many sprite clones searching out the same target
• And finally dynamic target changing
⭐ Support this channel - Join to get access to perks:
/ @griffpatch
❤️ Enhanced Scratch Developer Tools
www.griffpatch.co.uk/
📹 The Awesome Video Editing software I use (Camtasia)
techsmith.z6rjha.net/5bajbo
Hope you enjoy!!! And Scratch On!
the reason scratch cat is still smiling, is because griffpatch kept him. and fed him apples.
I have a scratch cat in some of my projects. It's sleeping
Mostly because griffpatch fed him apples.
ha ha
ye
@@peej10do91 definitely.
Me: Been working on Pac-Man Ghosts in Scratch griffpatch: _Uploads Pathfinding Tutorial_ You're amazing griffpatch!
I was working on the exact same thing lmao
All of that ×2
but why?
69 like!! Lol
I was also thinking about making Pac Man
Ive moved away from scratch to use some more powerful engines but I still love coming here and learning the creative solutions you came up with to get past what I thought were the limitations of scratch. Keep up the great work!
Its so cool seeing Griffpatch go from just a really good Scratcher to an awesome tutorial KZheadr
This is even better than part 9 of the tile scrolling platformer. You actually get to learn something here and how to code this for enemy AI games instead of copying code because after a few parts of a project you start to not care so much about the code and only about the final product.
In the tile scrolling platformer, if you just copy the scripts, it's your own fault. Next time, before you do, try to understand what's happening, and teach yourself how it works.
@@trombone28 I'm saying that I try to learn something and I copy what griffpatch does. I understand what he's doing but I don't understand how the code does that sometimes. For example, part 6.
@@AntiFreeMarket I see. What you should do then is try to break apart the code into smaller pieces, and watch the video bit by bit to try and better understand how everything works together, but I get your point.
HOLY MOLY IS THIS WUMPUS?!?
@@TRexgamer699 No this is patrick!
This is why I don’t go to other KZhead channels for scratch tutorials because they most likely don’t work or outdated. Go to the king, he can teach you.
so excited to program this with lists and grids lol
Do you think you can give it a go yourself, or would you be waiting for the tutorial to cover it?
@@griffpatch A tutorial please! :D
@@griffpatch it sounds complicated, but i know you can explain it well
I already tried it with a "controled cloning" system. That means that i have a generator and every clone has its specific number so you can add things like a x or y coordinate in a list. But pathfinding is something that i need to learn with this system.
@@rubenvanderark4960 there are a few more scripts to put in place, but once you are comfortable using them it actually really free things up to be very cool indeed
This is amazing! Griffpatch, please know how incredible your projects are, but also these video contributions to the community. I teach computer programming, and I often use Scratch for many of my students. These tutorials help me teach students some really cool tricks.
Just as I was thinking of making a pathfinding bot in scratch.... griffpatch uploaded
Same
Same
Same
I searched for tutorials like this SO MUCH I AM SO HAPPY!
Amazing piece of smart scripting! I used scratch a lot when I was younger, and although i don't do visual scripting that much, i still appreciate just how elegant and simple the programming was. Specially the "when not touching black" part, i love how that killed two birds with one stone.
DUDE! You have no idea how much this saved me when I was trying to design a game! TYVM!!!
22:22 That right cat just started revolution🤣
Top left as well
Cool! I really love how your videos are nice and simple compared to other channels who dont explain anything.
yes! griffpatch inspired me to get into programming
actually u r kinda true tho lol bcuz they all just put the code or whatever and dont explain lol
@@cutepugjoardan and some just put text! Like what if you can't read?
@@battleforDreamIsland4G41N How do you use scratch or code without reading?
@@battleforDreamIsland4G41N if someone can't read than i'm not sure they can code
3D raycast with multi layering would be amazing for next tutorial, It would be hard to do for beginners,But you really know how to explain and make it look simple
woah ur wish came true, he made a series already!
@@brodixthepumpkinwhowantmango not multi layering tho
Just wanted to thank Griffpatch for getting me into coding. Two years ago, I stumbled upon Scratch and signed up for it. I began watching your videos and now I have a job for coding. I start tomorrow. This will be my first job at the age of fifteen. Without Griffpatch, I don't think I would've ever picked up an interest in coding.
Congo bro
awesome
I personally don't use scratch, but this tutorial is still an amazing breakdown of how to set up a good pathfinding system. This video perfectly breaks down the essentials of pathfinding and make it easy to understand. Good job!
ikr, I literally came here cuz I remembered watching this when I did use scratch and I needed a path finding method for a non scratch game!
Thank you for helping me and many others understand complicated ideas with your help full videos! It really helps me and I encourage you to keep doing so, and Scratch on!
Happy to help!
@@griffpatch :D
@@griffpatch I really like your remake of Terraria. One thing that interests me is the map generation, and I would LOVE to see a tutorial on it!
I just got memories of going on scratch in awe of this guy's creations!! Honestly I remember everyone in school rushing to the computor room to play paper minecraft like it was yesterday!!
Yesss!!! Thanks so much griffpatch :D we've all been waiting for this!
I don’t even use scratch anymore but I had to watch it for my childhood thanks griffpatch
:D
i’d say your the most calming youtuber that makes scratch tutorial
You inspire me so much, and these tutorials are SUPER helpful even if I only watch them to understand how it works!!! Keep up the good work, these are the highlights of my Mondays! :)
Glad you like them!
I learned a new way to make sprite move. Really helped in other projects. Thank you. Just like this other videos are amazing and interesting.
I love your lessons, and I'm a big fan of your scratch projects. :)
I'm pretty amazed by the way color detection is used. Also I learned that scaling down an offscreen object wouldn't make him go onscreen again. Very smart design, even though it might create a bit too much lag in a larger scale project because of the clones being used. Also, I think you could make arrows invisible by just making them ghost 100, color detection would still work.
I don't do much programming in scratch (Only for school when we had to), but I can still use these concepts for other languages like assembly. This video is high quality right from the start and this idea is so good that I will open up scratch just to do it.
OMG! Thank you!!!!!! What a coincidence, im making a game where i need a path finding object and started yesterday and you upload this? Thanks!! 😁
Awesome video! sort of reminds me of the navmesh component found in unity!
This is amazing! I will definitely try this. BTW, Scratch Add-ons is awesome! I love everything about it! Thanks for making Scratch so much better!
yep we're awesome
@@ScratchAddons Yess!!
This is incredible! Like, really, really interesting! Thank you so much for making videos like this.
Whoa! I didn’t know you had a KZhead! I just follow you on Scratch, that’s so cool you popped up on my recommended! You’ve inspired me for years to create games, and I think your games are the coolest!
oh! I just came back! i was with you with 20k subscribers! You have improved!
I was with him since 18k man he grew so fast
@@rsrk.2601 yeah!
0:23 Paper Minecraft and the pathfinder are linked because they share a filling algorithm. In the game, the light source will have a "infected" tile with a light value of 5 or something. Then that tile will infect other tiles around it and subtract 1 from the parent.
I am trying to implement the same lighting algorithm in my game, could you please explain it a bit more detailed?
I love how you explain your thinking
i have been waiting since i woke up! thanks for videos every monday!
Hey griffpatch! I love your tutorials and they are super helpful so I want to thank you for that :)
Hello
The most convenient timing for me and a friend's game Thank you, griffpatch! Best wishes!
Awesome tutorial! Such an advanced topic for scratch, brought down to a level that's easy to understand level for beginners, and yet functions fairly well! Now to see how advanced I can make this...
this is so cool this is helping me get a better understanding of the motion blocks
I remember playing your projects roughly 6-7 years ago back when i used scratch (the golden days). Was just taken back to this by nostalgia. So glad to see youre teaching a new generation of scratchers how to block code. Godspeed
Cheers :) - How time flies right!
This literally warms my heart because of the nostalgia 😌
Oh wow, it's much easier than I thought. Great tutorial as well!
I appreciate all your help griffpatch. Even the maze tutorIal.
"Keep scratch cat"? Scratch cat didn't see that one coming
I usually delete scratch cat then add him back in if I need him
@@themaydayman keep him and make him slide around in the project corner at very small size! He will appreciate that.
I like how you referred to Scratch Cat as "their", since so many people think Scratch Cat is male.
‘Her’
“They will be pleased.” Literally a second later: We need Him…
0% male 0% female 100% goober
I think he's a boy personally, since his name is Scratch, and he's orange, but yeah whatever.
Does it matter if we misgender a 2d cat made of pixels?
This is literally perfect! You help so much!
I'm struggling with setting the target to specific objects, so this helped. Thanks!
I didn't expect breadth-first search to be implemented so simply in Scratch.
IKR - I was quite pleased by how simple I got the script in the end lol
@@griffpatch at 22:20 you will notice a scratch cat at the top of the maze going somewhere else ,why is that?. is that a bug?
You are great griffpatch! You should be in the scratch team as you have answers to anything!
Agreed
11:30 Finally griffparch uses caps!!! Greetings from Italy you are the best :)
All normal Scratch blocks are lowercase though.
Oh dear, this is actually what I wanted! and congrats on 1.1k likes on this video!! 😀
That feeling you get when you finally get sprites working as we want to after many fails........ it's so AMAZING!
Videogame AI demystified by making it visible. This video is a brilliant learning tool!
Thank you, yes I did try to make is as visual as possible. I think that really helps understanding.
rarest event@@griffpatch
Now this is cool. This just made pathfinding simpler. Thank you for the video!
This is so cool! And everything worked out!
As soon as school is over I’m going to do this is python!
*hacker typing itensifies*
OR C++ because scratch is based in the same thing
@@hadisantamaria3391 Scratch 3.0 is based on JavaScript, not C++.
@@chiroyce yeah
@@chiroyce yeah
Dunno what this is but I know imma love it :D
Amazing tutorial! This will absolutely help making top-down shooters!
That was...AWESOME!
Where were all these super cool tutorials when I was young and used Scratch??
YESSSSS HE POSTED
yes!!!
Right now I'm watching your video and it's like the greatest thing ever!
OMG THANKS THIS WAS REALLY HELPFUL
you say "simple programming", I say "Super complex programming that only griffpatch knew how to do until now"
but it's actually really simple!
Yep
this is simple but some of griffpatch's other vids are real complicated like the tile scrolling one he's doing now
Хоть я и не могу понимать это на слух, старания и талант видны и так) Hello from Russia!
Не слишком сложный английский, но кота яблоками кормить не надо.
@@darkfrei2 ахахах
Thanks for the tutorial griffpatch!!
I'm using this in conjunction with the maze generation. Thank you griffpatch!
The 1 dislike is from that person who messed up and tried again but the battery in their tablet used for KZhead was dead
haha! 😂🤣
nah, they are the aussies that agree that Griffpatch is the true King of Scratch
Then how would he dislike the video?
@@LandonEmma he used a vpn
There are no variables for a Griffpatch tutorial! 🤣
He he - I actually purposefully did that this time - However, to make this even more useful we would start to bring them in again lol
As always, great video!
This Wonderfull, advance concepts explained in a fun and entertaining way. Griffpatch all the way !!!!!
Great tutorial! But how you get the position and clones next to the green flag?
You need Scratch Add-Ons
@@griffpatch Ok, thanks!
Honestly this is the first time I've ever seen you not using Run without screen refresh in a custom block 😅
wdym
yeah i guess
Griffpatch is real Bob Ross of scratch
I put this script in the Maze generating project. It worked. It's very cool.
This is why you are the King of Scratch
4th Also, it's my birthday, and im in the middle of playing paper minecraft lol
happy birthday 🎉
@@thacuber2a03 ty
happy birthday you bundle of joy
this is actually really cool. i was thinking the easiest pathfinding method would be complicated to code but you cracked it, and it works really well. you never fail to amaze me griffpatch :)
Thx Griffpatch your tutorial are easy to follow.
I hope that sometime, I'll also get so many subs with scratch only
Interview: What is your favourite tutorial you have made?
@Dhiviyesh Akilathasan it was a joke, u weren’t sapost to replie bu ok...
Logo looks by pressing space to switch costumes!!!!
Love you Henry Wolfe❤️
Love you❤️
@@belkamelka07 Do you know me from scratch?
Thank you for this wonderful tutorial!
You are so welcome!
Thank you , this helps for my js game! you explain this the best
0:01 Do I pause the video every time that I watch one to see my username? Yes 😂
Dude that is cool
he said my name so many times :0
Your videos and games on scratch were awesome, hope you a good day.
I like these tutorials, they are so detailed, and cool!
A blessing from the lord!
参考になります!有難うございます!!!!
Wow can you see the future this is exactly what I need for my new shooter.
this is great. I have been trying to create a pac man game with ghosts for a while now but i have not figured out how until I saw this. It really helps
A very simple yet effective method, thank you for this tutorial.
You're welcome!
Yeah, I can finally finish my game. Thank you so much!!!!😁😀
cool super exited to see more videos like this!
Thanks so much! I've wanted to know how to do this for a while.
this project is simply amazing
Thank u Griffpatch again!!
I am in a tournament in scratch and I am so glad I found this chanel (your game paper minecraft is so cool)
Griffpatch, you are the reason I've used to be on Scratch for my childhood. You make the best games on Scratch. Never knew you had a yt
I do!