#Scene is corrupted only when a script is attached to the scene

6 messages · Page 1 of 1 (latest)

pearl geyser
#

I re-organized some nodes in my main scene (I created a new root node by shuffling around nodes manually). The game still ran after that.

This is the 'reshuffle' I'm describing that I did that is the precursor to my woes:

# initially:

Top2DNode/
└── Grunt

# after change:

TopControlNode/
└── Top2DNode
    └── Grunt

So I then closed and re-opened the project, and on load, I am told the grunt.tscn is corrupted.

The error:

  scene/resources/resource_format_text.cpp:284 - 
res://scenes/grunt.tscn:225 - Parse Error: 
  Failed loading resource: res://scenes/grunt.tscn. Make sure resources have been imported by opening the project in the editor at least once.

That's not much to go on, except the line number 225:

So the scene error is on this line:

[ext_resource type="Script" path="res://scripts/grunt.gd" id="1_q4egi"]

...

[node name="Grunt" type="CharacterBody2D"]
scale = Vector2(2, 2)
collision_layer = 2
collision_mask = 2
script = ExtResource("1_q4egi")     < THIS LINE IS #225

You would ask then, does the file res://scripts/grunt.gd exist? It does!

Let me explain some further debugging:

So I comment out the script = ExtResource("1_q4egi") , and at least the project loads again.

Then I add back the script manually, re-run the game; the script runs like it should. Everything seems fine.

... But then I reload the project, and boom, the grunt.tscn is corrupt again, and for the same reason.

So this issue is reproducible; attach a script to this scene, and the project will not reload successfully.

Does anyone have a suggestion here for me to try?

#

Actually, there is something that's the biggest clue, and it's of course in the error that I shared above.

Make sure resources have been imported by opening the project in the editor at least once.

I'll search more on this. I don't understand the error in this case, but it's the main lead.

pearl geyser
#

So, I went into the world 'just trying things'.

Ultimately I'm working again, as long as I don't use the actual script file that was causing the issue.

So I literally copied the script file that I've been using for my 'grunt' scene to a new file called stupid-temp.gd, and attached that to my scene instead. Now it's working.

I search the entire project for any instances of grunt.gd (the 'cursed' script filename), but it's not in use anywhere. I really expected to find it accidentally in use somewhere, creating a circular dependency or something. Nope.

shrug

#

Scene is corrupted only when a script is attached to the scene

unkempt vine
#

I've had weird things like this happen as well. It seems like Godot doesn't correctly update scenes and scripts and their paths, leading to corrupt scenes and files. This has been an issue for a while idk why nobody has fixed it yet.

#

Maybe report the bug on the godot repo if you feel like bothering