However I’m having a problem when creating the tilemap objects through an object factory.
As you can see in the following screenshot, the tiles are updated correctly by the script, but the collision does not get updated.
(screenshot from when the tilemap object was created by a factory)
What is also strange is that as you can see in the screenshot, new collision areas were created correctly, however they weren’t removed from where tiles were removed.
For now, as a workaround, I will inverse my generation approach and have the script close holes which are open by default, since apparently collision areas can be added but not removed?
Or tell me if there’s a better way to achieve what I’m trying to do
Thanks!
PS: Floor tiles are being randomized, don’t think that these are different tilemaps
When modifying the tilemap, are you changing the correct layer? If you’re adding the new tiles in a different one, the original layer would remain hidden underneath, including the collision objects.
Yes I’m definitely editing the correct layer. When I add the tilemap to the scene manually via “Add Game Object File” (screenshot 2) everything works perfectly and the collisions are set up correctly. It is only when I create the exact same object using a factory (screenshot 3) that this issue appears.
Now that I think about it, I ran into something like this when I was working on Jetbot Jumble. I don’t remember details, but I think I figured out why it was happening, though it still meant I had to make some workaround.
Looking at my commit messages, I don’t think I have a version with the bug present, but I could look at the code tomorrow and maybe remember what exactly happened.
I looked at the code, but I can’t figure out what was my original approach that lead to the bug (if it even was the same issue). I played around with it a bit, but I couldn’t reproduce it.