Simple Pathfinding Tutorial

Sdílet
Vložit
  • čas přidán 13. 07. 2024
  • 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
    🚀 Boost Your Creativity with Griffpatch
    The Griffpatch Academy will take you from "Gamer to Game Creator"
    Learn more at 👉 griffpatch.academy 👈
    😺 Scratch was developed by the Lifelong Kindergarten Group at the MIT Media Lab. See scratch.mit.edu
    ❤️ 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!

Komentáře • 1,5K

  • @geeknrd962
    @geeknrd962 Před 3 lety +783

    the reason scratch cat is still smiling, is because griffpatch kept him. and fed him apples.

  • @STEMMC
    @STEMMC Před 3 lety +277

    Me: Been working on Pac-Man Ghosts in Scratch
    griffpatch: _Uploads Pathfinding Tutorial_
    You're amazing griffpatch!

  • @jamesjunk5691
    @jamesjunk5691 Před 3 lety +69

    Its so cool seeing Griffpatch go from just a really good Scratcher to an awesome tutorial CZcamsr

  • @SirDonTheThird
    @SirDonTheThird Před 3 lety +46

    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!

  • @Firelord8447
    @Firelord8447 Před 3 lety +65

    Just as I was thinking of making a pathfinding bot in scratch.... griffpatch uploaded

  • @weepgamer
    @weepgamer Před 3 lety +188

    so excited to program this with lists and grids lol

    • @griffpatch
      @griffpatch  Před 3 lety +49

      Do you think you can give it a go yourself, or would you be waiting for the tutorial to cover it?

    • @GamePlay-rt8fc
      @GamePlay-rt8fc Před 3 lety +32

      @@griffpatch A tutorial please! :D

    • @rubenvanderark4960
      @rubenvanderark4960 Před 3 lety +17

      @@griffpatch it sounds complicated, but i know you can explain it well

    • @realBHGTV
      @realBHGTV Před 3 lety +10

      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.

    • @griffpatch
      @griffpatch  Před 3 lety +13

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

  • @Nedums
    @Nedums Před 3 lety +32

    This is why I don’t go to other CZcams channels for scratch tutorials because they most likely don’t work or outdated. Go to the king, he can teach you.

  • @hadisantamaria3391
    @hadisantamaria3391 Před 3 lety +26

    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

  • @RedToilets
    @RedToilets Před 3 lety +87

    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.

    • @trombone28
      @trombone28 Před 3 lety +5

      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.

    • @RedToilets
      @RedToilets Před 3 lety

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

    • @trombone28
      @trombone28 Před 3 lety

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

    • @TRexgamer699
      @TRexgamer699 Před 2 lety

      HOLY MOLY IS THIS WUMPUS?!?

    • @tunedoesstuff
      @tunedoesstuff Před 2 lety

      @@TRexgamer699 No this is patrick!

  • @ItzYeetus
    @ItzYeetus Před 3 lety +35

    I searched for tutorials like this SO MUCH I AM SO HAPPY!

  • @GeekSHO
    @GeekSHO Před 2 lety +9

    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.

  • @dominicspinnato5998
    @dominicspinnato5998 Před 3 lety +5

    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.

  • @jooddotcom
    @jooddotcom Před 3 lety +151

    Cool! I really love how your videos are nice and simple compared to other channels who dont explain anything.

    • @0x19
      @0x19 Před 3 lety +6

      yes! griffpatch inspired me to get into programming

    • @cutepugjoardan
      @cutepugjoardan Před 2 lety +1

      actually u r kinda true tho lol bcuz they all just put the code or whatever and dont explain lol

    • @GeometryMath3
      @GeometryMath3 Před 2 lety

      @@cutepugjoardan and some just put text! Like what if you can't read?

    • @mischiefthedegenerateratto7464
      @mischiefthedegenerateratto7464 Před 2 lety

      @@GeometryMath3 How do you use scratch or code without reading?

    • @tvpac-magic6150
      @tvpac-magic6150 Před 2 lety +2

      @@GeometryMath3 if someone can't read than i'm not sure they can code

  • @thelumberjack8838
    @thelumberjack8838 Před 3 lety +7

    I don’t even use scratch anymore but I had to watch it for my childhood thanks griffpatch

  • @clasherz_gut328
    @clasherz_gut328 Před 3 lety

    Yesss!!! Thanks so much griffpatch :D we've all been waiting for this!

  • @arielleyva7571
    @arielleyva7571 Před 3 lety +2

    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.

  • @eeeeeeeeefeeeeeeeee
    @eeeeeeeeefeeeeeeeee Před 3 lety +6

    DUDE! You have no idea how much this saved me when I was trying to design a game! TYVM!!!

  • @idontknow8029
    @idontknow8029 Před 3 lety +5

    I love your lessons, and I'm a big fan of your scratch projects. :)

  • @inspyx6818
    @inspyx6818 Před 3 lety +4

    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

    • @griffpatch
      @griffpatch  Před 3 lety +6

      Cheers :) - How time flies right!

  • @danielgamez5190
    @danielgamez5190 Před 3 lety +5

    oh! I just came back! i was with you with 20k subscribers! You have improved!

  • @tonypatino1765
    @tonypatino1765 Před 3 lety +24

    "Keep scratch cat"? Scratch cat didn't see that one coming

    • @themaydayman
      @themaydayman Před 3 lety +2

      I usually delete scratch cat then add him back in if I need him

    • @wateryagarvideos5186
      @wateryagarvideos5186 Před 3 lety +1

      @@themaydayman keep him and make him slide around in the project corner at very small size! He will appreciate that.

  • @vVearon
    @vVearon Před 3 lety +7

    i’d say your the most calming youtuber that makes scratch tutorial

  • @eliericksson.8950
    @eliericksson.8950 Před 3 lety +2

    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! :)

  • @giuseppelucacorreale5843
    @giuseppelucacorreale5843 Před 3 lety +1

    11:30 Finally griffparch uses caps!!!
    Greetings from Italy you are the best :)

    • @cst1229
      @cst1229 Před 3 lety

      All normal Scratch blocks are lowercase though.

  • @letalexalexyt4698
    @letalexalexyt4698 Před 3 lety +11

    22:22 That right cat just started revolution🤣

  • @spleeN_
    @spleeN_ Před 3 lety +7

    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!

    • @rubylikessonic2
      @rubylikessonic2 Před 11 měsíci +1

      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!

  • @gomango99
    @gomango99 Před 3 lety +1

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

  • @drevoksi
    @drevoksi Před 2 lety

    This is incredible! Like, really, really interesting! Thank you so much for making videos like this.

  • @yellow-brain4735
    @yellow-brain4735 Před 3 lety +5

    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!

    • @griffpatch
      @griffpatch  Před 3 lety +1

      Happy to help!

    • @yellow-brain4735
      @yellow-brain4735 Před 3 lety +1

      @@griffpatch :D

    • @yellow-brain4735
      @yellow-brain4735 Před 3 lety +1

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

  • @dubsisthegoat48
    @dubsisthegoat48 Před 3 lety +3

    Hey griffpatch! I love your tutorials and they are super helpful so I want to thank you for that :)

  • @Twinstars12
    @Twinstars12 Před 2 lety +1

    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.

  • @raidenxd2
    @raidenxd2 Před 3 lety

    i have been waiting since i woke up! thanks for videos every monday!

  • @jgcodes2020
    @jgcodes2020 Před 3 lety +8

    I didn't expect breadth-first search to be implemented so simply in Scratch.

    • @griffpatch
      @griffpatch  Před 3 lety +2

      IKR - I was quite pleased by how simple I got the script in the end lol

    • @39-varishpatil12
      @39-varishpatil12 Před 3 lety +1

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

  • @Denise-
    @Denise- Před 3 lety +39

    As soon as school is over I’m going to do this is python!

    • @Red_Eagle
      @Red_Eagle Před 3 lety +2

      *hacker typing itensifies*

    • @hadisantamaria3391
      @hadisantamaria3391 Před 3 lety +1

      OR C++ because scratch is based in the same thing

    • @chiroyce
      @chiroyce Před 3 lety +10

      @@hadisantamaria3391 Scratch 3.0 is based on JavaScript, not C++.

    • @geeknrd962
      @geeknrd962 Před 3 lety

      @@chiroyce yeah

    • @poendie835
      @poendie835 Před 3 lety

      @@chiroyce yeah

  • @chiroyce
    @chiroyce Před 3 lety +1

    Oh dear, this is actually what I wanted! and congrats on 1.1k likes on this video!! 😀

  • @shadow_1363
    @shadow_1363 Před 3 lety +2

    Oh wow, it's much easier than I thought. Great tutorial as well!

  • @liquidportal9082
    @liquidportal9082 Před 3 lety +4

    Awesome video! sort of reminds me of the navmesh component found in unity!

  • @SoaringSunshine
    @SoaringSunshine Před 3 lety +3

    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!

  • @ashton_yt4504
    @ashton_yt4504 Před 3 lety

    This is literally perfect! You help so much!

  • @Noentiendo-qb3ve
    @Noentiendo-qb3ve Před 3 lety

    As always, great video!

  • @christophercampbell6884
    @christophercampbell6884 Před 2 lety +4

    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.

    • @Montogoronto
      @Montogoronto Před 6 měsíci +1

      I am trying to implement the same lighting algorithm in my game, could you please explain it a bit more detailed?

  • @ItsMrGrateful
    @ItsMrGrateful Před 3 lety +5

    you say "simple programming", I say "Super complex programming that only griffpatch knew how to do until now"

    • @mr.v1ct0r
      @mr.v1ct0r Před 3 lety +1

      but it's actually really simple!

    • @Gabriel-eb7jw
      @Gabriel-eb7jw Před 3 lety

      Yep

    • @witherwraithmc
      @witherwraithmc Před 3 lety

      this is simple but some of griffpatch's other vids are real complicated
      like the tile scrolling one he's doing now

  • @crimsoncrusader8989
    @crimsoncrusader8989 Před 3 lety

    This is so cool! And everything worked out!

  • @Tealen
    @Tealen Před 3 lety +1

    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!! 😁

  • @somewhatBoring
    @somewhatBoring Před 3 lety +4

    This literally warms my heart because of the nostalgia 😌

  • @amonke5983
    @amonke5983 Před 3 lety +7

    YESSSSS HE POSTED

  • @delta_0869
    @delta_0869 Před 3 lety

    I appreciate all your help griffpatch. Even the maze tutorIal.

  • @syedmahmed6920
    @syedmahmed6920 Před 7 měsíci

    This Wonderfull, advance concepts explained in a fun and entertaining way. Griffpatch all the way !!!!!

  • @schazz3929
    @schazz3929 Před 3 lety +10

    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.

  • @milankarow6567
    @milankarow6567 Před 3 lety +4

    Videogame AI demystified by making it visible. This video is a brilliant learning tool!

    • @griffpatch
      @griffpatch  Před 3 lety +1

      Thank you, yes I did try to make is as visual as possible. I think that really helps understanding.

    • @nguyenbichhuong1208
      @nguyenbichhuong1208 Před 8 měsíci

      rarest event@@griffpatch

  • @hedgehogs_r_beast3248
    @hedgehogs_r_beast3248 Před 3 lety

    Whoa! I didn’t know you had a CZcams! 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!

  • @darklava4716
    @darklava4716 Před 3 lety

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

  • @coolminecraftguy3231
    @coolminecraftguy3231 Před 3 lety +3

    You are great griffpatch! You should be in the scratch team as you have answers to anything!

  • @oh.........
    @oh......... Před 3 lety +13

    The 1 dislike is from that person who messed up and tried again but the battery in their tablet used for CZcams was dead

    • @meghagoel4689
      @meghagoel4689 Před 3 lety

      haha! 😂🤣

    • @EdbertWeisly
      @EdbertWeisly Před 3 lety

      nah, they are the aussies that agree that Griffpatch is the true King of Scratch

    • @LandonEmma
      @LandonEmma Před 3 lety

      Then how would he dislike the video?

    • @EdbertWeisly
      @EdbertWeisly Před 3 lety

      @@LandonEmma he used a vpn

  • @OzzyVRrealone
    @OzzyVRrealone Před 3 lety +1

    Right now I'm watching your video and it's like the greatest thing ever!

  • @huntabadday2663
    @huntabadday2663 Před 3 lety

    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.

  • @ferdinandoph
    @ferdinandoph Před 3 lety +4

    Where were all these super cool tutorials when I was young and used Scratch??

  • @tsesaken
    @tsesaken Před 3 lety +7

    The most convenient timing for me and a friend's game
    Thank you, griffpatch! Best wishes!

  • @mohannune3678
    @mohannune3678 Před 3 lety

    Thanks for the tutorial griffpatch!!

  • @Lawful_Mango
    @Lawful_Mango Před 3 lety

    Now this is cool. This just made pathfinding simpler. Thank you for the video!

  • @39-varishpatil12
    @39-varishpatil12 Před 3 lety +3

    That feeling you get when you finally get sprites working as we want to after many fails........ it's so AMAZING!

  • @therealdeadend
    @therealdeadend Před 3 lety +4

    he said my name so many times :0

    • @cats4Life
      @cats4Life Před měsícem

      I don’t get it. What is your name?

  • @nimfbdhdkdm
    @nimfbdhdkdm Před 3 lety

    I love how you explain your thinking

  • @stefansuch1588
    @stefansuch1588 Před 3 lety

    Amazing tutorial! This will absolutely help making top-down shooters!

  • @linuxs
    @linuxs Před 3 lety +7

    There are no variables for a Griffpatch tutorial! 🤣

    • @griffpatch
      @griffpatch  Před 3 lety +3

      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

  • @J0hnLen1n
    @J0hnLen1n Před 3 lety +13

    Хоть я и не могу понимать это на слух, старания и талант видны и так) Hello from Russia!

    • @darkfrei2
      @darkfrei2 Před 3 lety

      Не слишком сложный английский, но кота яблоками кормить не надо.

    • @russianyoutube
      @russianyoutube Před 2 lety

      @@darkfrei2 ахахах

  • @zakahmed256
    @zakahmed256 Před 3 lety

    I like these tutorials, they are so detailed, and cool!

  • @kategacha11
    @kategacha11 Před 2 lety +2

    That was...AWESOME!

  • @danielzhang7626
    @danielzhang7626 Před 3 lety +3

    Dunno what this is but I know imma love it :D

  • @EdbertWeisly
    @EdbertWeisly Před 3 lety +5

    This is why you are the King of Scratch

  • @creativepeople9995
    @creativepeople9995 Před 3 lety

    You're amazing griffpatch!

  • @prasenjitchakraborty2320

    cool super exited to see more videos like this!

  • @thacuber2a03
    @thacuber2a03 Před 3 lety +3

    Honestly this is the first time I've ever seen you not using Run without screen refresh in a custom block 😅

  • @elvingpierre8060
    @elvingpierre8060 Před 3 lety +3

    Great tutorial! But how you get the position and clones next to the green flag?

  • @marcboss
    @marcboss Před 3 lety

    Thx Griffpatch your tutorial are easy to follow.

  • @ledu3383
    @ledu3383 Před 3 lety

    Your videos and games on scratch were awesome, hope you a good day.

  • @AzziyaisChronicallyOnline

    4th
    Also, it's my birthday, and im in the middle of playing paper minecraft lol

  • @dubsisthegoat48
    @dubsisthegoat48 Před 3 lety +15

    Interview: What is your favourite tutorial you have made?

  • @PixelZYX
    @PixelZYX Před 3 lety

    Thank you , this helps for my js game! you explain this the best

  • @Chipsyay
    @Chipsyay Před 3 lety

    Great tutorial :D this helped me with a game I'm working on :)

  • @thatduo4126
    @thatduo4126 Před 3 lety +28

    I like how you referred to Scratch Cat as "their", since so many people think Scratch Cat is male.

    • @craigdavies2598
      @craigdavies2598 Před 9 měsíci

      ‘Her’

    • @nicholasimber
      @nicholasimber Před 7 měsíci +5

      “They will be pleased.” Literally a second later: We need Him…

    • @guestive
      @guestive Před 6 měsíci +1

      0% male
      0% female
      100% goober

    • @boredyoutubeuser
      @boredyoutubeuser Před 6 měsíci

      I think he's a boy personally, since his name is Scratch, and he's orange, but yeah whatever.

    • @Saifullah_4112
      @Saifullah_4112 Před 6 měsíci +5

      Does it matter if we misgender a 2d cat made of pixels?

  • @thescratchsavy1587
    @thescratchsavy1587 Před 3 lety +4

    I hope that sometime, I'll also get so many subs with scratch only

  • @EsthermaidElderlycares

    i love this maze you made griffpatch

  • @AlexSteveScratch
    @AlexSteveScratch Před 3 lety

    Thank you for this wonderful tutorial!

  • @FeniteFr
    @FeniteFr Před 3 lety +3

    0:01 Do I pause the video every time that I watch one to see my username? Yes 😂

  • @soulwingcatshot9547
    @soulwingcatshot9547 Před 3 lety +2

    A blessing from the lord!

  • @bradyd2799
    @bradyd2799 Před 3 lety

    ball physics + this = super fun video game! Thank you griffpatch!

  • @a26lolheart
    @a26lolheart Před 3 lety

    I'm struggling with setting the target to specific objects, so this helped. Thanks!

  • @greenjc12
    @greenjc12 Před 3 lety

    griffpatch strikes again... this is awesome!

  • @dylanlamprecht3406
    @dylanlamprecht3406 Před měsícem +1

    Tysm for the smooth turning code!!!!!!!

  • @garabatosdc5610
    @garabatosdc5610 Před 3 lety +1

    I am in a tournament in scratch and I am so glad I found this chanel
    (your game paper minecraft is so cool)

  • @reglan_dev
    @reglan_dev Před 3 lety

    Great! Working amazing!

  • @apolloslickfm
    @apolloslickfm Před 3 lety

    I'm using this in conjunction with the maze generation. Thank you griffpatch!

  • @ElliAndScarletTheGuineaPigs

    This is so helpful as I'm a noob. You're the best❤️

  • @vasya_cat
    @vasya_cat Před 2 lety

    This is just what I need!

  • @razzberytman
    @razzberytman Před 2 lety

    Thanks so much! I've wanted to know how to do this for a while.

  • @real4kGaming
    @real4kGaming Před 3 lety

    The new intro is epic, keep it up!

  • @nicholasdutoit4318
    @nicholasdutoit4318 Před rokem

    this is so cool this is helping me get a better understanding of the motion blocks

  • @tiltedhorizon291
    @tiltedhorizon291 Před 3 lety

    Woah, this works seamlessly! :)

  • @witherwraithmc
    @witherwraithmc Před 3 lety

    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