Hello Guest

Author Topic: Detecting what tile your player lands on.  (Read 4019 times)

CallumHolden

  • Newbie
  • *
  • Posts: 5
    • View Profile
Detecting what tile your player lands on.
« on: September 07, 2013, 11:21:59 am »
Hi all,

I have recently bought the 2d toolkit; and am very impressed with it. But I just have one question.

Is there a way to detect what id the tile you just landed on has? Therefore I can do things like make jump blocks etc...

Thanks!

Pfaeff

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Detecting what tile your player lands on.
« Reply #1 on: September 07, 2013, 03:19:50 pm »
You can use a prefab on the block that has the logic for launching your player in the air. You can assign these prefabs in the tilemap under "data".

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Detecting what tile your player lands on.
« Reply #2 on: September 07, 2013, 05:48:23 pm »
Prefabs are definitely the best way of going about this as you can associate behaviours directly by painting tiles.
But to answer the question you can work out a tile at a position using tilemap.GetTileIdAtPosition.

CallumHolden

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Detecting what tile your player lands on.
« Reply #3 on: September 07, 2013, 10:33:23 pm »
Yes that is the method I am currently using, I have an empty gameobject with a box collider with a script attached to it. And thanks I will look at the tilemap.GetTileIdAtPosition.