Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Most efficient way to implement platforms?

Discussion in 'Physics' started by ultrapingu, Jan 20, 2015.

  1. ultrapingu


    Jan 20, 2015
    Hi all.

    So I'm building a platform game, and I'm intending for the final product to be something like a 2D metroid game, in that rooms will consist of many tiles placed together to make them up. What I'm wondering is; what's an efficient way to implement collisions for the floor, walls, and roof? Currently I have one game object per tile, and each tile contains a box collider 2D. This works really well for prototyping, as my level designer can just drop blocks in, but as you'd imagine, this isn't the most efficient method. My first thought is to separate the colliders from the tiles so that many colliders can be combined into one. From there I will probably develop some graphical solution to render a tile sheet (I've seen a tutorial on this, but I'm not totally sure about doing it in a way that's nice to use for the level editor).

    Anyway, my question is, can you think of a better way to handle world collision?
  2. cjddmut


    Nov 19, 2012
    If you're ok spending a couple bucks, I've used the tilemap feature of 2DToolKit to handle tiles and their collisions. If you don't like that option (or don't find another asset that solves it for you) then you'll probably want to know which tiles are 'on' and construct a large collider that covers the tiles.
  3. Cpt Chuckles

    Cpt Chuckles

    Dec 31, 2012
    when i started making a platformer in GameMaker i would drop in tiles that had no collision on them at all and then add invisible collision boxes where the ground/walls were etc. so basically i had my tiles make it look like the ground took up half the screen, but in the room editor you could see there were only colliders along the edge of the ground and nowhere else. you might want to do something like that just to keep from calculating collisions on all of the untouchable tiles. you could probably just drop in some empties with box colliders on them and scale them to create the boundaries, unless you can create a script that combines adjacent colliders somehow which would make the level design process a little faster but yield the same result.