- Home /
Large 2D polygon mesh levels
Hello guys. I'm making a platformer game inspired by "Ori and The Blind Forest". The only thing that confuses me is how do I make really large freeform levels. Obviously using a really large image for level and collider would be too heavy for memory so it would be nice if someone knows a way to do such thing and how to implement it. Thanks in advance.
Answer by Rygaran · Mar 29, 2018 at 05:59 PM
well, it wildly depends on what you want to do exactly, but you can use smaller sprites for things suck as rocks, ground, and other decorations and build the lvl like that, you can use tilemaps as well, you can even use 3d models if you want and still use 2d physics, as for implementing them, you should look up tutorials on these things and from there you can figure out what's best for you.
The main problem here is optimizing such large levels. I couldn't find any examples on dividing huge 2d levels to chunks or anything like that so that's why I'm asking here. I'm not going to use tiles so tilemaps are not an option I think.
well, if you want to divide by chunks, you can do that by storing the all the gameobjects that are in an area to a list on a 2d array. For example: you get all objects and all that are between 0,0 and 10,10 are added to the list in [0,0], all thar are in 0,10 and and 10,20, go in [0,1] and so on. you'll then need to spawn the currently visible chunks on runtime, For this you should use a pool, so you're not instantiating and destroy objects. For getting the lvl data, you can use editor scripts to inspect the scene and create a file with basic information of the asset, like id of the sprite, size, and position within the chunk
Oh, that clarified some things for me. Right now I'm just storing all the objects in the array and activate/deactivate them if they're in range with a player. Using pools is an excellent idea. Now I sure know what to do. Thank you!
Your answer
Follow this Question
Related Questions
OnCollisionEnter2D Not working! 2 Answers
How to detect CompositeCollider2D shape center? 0 Answers
how can i change tile map collider2D's outline collider to shape? 0 Answers
Player movement 1 Answer