Pathfinding - Understanding A* (A star)

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 พ.ค. 2024
  • Pathfinding can be a fundamental component of your game. Truly understanding how it works gives you fine-grained control of how units interact with the environment.
    Learn how A* pathfinding truly works by diving deep into the mechanics. We'll go step by step through each process as well as cover the edge cases not often talked about.
    Repo: github.com/Matthew-J-Spencer/...
    ❤️ Become a Tarobro on Patreon: / tarodev
    =========
    🔔 SUBSCRIBE: bit.ly/3eqG1Z6
    🗨️ DISCORD: / discord
    ✅ MORE TUTORIALS: / tarodev

ความคิดเห็น • 156

  • @brittinfontenot3544
    @brittinfontenot3544 6 หลายเดือนก่อน +39

    I have a degree in Computer Science. I taught algorithm analysis in college. I've been a developer for more than 10 years. This is hands down the best introduction and demonstration to A* I've seen on youtube. Concise, comes with visual examples, comes with code, and comes wiht references to other videos. WELL DONE DUDE. You just made my day.

  • @akmaludddin9281
    @akmaludddin9281 23 วันที่ผ่านมา +1

    its either the viewer is smart enough to understand your video or your way of teaching is so good that even i can understand the A* pathfinding. but the most importantly, u give us the code :D I hope you all have a fun and great days, Thx!

  • @chchappa
    @chchappa 2 ปีที่แล้ว +92

    The time you took to make it so visual, I really appreciate it. I've never tried pathfinding and I am delaying its implementation in my own game just cuz it looked very difficult. But your explanation and way of showing so graphically for every step made it really helpful.
    Thanks and I hope this channel keeps growing.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +12

      Thanks for saying that! It makes the large time investment worth while.

    • @MatthewAWinston
      @MatthewAWinston 2 ปีที่แล้ว

      ​@@Tarodev Clear thinking, clear explanation, and clear visuals. Top notch! Had me subscribe right away.

  • @Paul-zh2jp
    @Paul-zh2jp 2 ปีที่แล้ว +69

    there aren't enough tutorials (in general) that just look at code and explain it. it feels like a better use of my time than watching someone type. ty for that. i'm also always surprised how your videos are about something commonly needed but that i've rarely seen covered

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +14

      This is a topic I constantly flip back and forth on (explaining typed code, or typing live). I did a poll months ago and most people said they prefer it being typed live, as it shows the thought process better, but obviously more advanced devs prefer pre-typed. So I do a bit of both.
      Glad you liked it!

  • @sc4334
    @sc4334 2 ปีที่แล้ว +16

    I went from day 1 feeling like this was impossible, to day 3 creating my entirely own method of implementing A* pathfinding because of how you explained the rules so in depth. It's much better to have a video like this where it explains the concept and rules / fundamentals rather than just doing it and saying to copy it. Thank you very much for your work on this. Saved my life!

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      That's amazing man, well done!

  • @julia_petcos
    @julia_petcos 2 ปีที่แล้ว +4

    Mark my words this video is about to blowup

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Bless you

  • @SpencerYonce
    @SpencerYonce 5 หลายเดือนก่อน

    I can't thank you enough for this video. No one has ever made a video that made me fully understand the algorithm like this one. Simple and to the point. Thank you greatly.

  • @lynnnr1319
    @lynnnr1319 2 ปีที่แล้ว +1

    What a timely upload! I was just finishing writing some work and reviewing A* was one of the things I had left to finish it. Thanks for the great explanation and presentation!

  • @MegaLolStorm
    @MegaLolStorm 2 ปีที่แล้ว +4

    I came across your videos a few weeks ago and ever since I was hooked. you explain concepts so well and so clearly. Keep up the great work!

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Thank you so much! Glad to have you on board

  • @JW-uu9je
    @JW-uu9je 8 หลายเดือนก่อน

    Thank you kindly for the download. I followed both yours and Code Monkeys tutorials on grids and pathfinding. I learned a lot, but a lot is also way over my head. The download works seamlessly and I am excited to dive into the code! Thanks for all that you do :)

  • @minigun62
    @minigun62 2 ปีที่แล้ว

    This is exactly what I've been looking for thanks for the video man, really explains it nicely.

  • @thepizzafoogle5481
    @thepizzafoogle5481 2 ปีที่แล้ว +1

    Thanks very much for this tutorial, its straightforward and explains things well!

  • @broneslav547
    @broneslav547 2 ปีที่แล้ว +1

    Wow, great work! Pure and simple

  •  ปีที่แล้ว +1

    That was such a great explanation. Thank you 😊

  • @rize2137
    @rize2137 2 ปีที่แล้ว +1

    Hey, wanted to say that I enjoy your simple format of these videos.
    Even tho I already understand topics you present it's still enjoyable.
    And these eye-candy effects and graphics do a lot!

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Glad they are still entertaining even if you know the topic! Thanks mate

  • @_g_r_m_
    @_g_r_m_ 2 ปีที่แล้ว +36

    I thought it was way more complicated, but it's pretty straightforward.
    btw i would like a video on optimization

    • @gadgetboyplaysmc
      @gadgetboyplaysmc 2 ปีที่แล้ว +1

      Same would love a video on optimization. Sebastian has done something with Binary Trees apparently, but I couldn't get my head wrapped around it haha

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +6

      @@gadgetboyplaysmc His implementation is very good (obviously, it's Sebastian), but I could certainly do it in the next video in a more beginner-friendly way.
      Or maybe I could just do a general binary tree video explaining how it works and mention at the end "By the way, you could use this to replace the F cost calculation in A*". I'll have a think

    • @shannonrowe9402
      @shannonrowe9402 2 ปีที่แล้ว +2

      @@Tarodev One quick win is to change the processed list to be a HashSet, for quicker .Contains checks. And then yeah, a min heap tree for the search list, which takes a fair bit more work. It's also possible to convert everything to Burst and C# Jobs, including the heap - I've done it, but it sure took a lot of head-scratching and probably wouldn't make for an easily explainable YT video. Anyway, great job on this one making the general A* principles easy to understand.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +2

      @@shannonrowe9402 Ohhhh, the hashset is something I didn't think about! Very interesting.

    • @pliniomourao
      @pliniomourao 2 ปีที่แล้ว +2

      I will just say but i don't recommend go into it without learning and playing alot, but implementing A* with JOBS (ECS) have an huge performance impact.
      I tested it and it's faster and can utilize all the threads your CPU may offer decreasing the amount of work for a result. Specially in bigger maps.

  • @PandemoniumGameDev
    @PandemoniumGameDev 2 ปีที่แล้ว

    Nicely explained and a great presentation, subbed!

  • @judasdedalosson8105
    @judasdedalosson8105 5 หลายเดือนก่อน

    Wow really good explanation of the algorithm! Very informative and to the point. No unneccessary talking but still all the information needed! Great video! Thanks to you I understood simply how to implement this algorithm in just 20 minutes (stopping your video when coding myself)! Great video! Thank you very much!

  • @SayedSafwan
    @SayedSafwan 2 ปีที่แล้ว +1

    Amazing as Always!Keep it up!

  • @Hassanali-jr4yb
    @Hassanali-jr4yb ปีที่แล้ว +1

    amazingly done & thanks i' have never done any algorithm myself but think this would be the first one, subscribed for more.

  • @gadgetboyplaysmc
    @gadgetboyplaysmc 2 ปีที่แล้ว +2

    I swear to God, your videos are the best. I always loved watching Sebastian Lague's videos on these. You go into them with so much detail and I really appreciate it. What's the secret?

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +2

      Even mentioning Sebastian in the same sentence as me is an honor. The secret is I get fueled by comments like this and seeing how I help people, so thank you!

  • @MrJanos
    @MrJanos 2 ปีที่แล้ว +1

    This was an extremely good video and the apps look REALLY educative and fresh! I have to learn and try to spread these programs for you! It is amazing how such simple applications can explain so much! MUCH LOVE FROM SWEDEN!

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +1

      Thanks Jonas from sweden!

  • @stephenkirby6788
    @stephenkirby6788 2 ปีที่แล้ว +1

    Top tier/very professional, in both production and subject matter explanation.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Thanks buddy

  • @d_ogo
    @d_ogo หลายเดือนก่อน

    amazing, simply so good that it was enough for me to learn and also enjoy...

  • @pa_de_queijo
    @pa_de_queijo 2 ปีที่แล้ว

    You are SPETACULAR!
    Most simple/complete A* video I've ever seen.
    It just works as magic!

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Ah, why thank you 😊

  • @VikkersOlfsson
    @VikkersOlfsson ปีที่แล้ว

    Legendary A* walk through. A hero the people need!

    • @Tarodev
      @Tarodev  ปีที่แล้ว +2

      Thinking about re releasing this with a few editing fixes

  • @libberator5891
    @libberator5891 2 ปีที่แล้ว +1

    I give this video an A*!!
    That intro though 🔥🔥🔥

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      That's cheesy bro

  • @DerAua
    @DerAua 2 ปีที่แล้ว

    Very good explanation!

  • @ragerungames
    @ragerungames 2 ปีที่แล้ว +2

    man this is amazing. Previous video I watched on A* was going above from my head and I couldn't understand the meaning of G and H cost, from this everything is clear from the first minute of the video. Thank you for creating amazing content. I can imagine where your youtube channel gonna be in near future!

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Thank you so much! This is exactly what I set out to provide in this video, so that makes me happy 😊

    • @ragerungames
      @ragerungames 2 ปีที่แล้ว

      @@Tarodev Hope to see some small game tutorial series (with intermediate concepts) on your channel in parts soon 😍

    • @Vastlee
      @Vastlee 2 ปีที่แล้ว

      It's probably because the other tutorial said "H Cost". Here it's careful explained as Haych Cast. Much easier to comprehend.

  • @datablob
    @datablob 2 ปีที่แล้ว +2

    Excellent stuff as always!

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Love you blobby

  • @hagen.360
    @hagen.360 7 หลายเดือนก่อน

    Very interesting!
    Thank you!

  • @user-dg6ue1tx6w
    @user-dg6ue1tx6w 4 หลายเดือนก่อน

    You are a genius Sir, Salute!!!

  • @money_hyde
    @money_hyde 6 หลายเดือนก่อน +1

    Jessussssssssss man FINALLY a video I understand

  • @robelso5646
    @robelso5646 ปีที่แล้ว +5

    Hey amazing tutorial! One small piece of constructive criticism, I think reading the code would be much more clear if instead of using the var keyword you used the variable type, other than that, stunning tutorial!

  • @istegal8079
    @istegal8079 2 ปีที่แล้ว +2

    Hello, I would be very interested in the optimization follow up, and also in a fix for units moving through gaps vertically. I don’t really know how to explain it, but basically if two blocks are diagonal to each other the unit can pass between them, assuming you allow diagonal movement on a square grid

  • @nopens
    @nopens ปีที่แล้ว

    Thank you. I still have troubles understanding how it works but it does. My implementation on pygame does indeed find the shortest path after watching this video.

  • @DanPos
    @DanPos 2 ปีที่แล้ว +1

    Nice, will be sure to watch this on lunch later!

    • @DanPos
      @DanPos 2 ปีที่แล้ว

      Awesome stuff and well explained - I actually prefer this method of not doing it the most optimised way at first, just to get your head around the concept, a lot of other tutorials out there set off to be the most highly efficient way of doing it but then it just gets confusing about what actually is the core basics of the algorithm. I'll have to check out the code monkey video on the job system version out of curiosity.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      @@DanPos I started out with pure optimization and then when I went to explain it, it was way too convoluted. I'm glad I dumbed it way down. Code monkeys tutorial for example is hyper-optimized (the jobs one, not his first one), but very hard to follow for new devs.

  • @hamedbabamohamadi9017
    @hamedbabamohamadi9017 2 ปีที่แล้ว +1

    One epic music on an epic video! well done.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Intro wasn't too dramatic? 😂

    • @hamedbabamohamadi9017
      @hamedbabamohamadi9017 2 ปีที่แล้ว +1

      @@Tarodev that was awsome :))

  • @CaptainGerBear
    @CaptainGerBear 8 หลายเดือนก่อน

    I had to shave and finesse in order to get this to work in my project, but extremely helpful overall, thank you very much.

    • @Tarodev
      @Tarodev  8 หลายเดือนก่อน

      Shaving and finessing is the perfect way to learn

  • @Fewnity
    @Fewnity 2 ปีที่แล้ว +1

    Wow thanks you now I understand how A* works!

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +1

      Mission accomplished :)

  • @star_smells6451
    @star_smells6451 ปีที่แล้ว

    Thankyou so much, I'm recreating a game in Roblox that uses A* path finding, this helped me to create my second version ever, (my first was technically by chat gpt)
    Although yes this is another language for code, my brain somehow translated it! THANK YOU FOR THE VISUALS TOO!!!! You deserve every subscriber and likes

    • @Tarodev
      @Tarodev  ปีที่แล้ว

      That's awesome 😂

  • @pliniomourao
    @pliniomourao 2 ปีที่แล้ว +1

    Very good explanation!
    You should think about adding a video for advanced users to turn your example/tutorial into JOBS as it can gain alot of performance.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +1

      It will certainly be in part 2, along with a few other tid bits :) Glad you enjoyed it!

  • @JoschinoDev
    @JoschinoDev 2 ปีที่แล้ว +2

    Great Tutorial and great visuals, made it really easy to understand. Just one thing around 6:30 the bg music was a bit to epic/loud.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Yeah... you're right >< I'll keep an eye on that for the next videos

  • @_g_r_m_
    @_g_r_m_ ปีที่แล้ว +4

    Hey! I've been tinkering with optimizations for the heuristic cost function (the one that returns your G and H costs) and I've found out that using Manhattan algorithm yields significantly faster results, here's the function in case someone want's to try it.
    float Manhattan()
    {
    var dist = new Vector2Int((int)Math.Abs(from.transform.position.x - to.transform.position.x), (int)Mathf.Abs(from.position.z - to.position.z));
    return dist.x + dist.y;
    }
    float Manhattan3D()
    {
    var dist = new Vector3Int((int)Math.Abs(from.transform.position.x - to.transform.position.x), (int)Mathf.Abs(from.position.z - to.position.z), (int)Mathf.Abs(from.position.y - to.position.y));
    return dist.x + dist.y + dist.z;
    }

  • @Tharky
    @Tharky 2 ปีที่แล้ว +1

    I literally had to code my own A* a few days ago and now you uploaded this :D I'm so sad.

  • @Amonimus
    @Amonimus 14 วันที่ผ่านมา

    Ah. Other videos only used a basic 2D grid, so this feels more understandable for practical usecases.

  • @TheKr0ckeR
    @TheKr0ckeR 2 ปีที่แล้ว

    I was always scared about A* algorithm, but this video explanation really makes me feel it's easy as f

  • @andrewhamel1
    @andrewhamel1 9 หลายเดือนก่อน

    Imma steal that "subscribe immediately" trick i didnt' realize I wasn't subbed

    • @Tarodev
      @Tarodev  9 หลายเดือนก่อน

      YT really is a place where you need to prod people to subscribe. I watch content all the time which I enjoy and would totally subscribe, but I just don't think about it until they ask me.
      We are simple creatures and need guidance 😅

  • @user-oc9be5bb2v
    @user-oc9be5bb2v ปีที่แล้ว

    Great video, but i have 1 last question: what a *current.Neighbors* array we have see in *foreach* loop on 4:38 ? How did you found the neighbors?

  • @RandomProduct
    @RandomProduct 2 ปีที่แล้ว +3

    I know it's supposed to be a literal target, but all I can think is "oh man that octopus really needs to go to Target, what's he getting?"

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +1

      He's getting a nice wall plant and bedside lamp

  • @juke-duke
    @juke-duke 2 ปีที่แล้ว +2

    This is great! Are you gonna be doing other pathfinding algorithims?

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Yes I think I may. Or at least a quick comparison of a few popular ones

  • @imheretosleep
    @imheretosleep ปีที่แล้ว

    Hey I have a question and its very important for my study, I would like to ask if theres any other way to get the heuristic value without calculating distance? Lets say by sound? Like if a grid is emitting a sound or a signal then is it possible to use that grid as the heuristic without calculating the distance from the starting node to that signal?

  • @Noctarc
    @Noctarc ปีที่แล้ว

    What would be the best way to implement this into the Game Grid Tutorial project?

  • @FunkyTurtle
    @FunkyTurtle 2 ปีที่แล้ว +1

    been working on A* for a couple of days now so your video gave me a great boost in the right direction!
    still have one problem tho,
    my algorithm (which looks exactly like yours)
    always gives me a path, but it's rarely the most efficient one,
    the path traced back from the end always seems to bump into a wall and then change direction instead of opting to go around it from the start. any tips as to how to debug my code?
    cheers

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      I'd say setup some debug lines (like I did) indicating the last few path calculations. It'll help you see what your silly unit it thinking. Also, ensure your distance calculation is correct as that can throw off the best path. For example if I just swap out my distance for vector2.distance it'll be way off. Maybe check out the package I provided for what I do.
      Not updating the G cost when it's more favorable can also give less-than-ideal paths. I know you said your code is the same, but I've seen a lot of attempts leave that out.

  • @nikunev
    @nikunev 2 ปีที่แล้ว +1

    I know A*, but the way you explained it is an ART! Even my cat would understand it and start to code :D BUT - the background music is probably unnecessary.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Since then I've learned what volume levels voiceover/music/sfx should be. Wish I could go back and change it :D

  • @dipereira0123
    @dipereira0123 5 หลายเดือนก่อน

    I have a question, how is the cost to neighbor and the cost to defined? the "G" and "H" do they stay stored or they are reprocessed everytime we run the code with a new origin and target?

  • @sseymour1978
    @sseymour1978 2 ปีที่แล้ว

    Hexagonal grid and pathfinding there was rather tricky to implement. Did that 15 years ago in Flash.

  • @popingui2219
    @popingui2219 2 ปีที่แล้ว +1

    Thank you for awesome guides! Started learning Unity with your videos on 2D Game Grid. Always wanted to make a puzzle-tactics game. One important noob question: is this a good idea to learn Bolt system? Or basic scripting is more efficient and better in the long run? It is quite tempting to learn visual system of Bolt but I am afraid it can lead a novice off track. It is also a bit confusing and timeconsuming to grasp both systems. Would appreciate your advice!

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +1

      Learning Bolt will pigeon hole you into only being a visual scripting game dev. Learning to code means not only can you work on games, you can also get employment as a programmer anywhere. Strongly recommend learning to program my guy.

    • @popingui2219
      @popingui2219 2 ปีที่แล้ว

      @@Tarodev Yeah, thanks. "There is no easy way out. There is no shortcut home!". A clean code also looks much better than those spaghetti-like arrows of Bolt!

  • @Hellishcaos
    @Hellishcaos ปีที่แล้ว

    Super curious if this can be converted to C++ to improve performance and smoothly match with Unreal Engine. I'm working on gathering the foundation pieces for an rts game and I need a pathfinding algorithm for it. So far I've discovered flowfields, deterministic lockstepping and this. In your opinion which of these would work best and why?
    For context, the game is supposed to have 2 to 8 players in a game at a time, with approximately 2000 actors assuming everything goes overboard and everybody maxes out on population count.
    Also looking for resources on rendering engines that handle lots of entities better than the current replication system.
    Sorry if this was long winded and thanks for the awesome video!

  • @longuemire748
    @longuemire748 2 ปีที่แล้ว +1

    Thank you.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      You are most welcome

    • @longuemire748
      @longuemire748 2 ปีที่แล้ว

      @@Tarodev Excuse me, but If I understand correctly, we calculate the heuristic with the function GetDisctance(ICoords other) ?

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      @@longuemire748 That is where I do the distance calculation, yes. It's an interface method so that I can re-use the same pathfinding logic for all 3 tile types.
      H cost will be the estimated cost to the target, without taking into account obstacles.

    • @longuemire748
      @longuemire748 2 ปีที่แล้ว

      @@Tarodev Thank you for this clarification.

  • @TomDonahue
    @TomDonahue 2 ปีที่แล้ว +1

    Came for the pathfinding. Stayed for the multiple pronunciations of "H" :D
    For real tho, fantastic tutorial.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +1

      This video was enlightening as I never knew I did that...

  • @nottheguy4328
    @nottheguy4328 2 ปีที่แล้ว +1

    So if I was trying to implement a system where there are different terrain types with varying traversal difficulties, would I want to have a multiplier assigned to the tile that would modify the G/H value calculated? How would you recommend doing that?

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +1

      That's exactly how I'd recommend it!

  • @bales1569
    @bales1569 6 หลายเดือนก่อน

    What do i do about the Neighbors, Walkable and GetDistance() red squiggly lines?

  • @piedra13
    @piedra13 ปีที่แล้ว +1

    i wasnt comparing H if F were same, lol the improvement in time

  • @blenderytrabajo5329
    @blenderytrabajo5329 3 หลายเดือนก่อน

    Claro que funciona asi pero la duda es como calcula si la cuadricula es valida o no

  • @cooperhardi4324
    @cooperhardi4324 10 หลายเดือนก่อน

    Yes

  • @fatmanboozer1760
    @fatmanboozer1760 10 หลายเดือนก่อน

    I know this is old but i cant figure out how to use the iCoords interface. Or more accurately I think i am failing to set the Icoords. I am trying to pass it a vector2 but it doesnt like that, video doesnt really cover this bit, any where i can see something that does?

  • @xdcedar
    @xdcedar 2 ปีที่แล้ว

    The nested `if` statement at 7:10 confused me a little bit since `!inSearch` appears twice there..
    How about splitting it into two parts? like this:
    ```
    if (!toSearch.Contains(neighbor)) {
    // set G and Connection
    // set H and Add Node
    }
    else if (costToNeighbor < neighbor.G) {
    // only set H and Add Node
    }
    ```
    It seems clearer to me ;)
    Oh wait..I come up with a better idea..Just pull the inner `if` statement out of the outer one:
    ```
    if (!inSearch || costToNeighbor < neighbor.G) {
    // set G and Connection
    }
    if (!inSearch) {
    // set H and Add Node
    }
    ```
    It works in the same way, but now there is no duplicate code or nested statement anymore~♪(´▽`) Easier to understand~

  • @CHEEZEyCHEEZE
    @CHEEZEyCHEEZE 2 ปีที่แล้ว +1

    And how would you do something that is dealing with many floors? Like Stairs?

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      You add modifiers to the different types. Sand might have a modifier of 1.5, so the F cost would come out as more expensive. It would make your units favor roads and dirt etc

  • @abuzzakasm9767
    @abuzzakasm9767 5 หลายเดือนก่อน

    What if i need every possible path not the closest path?

  • @ntomsho4545
    @ntomsho4545 2 ปีที่แล้ว +1

    Looks a lot like Dijkstra's Algorithm. Do you know why this is preferred over that algorithm in the gamedev space?

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      A* is an upgraded dijkstra. It adds the heuristic value to predict the best path available. It's not accurate every time but it certainly gives it a boost.

  • @CHEEZEyCHEEZE
    @CHEEZEyCHEEZE 2 ปีที่แล้ว

    How would you do it within a 3D space? For like flying agents?

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Just swap the y plane for the z plane to convert it to 3D. Flying agents can generally skip walls, so that's easy :)

  • @momissimo4087
    @momissimo4087 ปีที่แล้ว +1

    Hi, is the Grid created with the Unity TileMap?

    • @Tarodev
      @Tarodev  ปีที่แล้ว +1

      It is not, but you can still use this algorithm on a tile map

    • @momissimo4087
      @momissimo4087 ปีที่แล้ว

      @@Tarodev Thanks for the reply :)

  • @dio8440
    @dio8440 2 ปีที่แล้ว +2

    Literal greek god you are, very nice video

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +1

      Aussie god*

  • @pliniomourao
    @pliniomourao 2 ปีที่แล้ว

    in 6:55 where do you first set the neighbor for the "startNode"?
    Reading the logic of it. it will never enter the first iteraction of the foreach, because "current.Neighbors" is empty. Unless before calling "FindPath", you already filled the neighbors of startNode.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +1

      The neighbours are cached at scene load, so you don't need to assign neighbours :)

    • @pliniomourao
      @pliniomourao 2 ปีที่แล้ว

      @@Tarodev on the grid build right?
      In my thinking process:
      1. Construct the grid
      2. Define the Node data by working on their neighbors.
      Therefore when calling "FindPath", it is already there.
      Thanks.

  • @YulRun
    @YulRun 2 ปีที่แล้ว +1

    How did you know I was going to look into A* this week as a simple pathfinding system for networked play?

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      I was looking through your window

  • @DrHeinzDoofenshmirtz
    @DrHeinzDoofenshmirtz ปีที่แล้ว

    Where does the intial music in this video come from?

    • @hexitcz
      @hexitcz 9 หลายเดือนก่อน

      a year late, but hey
      better late than never
      Bonkers Beat Club - Ney Flute Type Beat

  • @Kalahee
    @Kalahee 2 ปีที่แล้ว +1

    One thing that often annoys me in how A* (or pathfinding in general) is presented is how it is always presented on an hex or square grid. I'm sure you could use coordinates 10² per 1m² to make it work over any terrain, but somehow it wouldn't be natural or efficient, would it? I wonder if a supersampling method (Poisson Disk, Quasi-Monte Carlo, N-Rook) would make it a good alternative to classic grid.

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +1

      A* should work on any node based grid as long as you can comfortably calculate the heuristic. Even using completely variable node distances.

  • @mrnotprofortnite4105
    @mrnotprofortnite4105 2 ปีที่แล้ว

    the package and code link are not working. please reply me

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +1

      Seems to be working for me. Here, I hosted it in another location for you: www.dropbox.com/s/yi9d845ffk3rkx3/Tarodev%20Pathfinding.unitypackage?dl=0

    • @mrnotprofortnite4105
      @mrnotprofortnite4105 2 ปีที่แล้ว

      @@Tarodev thank bro

  • @seppukun208
    @seppukun208 ปีที่แล้ว

    Did you say class or cast?

    • @Tarodev
      @Tarodev  ปีที่แล้ว

      I have no idea babe

    • @seppukun208
      @seppukun208 ปีที่แล้ว +1

      @@Tarodev oh you said “cost”. Of course 🙄 to early in the morning for pathfinding algorithms 🤣

    • @Tarodev
      @Tarodev  ปีที่แล้ว

      @@seppukun208 did my Aussie accent throw you off? 😂

    • @seppukun208
      @seppukun208 ปีที่แล้ว +1

      @@Tarodev I’m Australian too so super lame that I couldn’t understand you 🤣

    • @Tarodev
      @Tarodev  ปีที่แล้ว

      @@seppukun208 haha, no excuse then brother 😂

  • @mikhailnikolaev9927
    @mikhailnikolaev9927 ปีที่แล้ว

    But what if I have a big units, like 2x2? Let it be square grid.

  • @LeviAckerman-xt7dx
    @LeviAckerman-xt7dx 2 ปีที่แล้ว +1

    Comment for TH-cam algorithm

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      Thank you for your offering

  • @jeroeno_boy
    @jeroeno_boy 2 ปีที่แล้ว +3

    Here is something i always wonder, lets say you have 3 different tyles, water, road and dirt. You can drive over road and dirt, but dirt would be 3x slower. How would you calculate the fastest path to the target?
    My guess is that you add another variable, lets call it S. The road would have an S value of 3 and the dirt would be 1.
    With this the F variable would be G + H + S. Do you think this is a good way of calculating it? Or would you prefer another way?

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว +2

      Yes this is exactly how you'd do it. I've always called them modifiers, standard is 1. I multiply the cost by the modifier.
      It's quick and easy and has never given me troubles.

  • @amidriki6717
    @amidriki6717 2 ปีที่แล้ว

    Keep up the amazing work

  • @Betruet
    @Betruet 2 ปีที่แล้ว

    Man I just spent 2 days writing my own path finding system. It's nothing like this lmao. Not sure if its a good or bad thing... probably bad hahha

  • @MrSambhav200
    @MrSambhav200 2 ปีที่แล้ว +1

    I am too stupid to get this. Fuck!

    • @Tarodev
      @Tarodev  2 ปีที่แล้ว

      It's a lot. Although the code is simple, grasping it all can take time. Just take it bit by bit.

  • @TheDzzirtuoz
    @TheDzzirtuoz 2 ปีที่แล้ว

    Excuse me. It's a Squid Game?

  • @davidfoldberg8004
    @davidfoldberg8004 ปีที่แล้ว

    Terrible. Didn't even show pseudocode.