Spike obstacles to reload scene on collision with player.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ben2420

Hi, I’m making a simple 2D platformer game (quite new to Godot). I have one Tilemap for all the platforms and another Tilemap for spike tiles. I want my player to restart (die) when touching the spike tiles however the only way I can think of getting it work is to make each spike an individual Node and duplicate with an Area2D to detect the collision but this seems a very slow process and would leave me with so many spike Nodes with the amount of spikes in the game!

Is there a way to allow my player to interact with the Tilemap so I can place spikes quickly and easily on my map as a Tile?

Thank you!

:bust_in_silhouette: Reply From: betauer

I’m afraid you are facing the problem in the right way: individual nodes with Area2D to detect collision. The “trick” here is creating a scene with the spikes and use some special tiles in your tilemap to spawn them in the _ready() or _enter_tree(): functions.

You could try this addon (I’ve never use it and I don’t know the author): https://github.com/qtip/tile-spawner/tree/master/addons/tile_spawner