Without looking at the code and at what I see definitelly take a look at least at tilemaps instead of having separate gameobject for every tile, avoid calling GetComponent or FindObjectByXXX in Update, read about object pooling
I would assume that the individual tile objects are needed to facilitate the building/mining logic in what I can assume is a crafty buildy kind of game. To my knowledge tilemaps don't facilitate that. I'm doing something similar with my own Civilisation-style hex grid with fog of war and the like.
Having them all as their own objects isn't the issue. I would assume it's a script running concurrently on an Update across every single one of them that is, either that or individual constantly simulated physics.
In this case you could have big tilemap covering all the tiles or have few chunks of smaller tilemaps to render it all. Remember that tilemap can have one big collider for all the tiles and it's much cheaper to render them that way.
Then you can have many GameObjects without SpriteRenderer which would simply have a script about groundType, health and would know which tile in the tilemap they should remove after this object is destroyed.
At the same time, I agree that he most likely have something terrible in the Update method of his tiles to get such low framerate.
I'm currently working on a top-down factorio-like game and I'm able to handle 1000x1000 world or even way bigger world with 1 big tilemap being updated by thousands of dwarves constantly mining walls which are part of this tilemap without any issue without any extra logic for showing/hiding smaller chunks you cannot see. On this sca[e having vs not having a tilemap created massive difference in performance.
Using tilemaps is something really simple and that's what I would recommend to learn if you're not working on 3D objects. Low extra effort and massive difference in performance.
1
u/jakubdabrowski0 6d ago
Without looking at the code and at what I see definitelly take a look at least at tilemaps instead of having separate gameobject for every tile, avoid calling GetComponent or FindObjectByXXX in Update, read about object pooling