Building 2D Levels

Hey guys,

First off, I just started using Unity yesterday so I’m about as new as they come, so apologies in advance for the noobness of my questions.

I have a little 2D project started up where I can move my player around (top down view), camera follows etc, but next I need to move onto level building. My game will essentially be one level, maybe around 3000 x 3000 made up of 16x16 tiles.

My question is, what’s the best way of making the level? I’ve made rigidbody objects that I can assign as obstacles already (just to test), but is it possible to assign an entire layer as an obstacle instead? That way I can have all the level walls on that layer and just do a blanket ‘if player collides with object on this layer’ condition. Or do I have to make every single wall sprite rigidbody and do it that way?

Any pointers or links to info you can share?

Rigidbodies are only for objects that move; if objects don’t move then they don’t need rigidbodies. Sounds like you should use a tile system. Using an object for every tile is a bad idea.

–Eric

Uh oh. The project I recently started is tile-based, and so I need to figure out how to handle collision with raycasts or something. I can’t imagine how I would build my game without making each tile an object because they need to be destructible. Hmm.

There are tile systems on the Asset store. I bought one for like 20 dollars (I don’t remember the exact price) called SpriteTile. It should do what you want.

The general concept is that you use a data structure to represent a tile, and an array of that data structure to represent the world. Then you use some method of displaying the array that doesn’t use one GameObject for every tile. In the case of SpriteTile, it creates enough sprites to fill the screen, and recycles them as the camera moves, so it’s like a “window” into the world.

–Eric

I’ve been trying to do as much without purchasing pre-made stuff as possible but I might have to look into it. When I’m at home (and not typing with a phone ) I’ll have to share my code, and maybe you can tell me if you think it’ll work with SpriteTile. I don’t know how much it matters, but my game will not have a moving camera. It’s supposed to be something like Towerfall, if you’re familiar with it.