Tilemap collisions for procedurally generated tilemap (DEF-3609)

#1

Hi
I’m trying to generate tilemaps procedurally and I run into problems with the tilemap-colliders.
I use a Tilesource with colliders defined, and my tilemap has a collision component for the tilemap. When I set a tile I get an error message complaining about the collision objects.

ERROR:GAMESYS: Hulls can only be set for collision objects with tile grids as shape.

Is there a way to trigger a regeneration of the colliders in the tilemap after changing the tiles?

EDIT:
The problem turns out to be the extra collision-object I have in the go. I have one collision object with the tilemap as shape, and one with four boxes marking the edges of the screen. If I remove the collision object with the boxes there are no errors.
So it seems that the generation of the tilemap colliders also tries to update the other collision object, which throws errors because it is not a tilemap-collider.

Is this a bug or am I doing something wrong?

1 Like

Unofficial Defold Game Jam #2
#2

I have also used procgen a lot these days, but I have never run in that error. Usually, when I regenerate the tilemaps, the collision objects set themselves accordingly,without the need to interfere manually.
BTW have you tried enabling physics debug from game.project to see actually what is happening to the collision shapes.

1 Like

#3

when I regenerate the tilemaps

This sounds like it could be my problem. How do you regenerate a tilemap?

0 Likes

#4

Ok, I hade made another mistake that made the colliders not work. They work now, but the error message is still spammed.
image

I have two collision objects in the go. One for the tilemap and one with four boxes for the edges of the screen. Could that be the problem?

0 Likes

#5

I don’t think that they can be a problem, but have a try removing them.

1 Like

#6

I did, and they turned out to be the problem. The collision generation seems to be trying to generation colliders for that collision objects as well, which does not work of course.

0 Likes

#7

Did you only use the tile map colliders in your levels?

0 Likes

#8

For the tilemap collisions yes, but there are other collision objects too, for player, enemies, etc etc.

0 Likes

#9

It seems to me that the errors are caused by there being a second collision object in the same game object. Did you have those other collision objects in the same go with the tilemap?

0 Likes

#10

No. But let me try it.

1 Like

#11

Thanks! :slight_smile:

1 Like

#12

Just tried it, and it seems to be the same case you mentioned

1 Like

#13

Ok, thanks! I’ll post it as a bug then.

0 Likes

#14

Should be an easy workaround to put the collision object with the boxes on a different GO. It definitely sounds like a bug, but I think you came up with an unintended way of doing things.

1 Like

#15

Yes, maybe I’m going against the grain so to speak. And I agree it’s not hard to work around.
The reason I have the extra collision object in that same GO is because I want the same behaviour to be triggered by tilemap-colliders and manually placed colliders. E.g. I have a special tile that marks the exit from that map, but I also have a screen boundary box that triggers an exit. By having them in the same GO I can have a single script on that GO to control all ways of exiting. It’s separation of concerns I’m trying to achieve I guess…
But maybe there is a smarter way of doing this in Defold. I’m totally new to Defold and I keep running into things that work differently than I expect.

1 Like

#16

Sounds like a bug for sure! Added ticket DEF-3609 to track this issue.

4 Likes

#17
Hulls can only be set for collision objects with tile grids as shape.

Bumped into this error today when I added a trigger collision object to a game object that already has a TileMap collision object. Was there ever a solution to this?

0 Likes