Hello Guest

Author Topic: Tilemap for platformer - Questions  (Read 6267 times)

luispedrofonseca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 26
    • View Profile
Tilemap for platformer - Questions
« on: July 29, 2013, 04:05:37 pm »
Hi,

I'm currently trying to use the new tilemap (2.1 final) with a platformer I'm building, but before moving much more forward I have some doubts.

1) What would be the ideal way to implement platforms with different properties? With the current setup (without tilemap) I have a script attached to every platform that assigns it some properties (one sided, friction, slidable, etc), but since with the tilemap I think it's not possible, how would you do it?
What I'm trying to accomplish is to have for example a wall that the player can slide or a platform that is made of ice, etc.

2) Is it possible to implement parallax effect with tilemaps? Is it "allowed" to move the tilemaps during runtime or would you just use a perspective camera?


Thanks in advance for your time!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Tilemap for platformer - Questions
« Reply #1 on: July 29, 2013, 04:20:38 pm »
1. You can use layers in the tilemap editor, or you can dynamically query the tile the player is on, and then modify properties that way.
2. Don't move the tilemap, use layers, set unity layers on the ones you want parallax on - check out the parallax camera sample on this forum. Perspective cameras will work too, just remember to set transparency sort mode.

luispedrofonseca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Tilemap for platformer - Questions
« Reply #2 on: July 29, 2013, 04:35:53 pm »
Thanks for the prompt response!! Sorry but I'm not entirely sure I understood your layer suggestion.

You mean having a different tilemap layer for each platform type? What if I want to have walls with different slide speeds? I might end up with dozens of different layers... Is that a problem?
Can you elaborate on how would I query the tile the player is on? I'm using raycasts to detect collisions.


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Tilemap for platformer - Questions
« Reply #3 on: July 29, 2013, 04:59:27 pm »
Having loads of layers depends how big your map is.

After you raycast and find the intersection, you can use tileMap.GetTileAtPosition, that will return the x, y tile position in the tilemap. You can use that to find out what tile is at that position tileMap.Layer[0].GetTile, etc. You can also use GetTileInfoForTileId to get the info for a particular tileId (configured in the data tab of the tilemap editor).

luispedrofonseca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Tilemap for platformer - Questions
« Reply #4 on: August 09, 2013, 02:52:25 pm »
Hi,

Is it possible to know the width and height of a tilemap? I don't mean the total width and height, but the "used" area.

I need it to limit the camera movement only to the viewable area.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Tilemap for platformer - Questions
« Reply #5 on: August 09, 2013, 03:01:28 pm »
No it isn't. You can iterate through the tilemap.Layer[0].GetTile(x,y) and see what isn't -1 to work this out.