Reputation: 41
I'm working on a project where once you step out of a tile, that tile becomes a lava tile. (meaning you can only step on a tile once, making for some interesting levels.) But I cant figure out how to check if the player exits a tile. Please help. Thanks
Upvotes: 1
Views: 1570
Reputation: 111
TileMap
has a function to tell you which tile a given position corresponds to.
Assuming you are in your player script, you can find which tile you are standing on with:
tile_map.local_to_map(position)
Now it's just a matter of saving the current_tile in a variable, and then check if the tile still equals current_tile
, if not, we changed tile and it is time for current_tile
to go lava.
However, this may be pretty inefficient to run every cycle, so I'm happy to be pointed towards a better solution (researching this led me here).
Upvotes: 0
Reputation: 71
Have you looked at Area2D
. It provides you with enter and exit events.
Take a look at the links below.
Upvotes: 3