#how to detect if a characterbody2d is within any tile of a tilemap.

1 messages · Page 1 of 1 (latest)

silent light
#

So..I don't know how to do it with the tilemap. Im pretty sure its not even possible, since a tilemap only serves as a raw outline of the world. For more complex thing regarding the game, like a wall run, you'd have to make it a scene. ( I think, i could be wrong obviously )

But i do have an idea. I'd make a scene called "Wall run" or something and just have all the wallrun mechanics in there. Like the sprite for the wall. And an Area2D to detect where the player is. Then drag it in the main scene at the places where it needs to be.

First check youtube if there is a tutorial on how to make this, since i might be wrong about the fact that you can't do this within the tilemap.
But if there isnt any tut's try this method.

cerulean pike
#

First translate the character's position to cell coordinates with TileMapLayer.local_to_map(), then use TileMapLayer.get_cell_source_id() to see what is at X position in the TileMapLayer.

If it is null, then you can call that death function.

cerulean pike
#

Make sure to use a position that is local to the TileMapLayer with TileMapLayer.to_local(). Make sure to use a global_position in said function