And the resources you are using in this scene are not corrupted? I can only ask you to double check if all the paths are correct. Worst case you can try to delete every file associated with this scene and create the scene again
I had the same problem, and finding your question helped me find a solution.
What seemed to cause this for me was renaming the scene. If I were to hazard a guess, the error was caused by Godot still remembering that the old name referenced the nodes in the scene, and being unable to properly reference the nodes in the freshly renamed scene. However, I haven’t looked at Godot’s backend and wouldn’t know where to look to verify this.
What fixed it was copying all the nodes in the scene and deleting the scene, then making a new scene and saving it with the same name as the deleted scene.
how this solution would look for you is
open “snake_body” scene
shift + left click the top and bottom nodes in the tree
ctrl+x (cmd+x on Mac)
delete the “snake_body” scene
create a new scene
select “paste from clipboard”
save new scene as “snake_body”
If there are any corruption issues with the original scene, this process should divorce the nodes from the corruption completely, and shouldn’t break any code that used preload("res://snake_body.tscn"). However, this will decouple the scene from any @export functions, so you’ll need to drag the scene back into any nodes that referenced it using that function.
If this doesn’t work for you, I’m happy to try debugging the issue further, it’s possible there are other ways to cause this error other than renaming scenes.
hold on, I opened the scene again today and now the new scene is also experiencing the same error. It was working fine last night. Seems my fix doesn’t work after all.
If this is a corruption error, it shouldn’t be affecting different scenes of the same name, so now I’m stumped on how to fix this.
Edit: instantiating the scene via the right-click menu in the file system works fine, and the scene has all the nodes it’s supposed to have. Instantiating the scene with preload("res://[scene].tscn").instantiate() does not work, and preload("res://[scene].tscn").can_instantiate() returns false. This seems like an issue with the preload() function, not the scene.
The issue might be a merge conflict caused by working on the project simultaneously on different machines. This happened to me by having the project open on laptop and desktop at the same time. Digging around, I found this reddit post, with instructions on how to change the .tscn-file with a text editor. The trick is correcting duplicate id’s of loading resources caused by the merge conflict.
hey, I just ran into this bug again, and it wasn’t caused by a merge conflict (I’m only using one pc and the fix for resolving merge conflicts did not work).
seems there may be a bug with preload(), I’ll provide my code below for an example:
extends Node
var card_52 = preload("res://Scenes/52_card.tscn")
var level_select = preload("res://Scenes/level_select.tscn")
signal s_load_card_52
signal s_load_level_select
func _ready() -> void:
s_load_card_52.connect(_load_52_card)
s_load_level_select.connect(_load_level_select)
func _load_52_card():
#this doesn't work
var i_card_52 = card_52.instantiate()
add_child(i_card_52)
func _load_level_select():
#this works
var i_level_select = level_select.instantiate()
add_child(i_level_select)
There is no difference in function between the working code and the non-working code, and the card_52 scene stopped loading unexpectedly after I made changes to an unrelated scene.
I fixed this using the fix Calador posted above. I don’t know why this works, but it seems like preload() is sometimes unable to load scenes, but load() loads them fine. I lack the c++ knowledge to dig into the code for both functions and figure out what’s causing this.
I think multiple problems might be causing the same or similar error message. About half the people with this issue seem to be experiencing merge conflicts, and the other half it’s preload() acting up out of nowhere.
I just found this answer and was like thanks bro that sounds like the solution.
Then I remembered: wait I had that problem before.
Then looked again and saw that it was actually my answer
I was having a similar issue, but even weirder if i run the instanciator as a standalone it works fine but when in my main scene I get the error. Load fixed it for good thanks !