Unity Base-Building Game Tutorial - Episode 21! [PATHFINDING - Part 1]

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ต.ค. 2024
  • A preview of what the pathfinding will look like: gfycat.com/Gran...
    These base-building tutorials are funded by my awesome patrons at: / quill18creates
    Watch the whole playlist here: • Unity Base-Building Ga...
    Get the Project Files here: quill18.com/por...
    Make sure to SUBSCRIBE so you don't miss a video!
    Download the complete project: quill18.com/uni...
    Also, please feel free to ask lots of questions in the comments.
    This channel is mostly all about game programming tutorials, specifically with Unity 3d. You may also be interested in my primary channel, where I play and review games: / quill18
    I can be reached at:
    quill18@quill18.com
    / quill18
    / quill18

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

  • @quill18creates
    @quill18creates  8 ปีที่แล้ว +13

    This has probably been the most difficult topic to balance between beginner and advanced levels so far. I'm hoping I've gotten the balance close enough that everyone can follow and enjoy.

  • @Linck192
    @Linck192 8 ปีที่แล้ว +3

    Chunklets: what an exquisite word to say

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

    Quill, you should constrain your generic parameter (Path_Node where T: INode) to either an interface, which your node-able objects implement (cleanest) or a base class to all node-able objects(a common class to tile and room *shudder* ). Otherwise, you'll only have access to lowest common denominator's methods (object) and won't be able to work with it at the generic level.
    This comment assumes you don't have just a lazy data class.

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

    I dont know english, but this series so awesome, thank you Quill ^^

  • @Tyrope
    @Tyrope 8 ปีที่แล้ว +3

    I realize I'm way late on this suggestion. But I'd like to consider this an academic hypothesis. (Note I'm only 21 minutes into the video): Why not have the movement cost be the average of both tilecosts? that way the character's speed actually changes as they touch the difficult terrain, all the way until their sprite isn't colliding with the difficult terrain tile, and movements don't change dramatically..
    Let's do a bit of compairons math. 3 methods: OnEnter, Average, OnLeave. Let's say we're going from tile A, past B, to C.
    A.cost = 1
    B.cost = 2
    C.cost = 1
    OnEnter.cost = B.cost + C.cost = 3
    Average = (A.cost+B.cost)/2 + (B.cost+C.cost)/2 = 3
    OnLeave = A.cost + B.cost = 3.
    The OnEnter model is nice for leaving impassable tiles, since it literally doesn't care.
    The OnLeave method would straight up not work, since your speed will be 0.
    The OnAverage method would allow you to leave at half speed... however, it will also allow you to enter at half speed, which would require a bit of checking. But honestly I think that's worth it for having the smoother character speeds.

  • @Sfaxx
    @Sfaxx 8 ปีที่แล้ว

    I thought about generic implementation just couple seconds before you did it :D

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

    If you don't want Unity to break links between scripts and objects, etc., then you have to show meta files: Edit -> Project Settings -> Editor.

    • @mrbandler
      @mrbandler 8 ปีที่แล้ว

      +IWoytaZI Just wanted to comment the same thing :D

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

      Quill you gotta set it the Asset Serialization to Force Text and the Version Control to Visible Meta Files.

    • @woytaz
      @woytaz 8 ปีที่แล้ว

      +MrBandler Asset Serialization set to Force Text will help a bit in terms of bloat but you shouldn't merge scenes, prefabs, etc. if you have conflicts. I believe there's a tool for that bundled with Unity but I've never used it.

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

    The word "Chunklet" made me hungry (2:04)

  • @Formulka
    @Formulka 8 ปีที่แล้ว +7

    github page for the priority queue: github.com/BlueRaja/High-Speed-Priority-Queue-for-C-Sharp

  • @elgiloy
    @elgiloy 8 ปีที่แล้ว +6

    I think you'll want to include the walls as nodes after all, with edges out only. For even if you decide to let the wall building jobs be done from adjacent tiles so they don't sit on a wall when they're finshed, those nice little morons will be building walls underneath each other, because that's just what they do. Save the player some work scrapping and rebuliding walls, I'd say.

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

    9:40 ep tomorrow confirmed

  • @abcadef6171
    @abcadef6171 8 ปีที่แล้ว

    (Not a subset, since neither of them are sets: It's a refinement, if you want to be fancy).

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

    Here's the link as Quill forgot to include it
    github.com/BlueRaja/High-Speed-Priority-Queue-for-C-Sharp

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

    Talk, talk, talk, talk, talk > Figure that the talking has got out of hand > "Anyway lets continue"> Repeat this process

  • @HKCmoris
    @HKCmoris 8 ปีที่แล้ว +6

    Why are you multiplying the movement cost by 1? at 33:34

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

      +HKCmoris Probably because it is normal cost of movement. 0 is for nonwalkable objects, 1 for normal and 2 for hard to cross object like marsh, water or something like that :)

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

      Yeah I got that, but isn't it meaningless to multiply by 1 since the value isn't going to change? I mean, it doesn't really matter in the big picture...

    • @SolyomSzava
      @SolyomSzava 8 ปีที่แล้ว +8

      +HKCmoris
      The compiler almost certainly disregards operations with the neutral element, so no extra cycles are lost for no reason. Even 30-years old compilers know how to do that, I doubt Unity would be any different.

    • @HKCmoris
      @HKCmoris 8 ปีที่แล้ว

      Oh, okay, thx

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

    Heigh-ch-tah. LOL

  • @ebecar396
    @ebecar396 8 ปีที่แล้ว +3

    Hehe, chunklets :3

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

    Instead of two for loop on getTileAt, why not just : foreach (Tile t in world.tiles) ?

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

      +alekmoth Because foreach is twice as slow as two for loops, and because of the way that it has been implemented, foreach creates a lot of variables so it makes the Garbage Collector do a lot of unneceserary work. However, in C# 6.0, foreach has been improved upon, so it doesn't do that anymore.

    • @alexanderschacht8786
      @alexanderschacht8786 8 ปีที่แล้ว

      +rokkerboci So if I were to generate nodes for the empty tiles also, would it be more efficient to do the loops again and make a dictionary-lookup rather then the foreach?

    • @alekmoth
      @alekmoth 8 ปีที่แล้ว

      rokkerboci i am sure this neither this series, nor my own game, will be done prior to the release of 6, so I guess we are good then :)

  • @PsyBoots
    @PsyBoots 8 ปีที่แล้ว

    Why crashlands dont have pathfinding?

  • @nickvolf
    @nickvolf 7 ปีที่แล้ว

    How did you add a function from a script that isn't a GameObject to the button?

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

      For anyone else watching this pretty late. Quill's code is in world, then you can add
      public void PathFindingTest(){
      world.SetupPathfindingExample ();
      }
      into your world controller. Then add that code to your button.

  • @BrunoJanvier
    @BrunoJanvier 8 ปีที่แล้ว

    What about creating a simple mesh from furnitures and using unity navmesh ?

  • @alekmoth
    @alekmoth 8 ปีที่แล้ว

    I dont understand why you dont use the project structure in Monodevelop to open files. Seems so pointless to go back to unity to open the .cs files.. I mean, it is RIGHT THERE.

    • @alekmoth
      @alekmoth 8 ปีที่แล้ว +3

      +alekmoth Cough.. Very next file he opens using the project structure. .. Commenting during video..