Hello Guest

Author Topic: Assigning a layer to tilemap sprites  (Read 3567 times)

arvz

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 21
    • View Profile
Assigning a layer to tilemap sprites
« on: February 06, 2014, 01:32:43 pm »
Hey!

I'm building a 2D side scrolling prototype where the character is able to jump and land on the ground. Using the sample assets (beta) 2D Character prefab. I have created a new Unity layer called 'Ground' that is for all ground sprites that the character is able to land on.

How could I integrate this using the Tilemap? One way I have done it is to create a prefab of a tk2dprite that is going to be a ground, with a box collider and its layer assigned to Ground, and using the Tilemap Data feature to replace all instances of this sprite with the prefab I created. Is this the most optimal way? This becomes a problem for me currently as I'm using the same sprite for this ground that is turned upside down, and is not a ground, but of course since it's the same sprite the tilemap replaces them with the prefab I created.

If I do stick with the prefab/data method (if there is no better way) how would this perform? The levels are of course static - do tilemaps do static batching? Would they still be statically batched if they turn into my prefab?
« Last Edit: February 06, 2014, 01:38:41 pm by arvz »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Assigning a layer to tilemap sprites
« Reply #1 on: February 06, 2014, 10:09:10 pm »
The 2D character prefab is rather annoying, its really not practical to set up a level of any scale in that manner. I take it you've seen the super hack for sliding up platforms? You could set it up by creating unconnected polygon colliders in different layers - you can create layers with just colliders, turning off graphics - each tile map layer can have a unity layer assigned to it.

btw, you can modify the character prefab to work without that. Might be a bit easier long term if you're planning on building a big level.

arvz

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Assigning a layer to tilemap sprites
« Reply #2 on: February 07, 2014, 12:30:21 am »
I'm really only using the 2D character prefab as a test, long term I won't be using it at all.

Did not know there was a Unity layer that could be assigned to tile map layers, this is exactly what I was looking for! Thanks for always providing quick support :)