Data Structures For Game Devs: Arrays vs. Lists | Unity Tutorial (Part 1)

  Рет қаралды 27,305

Anni

Anni

Күн бұрын

Пікірлер: 52
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Next part on HashSets! kzbin.info/www/bejne/p5-vgod7ptiLqc0
@Pontypants
@Pontypants 3 жыл бұрын
Awesome series! :) Great for people like me who code as follows: ctrl+c, ctrl+v
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Thanks Ponty! :) I guess we're all living that pro coder life, no compromises!!
@vergilrose851
@vergilrose851 4 ай бұрын
3 Years late but this helped me alot, thank you, very easy to understand
@SomeKrnDude
@SomeKrnDude 2 жыл бұрын
As somebody with very little coding experience, this guide made it really easy to digest the definitions and usages. Thank you so much!
@ari12373
@ari12373 10 ай бұрын
Very good video, the rookie programmer feels that he has learned very much, thank you for sharing and giving your time!
@tPlayerioT
@tPlayerioT Жыл бұрын
i like how you skipped the cientific part (0:50) to tell us in a better way with visuals, very nice video!
@Karl_08
@Karl_08 2 жыл бұрын
Wow, this is the best tutorial I have seen in this topic! Thank you so much!
@AnnisVeryGoodGames
@AnnisVeryGoodGames 2 жыл бұрын
Thanks, great to hear!!
@AndrewGiacomoPinnical
@AndrewGiacomoPinnical 2 жыл бұрын
gosh this is an amazing tutorial, thank you so much for making this!
@bluecarrotrm
@bluecarrotrm 2 жыл бұрын
This is an excellent video for beginners in data structures. Thank you very much for making it. A year is too late for praise but have a heap of it anyway.
@AnnisVeryGoodGames
@AnnisVeryGoodGames 2 жыл бұрын
I'll take it anytime, thanks! :D Glad it helped you out.
@NamidaSai
@NamidaSai 3 жыл бұрын
Great masterclass, you’ve got the perfect mix of edutainment going here. Good work!
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Thanks Sai! :)
@kayPlayz.
@kayPlayz. 2 жыл бұрын
happy to come on your channel
@mehmeh8883
@mehmeh8883 3 жыл бұрын
Amazing stuff Anni!
@Aye_Sid
@Aye_Sid 2 жыл бұрын
Thanks for the awesome series Anni. U got a subscriber. 😀👍🏻
@paypercutts
@paypercutts 3 жыл бұрын
Nice and helpful for my own endeavors. Thank you. Also, very smart creating content to educate, which brings lots of new traffic and also incorporate your own game in there too. Keen for more!
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Great to hear! Yep, I didn’t really find a series like this, so why not try something new and make one! :)
2 жыл бұрын
Thanks for the tutorial Anni!
@lora6938
@lora6938 2 ай бұрын
I need to click on the button and create a public list that will be displayed in the inspector. Please help me!🙏🙏🙏
@bigofbig4884
@bigofbig4884 2 жыл бұрын
thanks for simple explaining i think we need more of these :D
@Skeffles
@Skeffles 3 жыл бұрын
Brilliantly explained! I rarely find myself using arrays these days
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Thanks! Yes, chances are we're just wasting our time on unnecessary optimizations... ;P
@danielgalli6760
@danielgalli6760 3 жыл бұрын
exactly what i was looking for thanks!!
@TREXYT
@TREXYT 2 жыл бұрын
Hey Anni, nice video, thanks for sharing. I want to know how can i get the layer order value of the last element in a List ? Thanks 😊
@stellarr1
@stellarr1 Жыл бұрын
Love the Dark Souls references ;)
@SGUDevs
@SGUDevs Жыл бұрын
which method can allow you to create categorization and be customizable?
@kayPlayz.
@kayPlayz. 2 жыл бұрын
i need help , i have a situation that i am creating different lvls in same scene, that is i disable lvl 1 object from the hierarchy and enable in same position second lvl, and player after player collide with finish line it came back to starting position in lvl 2 . but i cant disable and enable objects after collison except 2 lvls and 3 lvl is not opening , i tired with loop and arrays but not working.
@David18basso
@David18basso 2 жыл бұрын
Thank you for the class.
@happytofu5
@happytofu5 3 жыл бұрын
Thank you! Very understandable and entertaining!
@TurderaTommy433
@TurderaTommy433 2 жыл бұрын
hey htere how to use list , gameobect list of any type which derivates from an abstrac class? is it possible.
@AnnisVeryGoodGames
@AnnisVeryGoodGames 2 жыл бұрын
Yes, if you want a list of GameObjects: List goList; Or if you want a list of items that all derive from the same (abstract) base class: List anotherList;
@TheHonestLee
@TheHonestLee 2 жыл бұрын
could someone explain this to me regarding Arrays: if we are making an array of type int, which is called highscores, why dont we start listing the content of the array after the "="? what's the point of writing "int[] highscores = new int[3]"? Are we making a new array? Can't we just do "int[] highscores = 3,5,7"?
@Aye_Sid
@Aye_Sid 2 жыл бұрын
In C# we have to write new keyword to declare an array.
@nacs
@nacs 3 жыл бұрын
Nicely presented 👍
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Cheers! :)
@zigglyDev
@zigglyDev 3 жыл бұрын
Yo you are great teacher. But I'm little dumb for programming. Great video. 👍
@doombruh4775
@doombruh4775 3 жыл бұрын
Love your video awesome content;!
@DanceDarkCore
@DanceDarkCore 3 жыл бұрын
Hello .. from now i will follow your video because it is awesome Love from India🇮🇳🇮🇳
@WhiteNorthStar1
@WhiteNorthStar1 Жыл бұрын
LOL... so useful (and funny!)
@Soulzjd2
@Soulzjd2 3 жыл бұрын
@0:48 I actually kind of like the idea of an autobook for computer books. Then again I'm a nerd who dislikes reading.
@watercat1248
@watercat1248 2 жыл бұрын
is eny Data Structures that contain more the one verble for each off the elements the have im tried to create an inventory system and I want data for each off my elements for example if use array or list the contains only one type off elements for each type for example i array with game objects each off my Data Structures need to have more the one Data for example to include name off the ,item, text,icon etc otherwise if ther is no way to do that i will need to follow one off thos method 1. use the same code multiple times that contained all the verbles in public 2. use 2 array or more and to makes sure that in the code the Mach both element for both arrays that both of those methods is kind off tedious
@AnnisVeryGoodGames
@AnnisVeryGoodGames 2 жыл бұрын
Check out my video on dictionaries, it's part 3 of this series and should have what you need. :)
@CyberAngel67
@CyberAngel67 3 жыл бұрын
Posting my comment here because you only make mention of it here, and not in the Dictionary Video. At the 35 sec mark, you have stated that a Dictionary lookup is O(1), which is farthest from the truth that you think. Under the hood, a dictionary uses a for loop and other things to look this key up. The fact that it loops over the dictionary data, makes it an O(n) lookup. And FYI, if you actually do a two-dimensional array with the first being the key and the second being the value, and do a for loop over both arrays. To get to the last item in both scenarios, the two dimensional Array is faster by a significant amount than what a dictionary is to get the last item out of the dictionary. Sorry, as much as I love your videos, this small bit of information is important!
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
Hi! Thanks for your comment! However, you're wrong. :) A dictionary lookup is not O(n). For a lookup, a hash code is computed from the lookup key using a so-called hash function. The resulting hash represents the address of the Dictionary entry, so no looping is required. I have a suspicion that you may have looked at the internal implementation (which is a great idea in general!) but are confusing something. As you can see, a loop is still necessary. However, it loops over all the items in the _bucket_ (not in the Dict overall!) that the computed hash points to. Such a bucket may contain multiple Dictionary entries in case of hash collisions. A hash collision occurs when multiple Dictionary keys result in the same hash code when used as input for the hash function. A decent Dictionary implementation will try to minimize such hash collisions (it's a space vs. runtime tradeoff), avoiding buckets that hold many entries. By the way, this is also why there is no "last item" in a Dictionary; it is not an ordered data structure. Another option is that you're misunderstanding Big-O notation: A loop does not automatically make something a linear-time O(n) computation. The runtime of the for loop has to increase linearly with the number of items in the data structure, which is not the case in the C# Dictionary implementation. Also check out the Microsoft documentation for Dictionary lookups. It says: "This method approaches an O(1) operation." That said, in some scenarios, arrays or lists MAY still provide faster real world lookup speeds than Dictionaries or HashSets. There are many determining parameters: Size of your collection, access patterns in code, your hardware (cache size), effects from cache locality, computation speed of the hash function, etc. (I think I mention this somewhere in Part 4 of the series.) If you truly need to optimize runtimes at this level of your code, the best way to go about it is typically to run benchmarks for your exact use case. Performance optimization is hard. Lastly, while a two-dimensional array may work as you suggest (I haven't checked), I believe it's typically going to be a bad idea to prefer such a home-baked construct over library data structures, especially for beginners, who this video series is directed at. I mention the reasons somewhere in the videos: better readability, fewer bugs, more time to spend on what you're actually trying to do, and, importantly, a beginner likely (and luckily, haha) has absolutely no need to optimize at this level (yet). Phew, long response. Happy new year and let me know if I missed something!
@CyberAngel67
@CyberAngel67 3 жыл бұрын
@@AnnisVeryGoodGames Then I suggest you time it, and grab a value from various positions and see what the difference is. If it is O(1) the time it takes to grab the value based on the ky should be the same. Or, you simply could go to the source code for a Dictionary and see exactly where they do a for loop to grab the value based on a key! That by definition makes it O(n)
@bhanukadasanayaka3457
@bhanukadasanayaka3457 3 жыл бұрын
How to access list in another Script and store it? Like, If I store Transforms of houses in list in one script. And other script, i want to access only one house in that list and store it transform to new variable in this script
@AnnisVeryGoodGames
@AnnisVeryGoodGames 3 жыл бұрын
The best way to do it might depend on your exact use case, but if the script with the list is attached to a game object called "go", and if the class in that script is called "HouseList", to access the list "houseTransforms" within: go.GetComponent().houseTransforms; Good luck!
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
Here's How You Should Be Thinking About Data
10:56
Infallible Code
Рет қаралды 36 М.
How to Code (almost) Any Feature
9:48
DaFluffyPotato
Рет қаралды 715 М.
The Unity HACK that the PROS know
21:27
git-amend
Рет қаралды 19 М.
Better Coding in Unity With Just a Few Lines of Code
15:27
Firemind
Рет қаралды 320 М.
The Dictionary Data Structure in C# in 10 Minutes or Less
10:20
IAmTimCorey
Рет қаралды 43 М.
Intro to Data Oriented Design for Games
52:35
Nic Barker
Рет қаралды 90 М.
Introduction To Object Pooling In Unity
4:14
bendux
Рет қаралды 51 М.
Software Architecture in Unity
7:13
Jason Storey
Рет қаралды 125 М.
How To Build An Event System in Unity
8:01
Game Dev Guide
Рет қаралды 420 М.