Open lowagner opened 6 months ago
It should be impossible (maybe the files were just duplicated outside the editor?) but somehow your static box and magic box have ended up with the same UID.
Easiest way to fix this is to create a new scene, copy paste the contents of static box into it, and then replace all references to the original throughout the project.
Depending on... stuff, sometimes the godot uses the res path, sometimes the UID. This is why the error is so inconsistent. This is a bug though, I think. There should be some sort of check to make sure UIDs are actually unique when processing resources.
Indeed, this looks like you probably copied the file manually at some point, which isn't safe, you need to fix this by removing the uid from the invalid source file
This shouldn't happen when you copy or duplicate resources in the editor, if it does happen that part is a bug, but handling users manually adding files with already used UIDs is complicated and will naturally break things
nope, never edited the tscn manually (except to revert the automatic changes which deleted the MagicBox import and converted everyone to StaticBox import via git reset --hard HEAD && rm -r .godot
). this is probably a bug in the loading logic. is there a way to debug how the tscns are loaded?
Didn't mean you edited it manually, did you create the two different resources by copying one manually? Or did you duplicate them using the editor?
some of the StaticBoxes are duplicates of each other, but i'm pretty sure i added the MagicBox via Ctrl+Shift+A. either way, i can consistently repro the issue on my side if i try to add another MagicBox to the TestScene. are you able to repro at all?
Can yo repo it by duplicating a scene in the editor?
I don't have an MRP to repo from so I haven't tested, your project is not minimal, so I'd suggest trying to reproduce this in a new project and uploading it here
i'd prefer to make sure it's not something in my configuration before i invest in making a MRP. the project isn't that big right now so it'd be a great help to know it's not just my machine if you'd be willing to try.
i may have duplicated the scene via the editor (e.g., in the FileSystem inspector). but why would that break things when it is distinct now?
If you make an MRP and it works then that's a sign it is in your configuration, but without doing that you're essentially asking people to debug your project, rather than testing engine issues, so it'd be very appreciated if you put in the work to test it as you have the material to do so
Duplicating from the editor should work without causing these problems, it's been fixed in the past, that's why it sounds like you copy-pasted it outside the editor, therefore causing this, so just checking a simple project would be simple here, create a scene, and duplicate it, and look at the UID of both files, if they match that's a bug in the engine
ah i think see the problem. duplicating the scene gave the same UID to both packed scenes. i'll go in and edit them to be different. they both had the same internal structure, however, which is maybe why they hashed to the same value.
i don't think i copy-pasted from outside the editor but can test.
ah i think see the problem. duplicating the scene gave the same UID to both packed scenes.
Indeed, but that was fixed before, so I unless it's popped back up it probably isn't the cause, it will however happen if you copy-paste the resources, so if you can confirm it happens specifically when doing copying or duplicating in the editor then that'd be a good hint, but that was supposed to be fixed before 4.2 AFAIK
ok that probably was the cause (copy-pasting the file outside of Godot). i deleted the magic-box.tscn file and duplicated it via the editor instead of by hand, and now it's working fine.
do we have any proposals to notice when a newly loaded file has the same UID as another one? this would have prevented some headache/confusion here.
Thank you for confirming! This might be tracked in a different issue report, but this one will do for now if there isn't another one already, it's not so much a new proposed feature as it's a more robust system to handle cases like this, so it belongs here on the issue tracker
The problem is that it's not entirely clear how to handle it generally
Now if you do copy a file there's an original around and you can pick what file to connect the UID to, but what if you copy it and rename the original? Which should be used now? Etc., so the specific solution is a bit complicated
i think it'd be nice to just notice that the UID is the same, warn at this point (e.g., "Warning: file magic-box.tscn has the same UID as static-box.tscn"). for people who are manually changing files that's probably enough to cue them on to the problem and that they need to update the UID in one and then update its references everywhere.
we don't necessarily need a full solution if this can't happen via the editor alone.
Tested versions
i've reproduced in 4.2.2 and 4.2.1 and 4.2 stable
System information
Godot v4.2.2.stable - Pop!_OS 22.04 LTS - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3050 Laptop GPU () - 13th Gen Intel(R) Core(TM) i9-13900H (20 Threads)
Issue description
i've created a PackedScene with different PackedScenes inside, but the packed scenes don't retain their packed scene type when running the game. they will convert into one or the other when running the game.
Steps to reproduce
starting with https://github.com/lowagner/triangle/commit/5ee6351fbadedfec994f52531356dd6ba6a576e1 and loading the project in the godot4 subdirectory. opening the project is fine, if you go into the
Room
packed scene, it's an instance of TestRoom. inside the room are a bunch of boxes plus a "MagicBox" at the end.according to the editor, they are all the same type of PackedScene, a terrain/static-box.tscn scene (TerrainStaticBox class). however, i have created this test scene by creating a bunch of the TerrainStaticBox packed scenes, plus adding a MagicBox scene (from characters/magic-box/magic-box.tscn). it's saved at this point in the git versioning. you can see this if you look at the levels/test-room.tscn file, which has both MagicBox and TerrainStaticBox scenes loaded (e.g., inspect the commit above).
now's where it gets interesting/annoying. after opening up TestRoom in the editor, start the game. all the static boxes in the test room should remain static; the magic box should be a dynamic rigid body. HOWEVER, what actually happens is that everyone becomes either the MagicBox scene or the TerrainStaticBox scene. (if the former, since the magic box has rigidbody physics, everything will start dropping under the influence of gravity. if the latter, everything is static, including the magic box.) even without saving, you'll notice a
git diff
-- it removed the MagicBox external resource type and made everything a StaticBox type (even if everyone was acting as the MagicBox scene). if i clear my godot cache (rm -r .godot) and reload the project, then everything is static of course.you can also try to add another MagicBox to the TestRoom scene (Ctrl+Shift+A -> then add magic-box.tscn). it will look correct until you try running the game, at which point it will convert into a TerrainStaticBox.
it's clear that i don't want this behavior; i want the editor to know that the MagicBox is a different scene and shouldn't affect the other packed scenes, and similarly for TerrainStaticBox. here is an example git diff after running the game, even without changing anything in the editor. you need to open TestRoom in the editor before it will show this diff:
Minimal reproduction project (MRP)
N/A yet. i'll work on seeing if i can simplify https://github.com/lowagner/triangle/commit/5ee6351fbadedfec994f52531356dd6ba6a576e1 if this issue isn't already known.