Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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.