2D Toolkit Forum

2D Toolkit => Support => Topic started by: CallumHolden on September 07, 2013, 11:21:59 am

Title: Detecting what tile your player lands on.
Post by: CallumHolden 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!
Title: Re: Detecting what tile your player lands on.
Post by: Pfaeff 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".
Title: Re: Detecting what tile your player lands on.
Post by: unikronsoftware 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.
Title: Re: Detecting what tile your player lands on.
Post by: CallumHolden 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.