0 votes

Hi i have a small question. How i can detect every block separately in tilemap

i use c# in my scripts

here is my script whos i use but i must create new tile map to detect my lava or spikes as new collider to detect it. When i need those elements as one tilemap
https://prnt.sc/pvhj2o

asked Nov 11, 2019 in Projects by daniel500013 (65 points)
edited Nov 11, 2019 by daniel500013

1 Answer

+1 vote
Best answer

I often find it's easier to create multiple TileMaps for different types of objects. Think of it like layers in Photoshop - ground layer, hurt layer, items layer, etc. You can use the collision layer system to really simplify your code.

That said, if you want to detect what tile you've collided with, you take the collision position, convert it to tile coordinates (world_to_map()) and find the tile type with get_cell().

If you'd like to see an example of this in action, I've written a tutorial here:
http://kidscancode.org/godot_recipes/2d/tilemap_collision/

answered Nov 11, 2019 by kidscancode (16,476 points)
selected Nov 28, 2019 by daniel500013
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.