4ian / GDevelop

🎮 Open-source, cross-platform 2D/3D/multiplayer game engine designed for everyone.
https://gdevelop.io
Other
10.82k stars 848 forks source link

TileMap object action "Set the TileMap JSON File..." does not work #2271

Closed krunkster closed 3 years ago

krunkster commented 3 years ago

Describe the bug

Using the "Set the TileMap JSON File..." action on a TileMap after creating it does not actually update the tile map. The TileMap object will only seemingly use the TileMap JSON file that it was defined as in the scene.

To Reproduce

tilemap-set-map-bug.zip The attached reproduction has a tilemap object defined in the scene The events create an instance of that tile map at the begining of the scene When the scene is touched/clicked the TileMap object is updated to use a new JSON file But the TileMap object is NOT updated

I think this must be a bug, otherwise why would there be an action to modify this?

Other details

I'm really excited about using TileMaps, but it's going to be very inefficient if I have to create a specific TileMap object for every level I want to load. If you are interested you can see how I'm planning to use TileMaps here: https://forum.gdevelop-app.com/t/use-tilemaps-efficiently/30339

blurymind commented 3 years ago

Hmm interesting, this actually worked ok in the demo project I used when developing it 🤔 I will try to have a look tomorrow

blurymind commented 3 years ago

@4ian could this be because an instance of the tilemap is created using the event sheet at the start of the scene?

@krunkster what happens if the instance's json resources are loaded one second after the start of the scene? I bet its something to do with resource loading in GD. Can you try this with a timer?

4ian commented 3 years ago

could this be because an instance of the tilemap is created using the event sheet at the start of the scene?

No this is not related, objects are handled the same way.

If I open the example, put the TileMap on the scene, then change in its properties from level1.json to level2.json, it is also not working! The first tilemap is still shown. So there is a problem in the tilemap helpers I think.

See: image

But still the old tilemap: image

4ian commented 3 years ago

Found the issue @blurymind. It's here: https://github.com/4ian/GDevelop/blob/30aa5e78fd05b1f84979a2427955862914661ac8/Extensions/TileMap/pixi-tilemap-helper.js#L425-L435

Can you spot the error? It's about the id used to store the tilemap data in memory.

@krunkster thanks for the report, the minimal example game was very very useful! (we should ask one for every single bug like this :)). This was not happening if the tileset is integrated. Should be fixed soon and I'll release a version with the fix.

blurymind commented 3 years ago

Thanks @4ian I must have broken it along the way. Will try to pr a fix tonight if it hasnt been fixed already :) 👍

blurymind commented 3 years ago

lol, that was a pretty silly bug 😸 Fix here https://github.com/4ian/GDevelop/pull/2273

weird we didnt notice the regression in the demo project which has a test for that

krunkster commented 3 years ago

I really appreciate the fast fix on this! Since it's so new I'm still trying to figure out how to best leverage the feature efficiently, so I'm glad the map data is mutable on the object.