Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | alexzheng | |
Old Version | Published before Godot 3 was released. |
I thought define a tile with sprite and a body as a brick, when a player hit the brick, it will get the body and I can remove it easily, however I was wrong, what I get was the TileMap,How can I remove the tile that collide with player?
Thanks.
Another more straightforward example, place coin tiles on the TileMap, is it possible to make it pickable?
alexzheng | 2017-05-12 00:02
I checked the platformer demo, and the TileMap is only used for paint static tiles such as ground, other objects are placed by scene instances.
I think if these objects can be defined as tiles then place them on the TileMap will be much easier.
Since each tile is defined as a sub scene, why we can not just treat the TileMap as a helper container for placing these scene?
alexzheng | 2017-05-12 02:44
Is your player a rigid or kinematic body? And I think what you need to do is get the collision information as a position (perhaps using contact reporting?), and then use the TileMap#set_cell(x, y, -1) call to clear that cell.
Max Aller | 2017-05-12 03:22
Thanks for your reply.
My player is a kinematic body, my request may be beyond just clear a tile when collided.
I need to know what kinds of body the player hit, and call some method of that scene.
alexzheng | 2017-05-12 03:53
Still not 100% sure what you mean by painting a tile (are you adding a tile or removing one? unclear), but if you look at player.gd file in the Kinematic Character demo, there’s a line that mentions
# You can check which tile was collision against with this
# print(get_collider_metadata())
Might start looking there if you haven’t already.
Max Aller | 2017-05-12 03:57
painting a tile I mean adding a tile to the TileMap, it’s much easier than adding lots of scene instances.
Thanks, I will check this api
alexzheng | 2017-05-12 06:00