Data Structures For Game Devs: Queues & Stacks | Unity Tutorial (Part 4)

  Рет қаралды 13,244

Anni

Anni

Күн бұрын

Пікірлер: 69
@MattTheLegoman
@MattTheLegoman 3 жыл бұрын
A stack can be used for an "undo" system! If your stack data type represents actions the user has taken, you can easily pop off the top item in the stack and call some function to undo its effects.
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Nice, awesome example! :)
@Tarodev
@Tarodev 3 жыл бұрын
That's a fantastic use case
@HamieSAE
@HamieSAE Жыл бұрын
I am asking this: Wouldn't Command work better for Undo/Redo?
@qzlocxx
@qzlocxx 3 ай бұрын
Thats the command pattern :)
@Tarodev
@Tarodev 3 жыл бұрын
This was a really thorough breakdown and I wish I had videos like this when first starting my journey. Subbed! Keep them coming!
@saffetsiraz
@saffetsiraz 2 жыл бұрын
Absolutely I agree. Keep them coming!👏👏
@Enzo_TheRizzler
@Enzo_TheRizzler Жыл бұрын
Ok. So... after finishing this series I can say that it is awesome. Not only that you tell us how to use the code and so, but you also gave us some examples and I think this is very, very helpful, cause I learned some practical stuff, not just code and how to use it. 10/10 😁
@edisyo
@edisyo 5 ай бұрын
Really professional and in-depth series. Thank you!
@voidling2632
@voidling2632 Жыл бұрын
I don't understand anything but that's not your fault, it's 3am and I'm tired from programming all day long ... and my ADHD brain keeps distracting me. I like short videos, thanks for putting so much effort into them.
@Ryaurezh
@Ryaurezh 3 жыл бұрын
I like your simple-yet-comprehensive breakdown of how the structures work, how similar structures are different, as well as the practical examples on when to use them. I'm often frustrated when trying to implement something, only to realize it doesn't work and I don't know why, only to later find out there was a better solution all along. Look forward to seeing more videos like these.
@AnnaGlin
@AnnaGlin Жыл бұрын
thank you for making this little series! I'm a beginner at coding and have had no formal education in the field (I'm normally an artist/illustrator ;)). this was a good initial overview of what these things can do. However, I'm still not sure how to actually use them. I would love to see a concrete example, like Brackeys does in his tutorials which are very effective for me - being more visually oriented I need to see what actually happens😅 but I understand it's a lot more work. I would love to see maybe small tutorials like, for example, recreating game mechanics (can be just one part of a game, like a character creator for example), using these methods. I just have no idea where to start and what it would look like actually using these, not just a bunch of abstract examples!
@LeahTynan
@LeahTynan 2 жыл бұрын
This video is fantastic! 👏 Love how you combined theory with practical examples in game dev.
@turkeyjerkey
@turkeyjerkey 3 жыл бұрын
One of my favorite uses of Queues and Stacks is in Graph traversal. The use of a Queue for BFS and a Stack for DFS perfectly benefits the algorithmic implementation of each! Great job on your video series, btw!
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Thank you! Great points, definitely. I considered making a video on graphs as well, maybe some day! :)
@yess.6558
@yess.6558 Жыл бұрын
AMAZING SERIES!!! Thank you so much for these videos, this has been a massive boost to my C# & Game Dev journey :)
@wiglord
@wiglord 2 жыл бұрын
a bit late to the party with my comment but thanks for this tutorial series, I have been using lists for a while but had no real grasp of dictionaries or queues/stacks. Your videos explained it pretty clearly and the use case examples really helped me get my head around the concepts.
@AnnisVeryGoodGames
@AnnisVeryGoodGames 2 жыл бұрын
Great to hear, thanks! :)
@Soulzjd2
@Soulzjd2 3 жыл бұрын
I have something to say. I approve of this educational content. That is all, good day.
@theblackdragon7321
@theblackdragon7321 Жыл бұрын
MTG (Magic the Gathering) is a great example of "the stack" because that's how the game is played. First in, Last out. TY for this little series. I'm trying to make a card game, and was wondering if I should use a list, dictionary, ect. It's going to be similar to Slay the Spire, so I may want to add cards to the middle of the deck, or discard pile, ect.
@veotachigo3847
@veotachigo3847 2 жыл бұрын
This series was really compact and easy to understand, well done. 👍
@GabrielDias0223
@GabrielDias0223 3 жыл бұрын
That is the best explanation about Queues and Stacks I've ever seen, thank you so much!
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
What an honor, glad to hear!
@purplegoop1247
@purplegoop1247 Жыл бұрын
had no idea these were a thing, very helpful
@levayv
@levayv 2 жыл бұрын
We got Pool explained as a Bonus ? Nice !
@Skeffles
@Skeffles 3 жыл бұрын
This was a fantastic video series! I use queues all the time but I rarely find myself using stacks but now I know to use them in a card game.
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Haha yes, stacks are a bit less practical, really, but make sure to use them in every card game you ever make! ;P
@Skeffles
@Skeffles 3 жыл бұрын
@@AnnisVeryGoodGames Actually I take it back. I just found a use for a stack. I've got a lives system with a set number of hearts, so push on new lives and pop off old ones.
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
@@Skeffles heh, awesome! I actually used lives as a generic example for lists in the first video, but a stack can totally work for this! Someone else mentioned an undo-system as a stack use case BTW, which I thought was a great example as well.
@divainsyoutube4254
@divainsyoutube4254 2 жыл бұрын
Great video series and content. I loved the simplicity and examples
@AnnisVeryGoodGames
@AnnisVeryGoodGames 2 жыл бұрын
Thanks, glad to hear that!
@jsn4591
@jsn4591 3 жыл бұрын
Great little series! This was all stuff I vaguely knew but you've helped solidify much of it. You explain things really clearly, great visuals too and the occasional joke is nice. Thanks
@chelwebster478
@chelwebster478 2 жыл бұрын
Thanks for making these videos, they've been great! Very informative and at the same time very concise
@andreyradovski8514
@andreyradovski8514 3 жыл бұрын
Very nice beginner-friendly explanation, thank you!
@saffetsiraz
@saffetsiraz 2 жыл бұрын
Thanks for the simple explanation ❤
@charlesgosmexr
@charlesgosmexr 2 жыл бұрын
Just finished your amazing set of tutorials. These really helped!
@GlennVerheij
@GlennVerheij 3 жыл бұрын
Thank you, I learned things. 😌 As a jack of all trades game developer, these fundamental videos are super useful. Wouldn’t mind seeing more of these, or maybe something like design patterns in the context of Unity? Anniway (HA) well done. 🙂
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Awesome, that's glenntastic to hear (double HA!) 💥
@GlennVerheij
@GlennVerheij 3 жыл бұрын
@@AnnisVeryGoodGames 👌💀
@MuhammadAli-gs1co
@MuhammadAli-gs1co 2 жыл бұрын
Great video from start to end!
@markorossie9296
@markorossie9296 3 жыл бұрын
A pathfinding game - Make a bot find the path through a mesh. You can use a stack to record the moves of the bot & backtrack in case it reaches a dead end. Use a depth-first search algorithm here. Similarly Exploring nearest ally bases - Create a battlefield map with ally & enemy bases spread out through the map. Drop your commando at a random location & make it search for the nearest ally base. To implement this can use a queue to traverse through the map, & find the nearest ally base from your location. The algorithm to be used here is Breadth-first search. Stacks are often used when there are interrupts to handle, or when having recursive functions, or even when constructing a rudimentary AI for your games. So pretty much an extreme useful DataStructure in some cases.
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Great practical examples, nice!
@berthasebastian1490
@berthasebastian1490 2 жыл бұрын
Thank you, your series is very helpful. I use it as a study aid for job interviews! I think you should do some algorithms for game dev?
@dererzherzog
@dererzherzog 3 жыл бұрын
Your videos are very informative, but what I really like is how you keep them short and to the point. I am looking forward to watching new content on your channel!! As for queues, is it possible to acces a particular [i-th] element of a queue, like in arrays or lists?
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Thanks :) Yeah, since Queue inherits from IEnumerable, you can use yourQueue.ElementAt(i).
@visheshkhurana1211
@visheshkhurana1211 2 жыл бұрын
Amazing!! waiting for binary trees and graphs and linkedlist :P
@Berndr
@Berndr 3 жыл бұрын
Amazing and best tutorial on data structures I have seen.... sorry a total noob question not sure if it is stupid ... I am curious what happens if two trains arrive at the same time to the crossing, how is this managed by queue and what train will have priority ... do train crash or the unity system? by the way absolutely loved your approach to tutoring
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Thanks! Haha, I hope Unity doesn't crash because the trains arrive at the same time! ;) Even if they arrive during the exact same update cycle, Unity's event functions (Awake, Start, Update, etc.) and collider functions (OnTriggerEnter etc.) are called in _some_ order, so one train will be added to the crossing's Queue first, and then the other one. Once a train leaves a crossing (as determined by a collider), the crossing checks for any remaining queued trains and "tells" the first in-queue to continue. In the game, trains from two different directions will always take turns moving onto the crossing due to the Queue data structure. Hope that makes it clearer!
@Berndr
@Berndr 3 жыл бұрын
@@AnnisVeryGoodGames That is a fantastic answer and very clear thank you so much for clearing this up ...
@sh4dup692
@sh4dup692 3 жыл бұрын
Hey I'm curious about your project on track and how did you create train movement on the track /path
@lufasumafalu5069
@lufasumafalu5069 2 жыл бұрын
would be grear if you make step by step example in simple games demonstrating the use of each data dteucture
@googleuser4720
@googleuser4720 8 ай бұрын
Thanks, I had ChatGPT answer this question in less than 30 secs compared to your 9 minute video. Also chat GPT is more concise
@mercantilistic
@mercantilistic 3 жыл бұрын
Please do more on object pooling
@AstralNostalgia
@AstralNostalgia 11 ай бұрын
sorry I got a question , in the middle of the queue? you say "read only"... but tecnhically you should copy a queue collection in new one? because you can not access to any elemens in fifo (queue)? or am I wrong? ...if an element in the middle is needed , probably list or array are better? thank you.
@AnnisVeryGoodGames
@AnnisVeryGoodGames 11 ай бұрын
I'm not sure about what you are asking at the beginning of your comment. But if you need elements from the middle of the collection, then a queue is probably not the correct data structure for your use case, yes.
@DonsT199
@DonsT199 2 жыл бұрын
Good Tutorial but if we had an good open world , how to do parkours based on particular building or thing ...eg: Dying Light .. I Don't know right or wrong so any data structures behind this much handlings?
@edi_gun_awan
@edi_gun_awan 3 жыл бұрын
Thank you
@abdurraqib7031
@abdurraqib7031 3 жыл бұрын
where can i play the train game? it looks so fun !!
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Thanks! It'll be on the Android Play store soon! I'll make a video when it's ready. :)
@kaleb_t4818
@kaleb_t4818 3 жыл бұрын
Hey, I'm working on an enemy spawn system with waves. But I new to programming and cant figure out how to make a system which allows me to control the amount each type of enemy I spawn in a specific wave.btw I saw all your vids on data structures, they were very helpful. But I cant couldn't find a way to use them for my case. Any tips?
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
It sounds like you could for example try out a pooling system using a Queue or Stack to store all the Enemy GameObjects. Not sure what the exact issue is that you're facing for your enemy types, but consider posting your question in the Unity forum with more details! (What exactly is the issue? What do you want the wave spawn system to do?)
@kaleb_t4818
@kaleb_t4818 3 жыл бұрын
@@AnnisVeryGoodGames my issue is I can't figure out a way to control the number of each type of enemy per wave. For example if i wanted to spawn only enemy-1 3 times in the first wave and in the second wave enemy1 - 4 times and enemy2 - 2times then in the third only a single enemy3 as a boss fight. I'm looking for general tips of what I should be looking into
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Sounds like you'd want to store those numbers somehow, for example as simple constants, or if you have a lot of waves and a lot of enemy types, you could actually use a dictionary of dictionaries: Dictionary numberOfEnemies; The first int is the wave index, EnemyType could be an enum of available enemy types, and the last int would be the number of enemies to spawn for a given wave and enemy type. For wave 5 and enemy type "CrazyKaleb" ;) , you can get the number of crazy Kalebs to spawn like this: int numToSpawn = numberOfEnemies[5][EnemyType.CrazyKaleb]; But it always depends on your situation of course.
@kaleb_t4818
@kaleb_t4818 3 жыл бұрын
@@AnnisVeryGoodGames oh so dictionaries are the way to go, I'll do more research into them(I'm sure ur vid will suffice). Tnx alot I really appreciate it 😊
@dragonalias
@dragonalias 3 жыл бұрын
I knew about all of the data structures, but the one I knew least about was Hashsets. You mention you can do something called intersect/union... and I still don't understand what that means.
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Oh no, the tutorial failed you! :-o You can check the C# docs, the HashSet has these operations documented as well.
@dragonalias
@dragonalias 3 жыл бұрын
@@AnnisVeryGoodGames Yes it's very sad. I even watched it twice XD Alright, maybe I'll do that some day.
@quasar4780
@quasar4780 3 жыл бұрын
In short, since HashSets cannot contain duplicates, you can use IntersectsWith and UnionWith to compare two HashSets and see if they have values in common (Intersection) or to combine them together without having any value added twice (Union).
@dragonalias
@dragonalias 3 жыл бұрын
@@quasar4780 Ah, I get it now. Maybe her example made me confused, it's actually pretty simple. Thank you :)
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 799 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
The 6 Design Patterns game devs need?
24:20
Jason Weimann (GameDev)
Рет қаралды 377 М.
When Optimisations Work, But for the Wrong Reasons
22:19
SimonDev
Рет қаралды 1,2 МЛН
Why Majora's Mask's Blue Dog Took 25 Years to Win the Race
21:04
Vidya James
Рет қаралды 3 МЛН
Build Anything In Unity Using DSA | How Programmers Think
19:08
Darko Tomic
Рет қаралды 4,9 М.
How I mastered data structures and algorithms  (for beginners)
14:04
Improve Your Unity Code with MVC/MVP Architectural Patterns
15:32
Unity async / await: Coroutine's Hot Sister [C# & Unity]
16:18
Unity Performance Tips: Draw Calls
4:24
Lofi Dev
Рет қаралды 205 М.