+3 votes

I tried to include sprites with attached scripts into a tilemap, but these scripts don't seem to be executed when using these tiles. Could there be any way, to get this to work, or is there a reason behind this?

in Engine by (217 points)

1 Answer

+3 votes
Best answer

It's not possible, you cannot have a script for each tile. This is a quote from reduz explaining the limitation of TileMap in favor of performance:

more stuff could be eventually added, but in truth the idea is that you should combine the tilemap with instanced objects, not use one or the other.
Tilemap is designed to draw large amount of quads quickly, so adding more flexibility would beat the purpose. What is the problem of combining both?

As he explains, if you want more advanced behaviour, you can use other nodes for that task.

by (488 points)
selected by

Well, thanks for that. This is actually, what I'm currently doing. But I was curious, if there is a more simple or elegant way.

Hey,

I am sorry to re-open this thread, even if I found it useful to understand the limitations of TileMap node.
However, being new to Godot, I am running into the same problem as PixelWizzard and I can't find a proper way to solve this problem.

For now I am using scenes as tiles (with script attached to it), but I don't think it is the way to go when there are hundreds/thousands of tiles involved.

Does anyone has an idea on the best way to do it ?

Many thanks in advance :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.