Game
Land Of Enchantments
6 years ago

New Object Pooler system and more performance!


Hey, it’s been a while since I posted something here. So today I want to talk about this weekend’s progress on the Land Of Enchantments.

I use Unity to develop my games. Unity has a method called Instantiate. A method, for those who don’t know, is a block of code that executes a certain command of whatever length you want. They have names so that you can differentiate between each one. In this case, it’s called Instantiate.

Instantiates basically creates an object wherever you want. But it is a slow process. So, thinking of that and motivated by Brackeys Object Pooling video, I started using his Object Pooler design.

An Object Pooler instantiates and caches all of the objects you’ll need in-game when a level loads, so that there’s little to no time spent Instantiating those objects during the actual game.

But even an Object Pooler can go wrong. Brackeys implementation is not the best, I must say, and it lacks features. Of course, it’s a simple one for beginners, but he could have made a more feature heavy version of it.

For each different type of Pool that I wanted I needed to recreate the Object Pooler and add another Spawn method. So, let’s say I wanted a Pool that returned me an object of type Item and one that returned me GameObject. Those were two different methods and, in the end, two different Object Poolers.

Also, if I wanted to add an object to that system I needed to create a new item in a list that was representing the pool and assign the object. If I didn’t use it anymore I ended up forgetting about it and leaving it there, consuming RAM, you know, boring stuff. For that reason, it was not performing well.

At that time my game played at an average of 70 frames per second, which, in my rig is a real achievement. But I knew that it could be better.

So what I did was rewrite my whole Object Pooler from the ground up. Now it is much more feature heavy, and you don’t need to assign anything from the Inspector. Every object that needs its own pool creates them on the scene beginning so that if the object isn’t in the level no RAM will get unused.

Now, that took me only a day. I did it on Friday. But what took me the whole weekend was replacing all of the calls that I had to it and, boy oh boy, a lot of obsolete and slow stuff that I had to replace.

After all of that, my game is running at an average of 85 up to 95 fps sometimes. So I managed to gather up 15 fps. That’s a solid proof that sometimes premature code optimization can be good.

I know, that’s a rather long and boring post. So, you guys let me know if I should or shouldn’t make that Object Pooler public.

That’s it guys, go and visit my Tumblr blog, which is https://multiplegamestyles.tumblr.com because things there are getting cooler. I talk about other games there, and sometimes even game dev. Cheers! Also, don’t forget to follow me on Twitter where you’ll receive more updates about Land Of Enchantments and you’ll also be able to vote for what I’ll post on my Tumblr blog.

#gamedev #adventure #platformer #3d

  0 votes Voting finished



0 comments

Loading...

Next up

Oh well, it was about time that I added a working Controls tab to the game's pause menu.

I'm trying to finish the planets' configurations, but my game ain't making it easy. As soon as I'm done I'll make a post on the game's page! Meanwhile, enjoy this image of Vulram, a moon in the game.

Just as Pecaminosa's musicians #improvise this rendition of #LittleSunflower 🌻, so do we improvise with this post you're reading. 😂

What's coming out of your own improvs? 🤔

#Pecaminosa | #IndieDev | #OST | #Jazz

Here's a peaceful little forest scene for this #screenshotsaturday, from the beginning of the game.

Quantum precognition is one of the most powerful cards. End game cards & equipment. Demo/alpha build boss is no match for this deck.

The whole squad is here!

Interested? Follow me!

Microsoft Windows XP Unprofessional (windows logo prototype)

Rockin the Guitar, an Axe like Guitar I made for my Uni project

Why walk when you can jump?

"Day to Day" (also check spud out here he's a great guy and writer: https://soundcloud.com/spudward)