Assigning primitive collision shapes (e.g. capsule, circle, etc) to tiles in a TileSet

Godot Version

Godot 4.6

Question

I want to apply some circle and capsule collision shapes to some tiles in my tileset. The only way I know to assign collision shapes to tiles is through the "Physics Layer" in the TileSet where I can create the polygon collision shape and drag/add/remove nodes.

Is there a workaround to using primitive collision shapes in a TileSet? Or is the polygon the only option?

Thanks

Do you mean for individual tiles?

One way is to save them as scenes and load these scenes into a scene-tileset. If you do that, you can control things such as scripts attached, childnodes etc.

I believe collision shapes of individual tiles are otherwise limited to what you find in the tileset editor. = It can not exist outside of the tile.

1 Like

Yes, individual tiles.

Now that you say it, that does seem like the best option. I had disregarded it because the docs mention it comes at a performance cost bc each scene is instanced individually. However that’s really no different than having those same nodes all instanced outside of a TileMapLayer, is that correct?

I had intially imagined it being more costly than it would be to instance them outside the TileSet/TileMap but I think I just misunderstood the docs.

I dont think they would be more heavy inside the tilemaplayer than outside of it. Probably the opposite as they are not individual nodes. Either way they should be a lot easier to work with inside it!

I guess you could have some signal emitted every once in a while, so only the part of the tiles closest to the player would check for collisions. But i wouldnt think about that yet unless you already know that this will become a problem.

1 Like