Unity Base-Building Game Tutorial - Episode 20! [Responding to Comments!]

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ต.ค. 2024

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

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

    One thing you haven't talked about are the callbacks and C# events. Events do everything you require without the need to implement your own register/unregister functions (which gets really ugly when you have more than one callback in a class).

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

    Quill you should do again more Unity stuff.. it's so old and yet more advanced than half of yt tutorials

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

    Chebyshev is pronounced "Tshebb - eee - sheff", or at least that's as close as I can render it for English pronunciation.
    If you want some sort of a mid-point between these norms, look at the p norms for 1 < p < 2 (for between Manhattan and Euclidean), or p > 2 (for between Euclidean and Chebyshev). No physical analogies for these, but useful (1 < p < 2 encourages orthogonal movement, but allows diagonal movement when it's a noticeable improvement, while p > 2 encourages diagonal movement, while still preventing the silly zig-zagging that you get on straight orthogonal lines with Chebyshev distance).
    That said, Chebyshev distance does make sense realistically: if you've got something moving on two perpendicular axes independently (think grabber arm moved by two motors, one in x direction, the other in y in one of those toy-grabby things), then Chebyshev distance is exactly the correct distance to use to estimate how long it will take to get between two points.

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

    Hi!
    Mathf.Abs(... - ...) results for X and Y could go into variables making it no longer pure one liner, but much more readable and faster (due to the ABS and subtract being done once for each, instead of twice, which would be done in great most cases as in most cases you will compare non-neighbours therefore going through both parts of the function.)
    so it would look like:
    int absX = Mathf.Abs(this.X - tile.X);
    int absY = Mathf.Abs(this.Y - tile.Y);
    return (absX + absY) == 1 || (diagOkay && absX == 1 && absY == 1);
    PS. I know its gravedigging some old video, but because many other were speaking about this bit of code why not to kick it again :P
    Anyway, ignore me, and have a good day :P
    Cheers!

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

    You could always skip the pronunciation issue and just call Chebyshev by it's other name, 'chessboard distance.' Named such after how a king moves in chess.

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

      +Salvador A. Melo That's probably a REALLY good idea.

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

    From my understanding, small functions like Mathf.abs() are typically inlined by the compiler, so function calls aren't really a thing here. I could be totally wrong though.

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

    This is a very code-light episode. We're primarily going to be discussing different ways to calculate distance on a grid (Euclidean, Manhattan, Chebyshev) as well as responding to various comments and questions from TH-cam comments.

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

    I know i´m waay behind with the videos, but hey, whatever.
    When implementing proper euclidean pathfinding, you could indeed cache the sqrt() thingy. Instead of telling the character to move from Tile A to Tile B, you could tell him the direction to move. By doing so, you could use the constant value of 1 for horizontal/vertical movement and a constant cached sqrt(2) for diagonal movement.

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

    Abs can be implemented with a XOR operation so it should be fast.

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

    Quill - between my watching these tutorial videos at 1.5x speed (your voice works very well!) and trying to watch your Stellaris 'Sci-Fi Grand Strategy' series. You're basically taking up all my spare time right now. Which is annoying, because I'm missing out on some great TI6 games! Ahaha... Enjoying as always, thanks :)

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

    3:01 "What the hell am I talking about? WELL! Let's play 5x5 Sudoku!"

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

    So that one-liner already gives you your Manhattan-distance right away.

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

    I laughed way too hard qwhen he said pop pop

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

    I also was taught in Pascal at university. My GF (who is a few years younger than me) was absolutely horrified when that one came up in conversation one time.

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

    This Boolean/Equation worked for me:
    (Mathf.Abs((this.X - t.X) + (this.Y - t.Y)) == 1 ||
    (diagnals && Mathf.Abs((this.X - t.X) * (this.Y - t.Y)) == 1))
    Cheers!

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

    If you are limiting characters to sitting in the middle of a tile then manhattan norm or the Chebyshev norm would be the best (Chebyshev would allow diagonal movement). This is because of the fact we are limited to tiles and they are cheaper to compute as the Chebyshev is just the maximum of x and y distances. If you allow characters to free from, then euclidean would be best because you can take the actual shortest path no matter where the character is.

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

    Pop Pop! Community reference had me dying

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

    Man your videos are amazing. Thanks so much

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

    A lot of performance things that are not actual issues, and probably wouldn't be. I would like to see you address more code structure things rather than performance micro-issues.

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

    I'm with quill - I'd prefer verbosity in this case. But if you want to be a stickler (like these guys apparently do), you can save a mathf.abs() call by doing mathf.Abs(this.x+this.y - tile.x+tile.y) == 1

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

    Yup, you fooled me. I did not expect you to reference a programming language from the 1970s.

  • @weckar
    @weckar 5 ปีที่แล้ว

    What's the measurement system again where every second diagonal counts as 2? It creates more realistic measurements while still allowing diagonal movement.

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

    I just learned what a 1 unit diagonal is, I believe it is 1.4142

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

      its just √2

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

    This might be silly but could it work out to basically blend smoothly between Manhattan- and Chebyshev distance? That should be equivalent to giving diagonals a distance of 1.5 which is fairly close to the euclidean distance. I'm not sure whether it's worth it calculation-wise but it seems reasonable?
    Edit: Ah, just, like, half a second later, you adressed this, essentially.

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

    How hard would it be to make the job have percentage of completion. So that maybe one character completes it maybe 50% and then gets interupted, but when he gets back or another gets back, they only have to complete the last 50% percent?

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

    I'm in college, and we do pascal. It sucks.

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

    Chebyshev:Ch - like match; e - like gAme (æ); b - like b :); y - is Close central unrounded vowel (if you look this article in wiki you will find audio file with pronunciation); sh - like SHarp; e - the same as previous 'e'; v - like violet [or like v :) ]Hope it will help you) Crap, youtube remake it in one single raw :((

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

    "Manhattan distance is literally named after a city" - Actually, no, Manhattan is a borough of the New York City, named after the Manhattan Island on which it mostly lies. There are also a couple of cities across USA named Manhattan, but the Manhattan distance wasn't named after them.

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

    +quill18creates instead of square root/squaring, you can use Abs

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

      +izikblu If I understand what you mean Abs will not work. Abs only gives you the magnitude of a vector if you are in 1 dimension. In order to get the magnitude of a vector in 2 or more dimensions you must do a square root.

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

      later in the video he did what i was talking about (Abs(this.X-t.X) + Abs(this.Y -t.Y))

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

      +izikblu that doesn't give you the same answer as sqrt((this.X-tile.X)^2 + (this.Y-tile.Y)^2) though. It doesn't give you the Euclidean distance.

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

      ahh

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

    it will look silly if it zig-zags... just go straight

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

    hey with the amount of money you make why do you not make actual real projects you seem to understand code and the relative balances why not make a bigger project.

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

    +1 for the Community reference. Pop Pop!