Hello Guest

Author Topic: Custom Tilemap Collision?  (Read 3809 times)

TDippingSauce

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Custom Tilemap Collision?
« on: June 30, 2014, 02:37:08 pm »
Hi guys, I'm new to unity3d and 2dtoolkit, and I just followed tilemap tutorial on documentation board, and also read about Tilemap class reference.

What I want to implement is - moving tiles around freely, just like the game Minecraft.(This is 2d so more like Terraria.)

Player can pick a tile, and move that tile to wherever he wants.(Of course the tile will be snapped on tilemap grid automatically. Oh, and the map is not infinite - Character moves room to room so map won't be too big.)

I think i can achieve moving tiles by just using getTile(), setTile() and Build().

But, the reference says, "Build only rebuilds affected partitions and is efficient enough to use at runtime if you don't use Unity colliders."

Also this - "Avoid building tilemaps every frame if you use Unity colliders as it will likely be too slow for runtime use. "

So What I'm curious about is, Certainly there will be so many Build() calls in my game, but it won't be called "Every Frame". I use Box Trimmed collider which is pre-defined on sprite collection editor, and I'm worried if it will cause speed problem like the reference says.

Is it too much concern? I hope it is. Anyways, I'll wait for the answer :)


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Custom Tilemap Collision?
« Reply #1 on: June 30, 2014, 03:16:20 pm »
If you want to build something like terraria, I strongly recommend NOT using the colliders on a tilemap. The tk2d tilemap system will generate an optimal collider "skin" but that comes at build time cost.

For something like terraria, where everthing is aligned to a grid, either spawn box colliders where you need them and move them about as needed, or roll your own collision system. They are just boxes after all... Both of these solutions will work much more efficiently than the tk2d tilemap system, which is a lot more generic.

TDippingSauce

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Custom Tilemap Collision?
« Reply #2 on: June 30, 2014, 04:25:40 pm »
Well It's little bit sad that I have to implement my own collision which certainly will take some time :P But Anyway thanks for the answer, and also thanks for the great tool.