How to use a TileMaps like area 2D

Godot 4.3

Question

I’m making a 2D Platformer for school and wanted to add spikes. The tutorial I saw made the spikes as a separate scene but I want to be able to draw the spikes with a Tile Map Layer. I was wondering if there was a way to make my tile map layer I have for spikes act like an area 2d to output a signal when entered by the area 2D of my Character. If anybody needs extra details I would be glad to provide them.

It is possible to use scenes as if they were tiles. You can read more about this here: https://docs.godotengine.org/en/stable/tutorials/2d/using_tilesets.html#using-a-collection-of-scenes.

Note that there is a performance penalty for this. It may be negligible for your game, so don’t be afraid to try! Just keep an eye on the performance of your game.

1 Like

Another way to do it would be to put the spikes on their own collision layer in the tilemap. Put an Area2D on the player that collides only with the spikes, and then whenever there’s a collision, execute your code. It will only execute when the player hits the spikes.

1 Like