Hey, Jason. I see you doing the Enqueue objects back into the queue only after they expire their lifetime. Is there a reason for that? Why not just put it back in right after we Dequeue() ? Like: GameObject obj = pool.Dequeue(); pool.Enqueue(obj); This way we make sure that even if somehow the lifetime of the object isn't ended yet and we already need it again it will just disappear from where it stuck and get back into usage.
@@user-lv6qm3fj2z it would prevent instantiations entirely because the queue will always have a pooled object which would be reused every time it's needed.
@@herohiralal3255 ummm... no? Why would you even mention instantiation? We instantiate all needed objects on start. We don't instantiate anything during the process of dequeuein/enqueueing.
@@user-lv6qm3fj2z we do. If the queue is empty we instatiate a new object. If you don't know exactly how many objects you will need, your option on the pool won't work.
@@danielschulz7391 that doesn't make any sense. We make queue to avoid instantiation during the game to lower the script "weight". Why would we start instantiating objects in the middle? And the fact that the queue isn't big enough to satisfy all the requests - that's when the way I described comes to the rescue. If we return the object into the queue right after we took it from there, then in case the queue makes a "full turn" then we just use the object that is already in use "despawning" it from where it was an inserting it into place, where we need the new one.
I was using the classic "Instantiate and destroy" method on an shooter like game, then I decided to try this... the difference in the performance is HUGE!!! Thanks man!!
Huge help, even two years later. For some reason I just kept avoiding object pooling, but now that I'm working on a serious team project, I feel a duty to do everything I can to make the game run as efficiently as possible. Thanks a million, this was much easier to implement than I though it would be!
Coming from a .NET MVC background and watching your videos I'm really glad that someone follows proper coding principals like you. So many Unity videos I see that are just terrible code.
Now that's some real C# programming right there ... generics, lambda expressions, LINQ, delegates & events, those are the sweet features that make C# stand out from the crowd.
awesome tutorial man, explains 3 different cases really well. Perfect, I've watched it 3 times now and I feel like I fully understand how to setup my own pooling case in any situation. Thanks a ton!
Loving your videos more and more , although i didn't understand most of it , it will take me at least 2-3 re watches to fully understand the core concept. It gave me a reason to study other concepts also like queue,singleton etc.So thanks for that, will follow your videos regularly to learn new things.
Easier than I expected and clearly very useful and effective, thank you. Nice to see some clean code in a Unity tutorial. Everyone else seems to be competing on speed!
If you dont destroy the objects inside the array at anytime is pretty much a pooling system anyway, maybe not a proper way of pooling but a pool anyway.
I have a different way of doing this where I'll immediately Enqueue the prefab that the pool dequeues. This may seem counterintuitive, but what that's doing is moving the prefab to the back of the line, but the reference to that object can still be returned to the user. So, that way, the pool never runs out of objects. It also means that the prefab isn't dependent on the pool.
Thank you so much for sharing this information with us, sir. I love your videos especially game programming patterns video. would love to have more of them
I tried making a similar pooling concept to this, however where the poolable objects can pool themselves but ran into a problem, the Queue being static in an abstract class means that every class inheriting from the genericobjectpool will technically have the same pool Static variables don't get inherited and stay on the "level" of the class that they're at currently, if you pooled a house and a bullet (as long as the house had the same script as the bullet) they would both be used from the same pool.
Idk if I had the same problem as you, although indeed, where I tried the last approach having the same script component but different prefabs, this didnt worked as the Instance was pointing to whatever object was first to claim it. I think its a very important remark. I ve dealt with that using multiple generics "GenericObjectPool" And then "public static GenericObjectPool Instance {get; private set; }" And K should be a specific pool.
thanks bro.... being trying to understand how to code object pooling for a week already, people explain it like sh*t even in my own language hahaha thanks! keep going please!
There is another pooling tutorial with much more views, that fails to explore all the basic and necessary pooling techniques you introduce here, this video should be the topmost one on the subject. Nice job!
I like a non-generic approach better, you can create a poolable object component with a reference to a pool and a lifetime and inside of update check for lifetime, return it to the pool and disable it. On the pool itself just require this pooling object component instead of GameObject so you can assign pool reference and a lyfetime of the pooling object if needed. You can also make Update method protected virtual inside of poolable object so you can override it and also use a base one.
Doesn't appear to work with Prefabs! Jason, I don’t think method 3 is usable in the following scenario: If your blaster is a prefab, but your object pool is a game object in your scene’s hierarchy, then adding the object pool to the blaster via the inspector, and then applying the change to the blaster prefab, will not be possible, because: “A reference to an object in the scene cannot be applied to the Prefab asset”.
Small error with the AddObjects() method on line 30 in GenericObjectPool: It has the argument "count" but that's never used, guessing you just missed to wrap the method in a for loop. Good video nonetheless!
i don't understand how he instantiates the prefab.. The prefab is a gameobject, but the type he uses is the controller type (C# class file), How can you instantiate this while still accessing the Controller's functions?
When your prefab has a monobehaviour on it you can instantiate it and assign to a variable of a type of that monobehaviour. That's how unity works - here: czcams.com/video/uxm4a0QnQ9E/video.html
Wonderful Tutorial. It will be great if you Can you show how to spawn different objects like player bullet, enemy bullet, their particles etc... using same generic pool system ?
Any chance Jason you would let us download your little projects? I would understand much better by following you around on my screen at the same time. The same goes for the pattern videos you do - its just kinda too fast for me plus it would be give me much better understanding if we could just look around how the things are connected
Love the last version with Generics. What would be the best way to change bullets types, "look" or "skin" depending on weapon. This system is for the same type of bullet?
Great video, I like the progression in the designs. Have you ever tried to completely decouple the object being pooled from the pool? So the object being pooled has no pool code / awareness?
How do you deal with the integrity of the objects? What if the pooled objects get modified (even by just adding components) and then they end up back in the pool while they are "dirty"? How do you prevent that from happening
Does anyone know why when using the generics version with spawning enemy prefabs they get sent back to the pool instantly after being re-spawned (after being killed once)? This only happens after being killed and works normally when OnBecameInvisible() is called, also works great with my bullets. I thought it was something with the death animation/animator and calling the returnToPool method with animation evens, but nothing has worked. I'm stumped!
You have any tips on how to keep your code manageable as it grows bigger and bigger? I'm having a hard time keeping my code legible as I keep adding things. I used to have a script that did all character functions, but now I've broken it up into Player.cs, PlayerInput.cs, PlayerMovement.cs, PlayerWeapon.cs, PlayerAbility.cs and this seemed to work fine. But now I'm adding multiple Weapons that all function differently like hitscan, projectile, multiple projectile, and melee. And abilities that are AOE, spawn objects, extra movement, controller enemy movement (like a hook), etc... So I started using inheritance, a base weapon class, a base ability class, a base Entity class (for players and enemies) but it's all becoming too much for my little brain to handle. Any tips on keeping it clean, coherent, and manageable? Have a great day! :)
Keep notes and draw out your class structure/game's pattern on paper and post it on your walls. The more visual you can represent your code structure, the easier it will be to navigate.
I wonder, is there a reason to do this for rapid-fire audioclips? I know that they disappear after the clip is complete, but I can't help but wonder if there's some ramification to that.
I learned about garbage collection when I was programming a WebGL Minecraft clone in javascript and I was instantiating a 4x4 matrix for every block every frame 😂
Hi Jason, been watching alot of your videos, some really insane stuff! I was wondering how you would do this type of approach with textures being downloaded from a web api. 1000s of different textures in varying sizes, how do you deal with the caching, storing and reusing. In webgl builds its extremely memory intensive. Was just wondering if you had any ideas? Thanks
Hi, please how to create those instanties from pool in specific hierarchy place ? now it is creating in root, but I need it as child of something else.
I have this problem when I try to make the first object pool that appears in the video (only for one object): -ArgumentException: The Object you want to instantiate is null. I don't know why, but the pool just instantiate once and after that it just "recycles" that same game object but it doesn't instantiates more copies of it. I searched in google and in a Unity support blog said that I wasn't referencing a prefab in the pool script but I am doing that,I'm sure, plsss, I am new in Unity.
i will take the project source and try it cuz i dont see how it work with more type of gameobject and how it will select the "shootV2.0" as exemple. Anyway thx i like the way you do it with the lazy instantiation integrated. Cuz one pool automated for all gameObject will be asweome. See you
Since you're using generics is there a way to make it so that the parameter in shotspool would show up in the inspector, and be able to be set up? That way you wouldn't have to create multiple scripts just to change the type of the item they're pooling
Just implemented the generic version. Really instructive. I still wonder how to implement different types of bullets. Does it require to define a new class for each type of prefab (like GenericObjectPool)? I tried to reference the pool and call Get() from that reference, without success. Two set ups with two different bullet pools and bullet prefabs. But it's the same bullet prefab appearing in both set-ups, and only one pool is filled with instances...
Stupid me... I forgot the ReturnToPool part! So finally I could make two pools of the same type manage their own prefabs just by having public references and passing it to the projectile as well : public ProjectilePool pool; // changed the pool name for convenience ... public void Fire() { var shot = pool.Get(); shot.pool = pool; // because there is another public reference in the projectile class as well. ... } It's working fine without the need to create a class for each type of projectile and just playing with different pools. We could even think of having different pools referenced in the weapon as to switch bullet types, say. @Unity3d College Would you suggest another approach? Thanks for all the efforts you put in sharing your knowledge.
21:04 But then, wouldn't it be better to make a pool of IGameObjectPool? That way were sure that the pooled object will manage their own poolability, no?
I'm going crazy trying to get an object pool working. Must have watched 10 videos now. They all run into an issue one way or another and I must be retarded or something. In this case I'm typing word for word and it simply breaks once I write the Blastershot Get() because it's less accessible than the instance. I've seen this error on 3 videos now and I just don't get what they're doing that isn't being explained or what I'm missing.
Norbert Klar Actually not true, it's the same amount of code or less. I've done object pools for years. I know what is more efficient and what to use. Just from watching how the queue is used, I can see one bad flaw. That comes from experience and using the object pools in many ways.
@@klarnorbert is index = index + 1 mod length too complicated to understand? Maybe if people don't practice they feel things are over complicated? I agree without experience it will feel complicated but that's all it is. If you sit down and use this queue excessively, you'll realize just because there is a video on it, doesn't mean it is the best approach. I see people use lists in other situations and give the same excuse but then they call toarray() without understanding just use an array. At least with my comment people could get curious, investigate and realize a queue is not the only approach, less overhead for same code exists. That is the point I made and not an opinion. If you wanna use a queue, I won't stop you.
@@ZaCkOX900 Okay, you've made me curious now, so I'd like to know your thoughts on this: isn't one of the appeals of collections like queues, lists, and stacks the ability to easily resize themselves on the go? I'm a relatively new Unity/C# coder and so haven't really dug into this myself, but I've often heard that arrays are hard to resize once defined, and pools seem to me like they rarely have a consistent size the way arrays seem to require, thus queues or lists seem better suited for them. The only fix I can think of is making the array way bigger than you'll ever need, which seems like a waste of memory to me. Anything I might not be aware of?
Download the project source here - unity3dcollege.blob.core.windows.net/site/YTDownloads/Pooling%20Pattern.zip
Hey, Jason. I see you doing the Enqueue objects back into the queue only after they expire their lifetime. Is there a reason for that? Why not just put it back in right after we Dequeue() ? Like:
GameObject obj = pool.Dequeue();
pool.Enqueue(obj);
This way we make sure that even if somehow the lifetime of the object isn't ended yet and we already need it again it will just disappear from where it stuck and get back into usage.
@@user-lv6qm3fj2z it would prevent instantiations entirely because the queue will always have a pooled object which would be reused every time it's needed.
@@herohiralal3255 ummm... no? Why would you even mention instantiation? We instantiate all needed objects on start. We don't instantiate anything during the process of dequeuein/enqueueing.
@@user-lv6qm3fj2z we do. If the queue is empty we instatiate a new object. If you don't know exactly how many objects you will need, your option on the pool won't work.
@@danielschulz7391 that doesn't make any sense. We make queue to avoid instantiation during the game to lower the script "weight". Why would we start instantiating objects in the middle? And the fact that the queue isn't big enough to satisfy all the requests - that's when the way I described comes to the rescue. If we return the object into the queue right after we took it from there, then in case the queue makes a "full turn" then we just use the object that is already in use "despawning" it from where it was an inserting it into place, where we need the new one.
I was using the classic "Instantiate and destroy" method on an shooter like game, then I decided to try this... the difference in the performance is HUGE!!! Thanks man!!
IMO you're like Cherno but for Unity/C#. Really appreciate what you're doing. You're dragging my old head up to speed! Thanks, man.
cherno is the friggen goat
Huge help, even two years later. For some reason I just kept avoiding object pooling, but now that I'm working on a serious team project, I feel a duty to do everything I can to make the game run as efficiently as possible. Thanks a million, this was much easier to implement than I though it would be!
"even two years later"
The video was released 1 year ago though?
@@mrp0001 not for me though xD
Coming from a .NET MVC background and watching your videos I'm really glad that someone follows proper coding principals like you. So many Unity videos I see that are just terrible code.
Now that's some real C# programming right there ... generics, lambda expressions, LINQ, delegates & events, those are the sweet features that make C# stand out from the crowd.
awesome tutorial man, explains 3 different cases really well. Perfect, I've watched it 3 times now and I feel like I fully understand how to setup my own pooling case in any situation. Thanks a ton!
In other words, reincarnation.
object reincarnation pattern, sounds good
Loving your videos more and more , although i didn't understand most of it , it will take me at least 2-3 re watches to fully understand the core concept. It gave me a reason to study other concepts also like queue,singleton etc.So thanks for that, will follow your videos regularly to learn new things.
Easier than I expected and clearly very useful and effective, thank you. Nice to see some clean code in a Unity tutorial. Everyone else seems to be competing on speed!
Been trying to wrap my head around object pooling for a lttle while. Thanks you this is way clearer and simplified. Thanks for sharing :D
Used this video to substitute a different pooling pattern I was using and this is a lot better. Well done, sir.
I've always used arrays and create everything when the scene loads. This is a cool new way to do it! Nice!
If you dont destroy the objects inside the array at anytime is pretty much a pooling system anyway, maybe not a proper way of pooling but a pool anyway.
I have a different way of doing this where I'll immediately Enqueue the prefab that the pool dequeues. This may seem counterintuitive, but what that's doing is moving the prefab to the back of the line, but the reference to that object can still be returned to the user. So, that way, the pool never runs out of objects. It also means that the prefab isn't dependent on the pool.
Amazing video Jason, the best Unity channel out there
This is wonderful! Please Make More of These (Tutorials on Unity!)
this solution is so elegant and brilliant! Love it!! Works great!
helped me instantly wrap my head around the concept
Good stuff Jason. Nice to see someone who knows what their talking about. Keep it up. Subscribed.
Thank you! You helped me a lot with my Project!! :)
Thanks for teaching me what game courses did not.
Subbed and I'm a patron! Thanks for your work!
Thank you so much for sharing this information with us, sir. I love your videos especially game programming patterns video. would love to have more of them
I tried making a similar pooling concept to this, however where the poolable objects can pool themselves but ran into a problem, the Queue being static in an abstract class means that every class inheriting from the genericobjectpool will technically have the same pool
Static variables don't get inherited and stay on the "level" of the class that they're at currently, if you pooled a house and a bullet (as long as the house had the same script as the bullet) they would both be used from the same pool.
Idk if I had the same problem as you, although indeed, where I tried the last approach having the same script component but different prefabs, this didnt worked as the Instance was pointing to whatever object was first to claim it. I think its a very important remark.
I ve dealt with that using multiple generics "GenericObjectPool"
And then "public static GenericObjectPool Instance {get; private set; }"
And K should be a specific pool.
thanks bro.... being trying to understand how to code object pooling for a week already, people explain it like sh*t even in my own language hahaha thanks! keep going please!
There is another pooling tutorial with much more views, that fails to explore all the basic and necessary pooling techniques you introduce here, this video should be the topmost one on the subject. Nice job!
One of the reason why games made with Unity have poor performance: game devs can't optimize their games, because their knownledge is non-existent.
Thanks man for going in depth into this
I like a non-generic approach better, you can create a poolable object component with a reference to a pool and a lifetime and inside of update check for lifetime, return it to the pool and disable it. On the pool itself just require this pooling object component instead of GameObject so you can assign pool reference and a lyfetime of the pooling object if needed. You can also make Update method protected virtual inside of poolable object so you can override it and also use a base one.
Good Stuff Jason, many thanks!
Doesn't appear to work with Prefabs!
Jason, I don’t think method 3 is usable in the following scenario: If your blaster is a prefab, but your object pool is a game object in your scene’s hierarchy, then adding the object pool to the blaster via the inspector, and then applying the change to the blaster prefab, will not be possible, because: “A reference to an object in the scene cannot be applied to the Prefab asset”.
All of this information was really great. But my head exploded when I saw that you can vertically select code in the editor???
Small error with the AddObjects() method on line 30 in GenericObjectPool:
It has the argument "count" but that's never used, guessing you just missed to wrap the method in a for loop. Good video nonetheless!
if (count > 1)
AddObjects(count - 1);
Hello, The download link contains different project than the video. Am i missing something here?. Thanks
Great detail and explanations.
i don't understand how he instantiates the prefab..
The prefab is a gameobject, but the type he uses is the controller type (C# class file),
How can you instantiate this while still accessing the Controller's functions?
When your prefab has a monobehaviour on it you can instantiate it and assign to a variable of a type of that monobehaviour. That's how unity works - here: czcams.com/video/uxm4a0QnQ9E/video.html
Awesome Tutorial--Thanks!!
Love the video, thanks!
Jason, is there a threshold before you choose object pooling vs instantiation and destruction or is it always just go for object pooling?
Master
Wonderful Tutorial.
It will be great if you Can you show how to spawn different objects like player bullet, enemy bullet, their particles etc... using same generic pool system ?
Any chance Jason you would let us download your little projects? I would understand much better by following you around on my screen at the same time. The same goes for the pattern videos you do - its just kinda too fast for me plus it would be give me much better understanding if we could just look around how the things are connected
Sure, here it is - unity3dcollege.blob.core.windows.net/site/YTDownloads/Pooling%20Pattern.zip
@@Unity3dCollege Thank you!
Love the last version with Generics. What would be the best way to change bullets types, "look" or "skin" depending on weapon. This system is for the same type of bullet?
Great video, I like the progression in the designs. Have you ever tried to completely decouple the object being pooled from the pool? So the object being pooled has no pool code / awareness?
How do you deal with the integrity of the objects? What if the pooled objects get modified (even by just adding components) and then they end up back in the pool while they are "dirty"? How do you prevent that from happening
Does anyone know why when using the generics version with spawning enemy prefabs they get sent back to the pool instantly after being re-spawned (after being killed once)? This only happens after being killed and works normally when OnBecameInvisible() is called, also works great with my bullets. I thought it was something with the death animation/animator and calling the returnToPool method with animation evens, but nothing has worked. I'm stumped!
You have any tips on how to keep your code manageable as it grows bigger and bigger?
I'm having a hard time keeping my code legible as I keep adding things.
I used to have a script that did all character functions, but now I've broken it up into Player.cs, PlayerInput.cs, PlayerMovement.cs, PlayerWeapon.cs, PlayerAbility.cs and this seemed to work fine.
But now I'm adding multiple Weapons that all function differently like hitscan, projectile, multiple projectile, and melee.
And abilities that are AOE, spawn objects, extra movement, controller enemy movement (like a hook), etc...
So I started using inheritance, a base weapon class, a base ability class, a base Entity class (for players and enemies)
but it's all becoming too much for my little brain to handle.
Any tips on keeping it clean, coherent, and manageable?
Have a great day! :)
Keep notes and draw out your class structure/game's pattern on paper and post it on your walls. The more visual you can represent your code structure, the easier it will be to navigate.
@@gwills9337 Great idea! I'll give it a try. Thanks amigo!
Check this (really great, on-topic content!): czcams.com/video/t4Ze3kIJunI/video.html
I wonder, is there a reason to do this for rapid-fire audioclips? I know that they disappear after the clip is complete, but I can't help but wonder if there's some ramification to that.
i like ur beard
also nice tutorial
I learned about garbage collection when I was programming a WebGL Minecraft clone in javascript and I was instantiating a 4x4 matrix for every block every frame 😂
Hi Jason, been watching alot of your videos, some really insane stuff! I was wondering how you would do this type of approach with textures being downloaded from a web api. 1000s of different textures in varying sizes, how do you deal with the caching, storing and reusing. In webgl builds its extremely memory intensive. Was just wondering if you had any ideas? Thanks
too useful, thanks alot
How does this code determine the count of pooled objects in the scene? I couldn't catch that part in source code. Thanks for the awesome video btw.
nice video, I have a question, if I am shoting using the particles system, does it has its own pool, being a particle system?
Hi, please how to create those instanties from pool in specific hierarchy place ? now it is creating in root, but I need it as child of something else.
nothing, fixed, at least looks like , lets go sleep :D
When you try to scroll down the page to see more of the IDE but you end up at the comments section xD
The IDE is called Rider. He details it and its uses in Unity in a recent-ish video called something like: "11 tips that made me a better programmer".
@@CtisGaming That's not what I was saying, I already use Rider regularly. thanks though :)
About 3rd method. What if we need 2 pools for same GameObjectType?
Thanks!
I have this problem when I try to make the first object pool that appears in the video (only for one object):
-ArgumentException: The Object you want to instantiate is null.
I don't know why, but the pool just instantiate once and after that it just "recycles" that same game object but it doesn't instantiates more copies of it. I searched in google and in a Unity support blog said that I wasn't referencing a prefab in the pool script but I am doing that,I'm sure, plsss, I am new in Unity.
drag the prefab from the AssetsPanel to the gameobject slot in the inspector
i will take the project source and try it cuz i dont see how it work with more type of gameobject and how it will select the "shootV2.0" as exemple. Anyway thx i like the way you do it with the lazy instantiation integrated. Cuz one pool automated for all gameObject will be asweome. See you
Would you please make a video about frames and how can we do animation within those frame like many VR drawing tools.
Since you're using generics is there a way to make it so that the parameter in shotspool would show up in the inspector, and be able to be set up? That way you wouldn't have to create multiple scripts just to change the type of the item they're pooling
Not with generics. You'd just need a single new script inheriting from the generic pool
You can do it with a custom inspector script
Just implemented the generic version. Really instructive. I still wonder how to implement different types of bullets. Does it require to define a new class for each type of prefab (like GenericObjectPool)?
I tried to reference the pool and call Get() from that reference, without success. Two set ups with two different bullet pools and bullet prefabs. But it's the same bullet prefab appearing in both set-ups, and only one pool is filled with instances...
Stupid me... I forgot the ReturnToPool part! So finally I could make two pools of the same type manage their own prefabs just by having public references and passing it to the projectile as well :
public ProjectilePool pool; // changed the pool name for convenience
...
public void Fire() {
var shot = pool.Get();
shot.pool = pool; // because there is another public reference in the projectile class as well.
...
}
It's working fine without the need to create a class for each type of projectile and just playing with different pools.
We could even think of having different pools referenced in the weapon as to switch bullet types, say.
@Unity3d College Would you suggest another approach?
Thanks for all the efforts you put in sharing your knowledge.
The Unity DumbleDore of Knowledge....
21:04 But then, wouldn't it be better to make a pool of IGameObjectPool? That way were sure that the pooled object will manage their own poolability, no?
Yes normally. But Unity is moving towards data only objects plus factory or manager classes for ECS
Honestly, I get why you shaved your beard that that beard was Godly!
I'm going crazy trying to get an object pool working. Must have watched 10 videos now. They all run into an issue one way or another and I must be retarded or something.
In this case I'm typing word for word and it simply breaks once I write the Blastershot Get() because it's less accessible than the instance. I've seen this error on 3 videos now and I just don't get what they're doing that isn't being explained or what I'm missing.
Not clear to which object to attach scripts.
14:32 , 21:32
How do you make a selection like you do at 20:17?
Also thanks for this vid I really needed it!
@@rupsje7974 In Visual Studio Code, just use shift and middle mouse. If in Visual Studio (like Jason here), Alt + Shift and left click.
@@trayfenodonnell5386 Thanks!
@@rupsje7974 Sorry it took 9 months for someone to answer...
@@trayfenodonnell5386 I have been waiting so long for this day!
BEARD!
Fuck I miss that beard
A queue for this is not necessary, I would much rather use something less heavy with speed. Array, integer index increase / reuse, simple and better.
Queue is the most logical choice for this. You can use array, but you need to write more code.
Norbert Klar Actually not true, it's the same amount of code or less. I've done object pools for years. I know what is more efficient and what to use. Just from watching how the queue is used, I can see one bad flaw. That comes from experience and using the object pools in many ways.
IMO with queue it's easier to implement, without overcomplicating it. If you need more performance, yeah, fixed sized arrays is the way to go.
@@klarnorbert is index = index + 1 mod length too complicated to understand? Maybe if people don't practice they feel things are over complicated? I agree without experience it will feel complicated but that's all it is. If you sit down and use this queue excessively, you'll realize just because there is a video on it, doesn't mean it is the best approach. I see people use lists in other situations and give the same excuse but then they call toarray() without understanding just use an array. At least with my comment people could get curious, investigate and realize a queue is not the only approach, less overhead for same code exists. That is the point I made and not an opinion. If you wanna use a queue, I won't stop you.
@@ZaCkOX900 Okay, you've made me curious now, so I'd like to know your thoughts on this: isn't one of the appeals of collections like queues, lists, and stacks the ability to easily resize themselves on the go? I'm a relatively new Unity/C# coder and so haven't really dug into this myself, but I've often heard that arrays are hard to resize once defined, and pools seem to me like they rarely have a consistent size the way arrays seem to require, thus queues or lists seem better suited for them. The only fix I can think of is making the array way bigger than you'll ever need, which seems like a waste of memory to me.
Anything I might not be aware of?
santa!!! :D
one person turned the video off after a 1min becuase they didn't understand 'lets look at a bad example'
May I ask how old you are?
Not rude or something.
I can't wait for ECS, we will no longer have to do all of this stuff.
lol
Its a lot more abstract than monobehaviours, at last at the moment. So beginners gonna have issues
Fuck I miss that beard