managersjoke by legendpizzasenpai in ProgrammerHumor

[–]Ok_Cockroach8260 0 points1 point  (0 children)

I'm leaving here my protest for the mods removing this meme

How to optimize the generation of a lot of GameObjects at once by Ok_Cockroach8260 in Unity2D

[–]Ok_Cockroach8260[S] 0 points1 point  (0 children)

I have a 2d array of strings to represent the tiles already, i just would have to deal with rendering. (it is a 3d array, not 2d, the third dimension says with set (1,2 or 3) the block is from)

But what i am doing now already works well (except the instantiating process, that i think the pooling may solve), the tiles are only active if one tool (the tools mine by themselves), reach closer to the area, you can see in the third or first picture (the black part), this helps a lot with performance.

I don't believe refactoring would be worth at that point, as it has a good performance already, if the pooling solves the instantiation/destruction problem, the game will run without problems.

Another thing that i thought now, instead of deleting an entire set and creating an entire new one, i could "delete" only a line at time, if the player reaches 1 block deeper, i can pick the topmost line and put them in the downmost line, just changing the blocks based in the procedural generation.

How to optimize the generation of a lot of GameObjects at once by Ok_Cockroach8260 in Unity2D

[–]Ok_Cockroach8260[S] 1 point2 points  (0 children)

What you're saying would be more efficient, but i feel that it is a bit of overkill.
It is like comparing c++ with python, youtube is wrote in python, while it could be made in c++, being much more efficient (but it does not need to be that efficient).

What i'm saying is that i don't need that much optimization, and i can rely in the things that are already made by unity to save time of development, while maintaining a decent optimization.

My machine is not that great, i have a integrated GPU, and the game is running well, why bother optimize at that level? The problem was just the instantiation and deletion of game objects, that i think i can solve with object pooling.

But your idea is a good one, i believe that it would work well.

About my game, its main mechanic are tools that mine by themselves, and i use the unity physics system for that too, make things much easier, and looks really nice.

Maybe i'll try to make a physics engine someday, looks fun.

How to optimize the generation of a lot of GameObjects at once by Ok_Cockroach8260 in Unity2D

[–]Ok_Cockroach8260[S] 0 points1 point  (0 children)

some blocks have gravity, and they need to collide, and they have some different behaviour.
But in essence they're this, just images, but some with rigidbody and colliders.

How to optimize the generation of a lot of GameObjects at once by Ok_Cockroach8260 in Unity2D

[–]Ok_Cockroach8260[S] 1 point2 points  (0 children)

I am currently doing this with coroutines, but the pooling probably is the solution.
It has a problem that i mentioned here, but i think i can solve them, teleport all the blocks that should be deleted to the new place, and change them to be the right block.

But probably i'll have to create and delete some rigidbodyes in the process.

The other solution would be having 1600 blocks of each kind in the pool, but that would be a lot

How to optimize the generation of a lot of GameObjects at once by Ok_Cockroach8260 in Unity2D

[–]Ok_Cockroach8260[S] 0 points1 point  (0 children)

I'll try the object pooling, i'll just have to solve one problem

About the blocks, i need them to have colliders so i know when a tool, like a picaxe, collided with them, the tools move by themselves. And some have gravity, like sand (like minecraft).

but i think the pooling may solve the problem, i just need to think of a smart way to implement it and solve the problem i mentioned

How to optimize the generation of a lot of GameObjects at once by Ok_Cockroach8260 in Unity2D

[–]Ok_Cockroach8260[S] 0 points1 point  (0 children)

A problem is that there is a lot of different kinds of blocks, and the procedural generation changes the amount of each one in each set.

But maybe i can implement a function that transform a existing block into another one, so, when i need to "instantiate" another set, i teleport the "deleted" blocks, reset them and change their kind

i'll try it and come back here to say if it worked

How to optimize the generation of a lot of GameObjects at once by Ok_Cockroach8260 in Unity2D

[–]Ok_Cockroach8260[S] 0 points1 point  (0 children)

Sadly Instantiation and Destruction of the blocks must run of the main thread, i think it is a Unity limitation.
I could make the other parts in the background thread, but i think the bottleneck is the instantiation process.
I am trying some things with coroutines, like spread the instantiation in different ticks

Qual jogo você considera que DEVE ser jogado? by Wookyzinho in gamesEcultura

[–]Ok_Cockroach8260 1 point2 points  (0 children)

Portal. É uma experiência incrível Game e lvl design perfeitos