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

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.

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

Short intro of us 💕✌️

We're an eletro duo based in Seoul 🇰🇷 Heavily influenced by the 90s.

Our new album #Xennials is all about the nostalgia of that era 💽 CD listenin 📟 beeper beepin 💾 floppy disks floppin days 😎

Stream now! 🎧

https://open.spotify.com/album/3YwWhnHWVy5cA8XOpbaGRA?si=8E9awqU…

We are under attack!

Have a good Boi

Protege el conocimiento, salva la historia. Guardian of Lore es un platformer 2D en el que debes luchar para mantener viva la memoria de la mitología latinoamericana. El juego llegará a Steam el 18 de mayo: https://steam.pm/app/1211740 #ScreenshotSaturday

"Our work is never over" they said.

The whole squad is here!

Interested? Follow me!

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

We're glad to announce that Baby Dino Adventures 🦖 is now available in Early Access here on GameJolt! Link: https://gamejolt.com/games/babydinoadventures/508121 Walk, run, and jump as a baby t-rex in this cute platformer Free demo available #IndieGame | #GameDev | #PixelArt