• Godot Help
  • Corrupt scene file, Condition "nc == 0" is true. Returning: nullptr

I'm trying to fix this scene file that got corrupted when importing my project to 4.0.
When opening it it throws:

ERROR: Condition "nc == 0" is true. Returning: nullptr
at: SceneState::instantiate (scene\resources\packed_scene.cpp:92)

Can't seem to upload the file in question so here's the scene's code:

`
[gd_scene load_steps=12 format=2]

[ext_resource path="res://Assets/Icons/Magic Categories Icon.svg" type="Texture2D" id=1]
[ext_resource path="res://Assets/Icons/Icon Bitmap.png" type="BitMap" id=2]
[ext_resource path="res://Menus/Interaction UI/Interaction UI Button.gd" type="Script" id=3]
[ext_resource path="res://Menus/Interaction UI/Interaction UI Icon.gd" type="Script" id=4]
[ext_resource path="res://Assets/Icons/Action Bar Card Fragments/fragment center.svg" type="Texture2D" id=5]
[ext_resource path="res://Assets/Icons/Status Icons/Health.svg" type="Texture2D" id=6]
[ext_resource path="res://Assets/Icons/Status Icons/Energy.svg" type="Texture2D" id=7]
[ext_resource path="res://Assets/Fonts/Isometros Large.tres" type="FontFile" id=8]
[ext_resource path="res://Assets/Icons/Status Icons/Time.svg" type="Texture2D" id=9]
[ext_resource path="res://Assets/Icons/Action Bar Card Fragments/cutout inverse.svg" type="Texture2D" id=10]

[sub_resource type="Animation" id=1]
resource_name = "Blink Highlight"
length = 0.9
step = 0.01
tracks/0/type = "bezier"
tracks/0/path = NodePath("Highlight:modulate:a")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PackedFloat32Array( 0.819608, -0.25, 0, 0.25, 0, 0.819608, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0.819608, -0.25, 0, 0.25, 0, 0.819608, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0.819608, -0.25, 0, 0.25, 0, 0.819608, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0.819608, -0.25, 0, 0.25, 0, 0.819608, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0.819608, -0.25, 0, 0.25, 0, 0.819608, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0 ),
"times": PackedFloat32Array( 0, 0.09, 0.1, 0.19, 0.2, 0.29, 0.3, 0.39, 0.4, 0.49, 0.5, 0.59, 0.6, 0.69, 0.7, 0.79, 0.8, 0.89, 0.9 )
}

[node name="Interaction UI Button" type="Node2D"]
script = ExtResource( 3 )

[node name="TextureButton" type="TextureButton" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -400.0
offset_top = -400.0
offset_right = 400.0
offset_bottom = 400.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2( 0.1, 0.1 )
pivot_offset = Vector2( 400, 400 )
texture_normal = ExtResource( 1 )
texture_click_mask = ExtResource( 2 )
script = ExtResource( 4 )
meta = {
"edit_use_anchors": false
}

[node name="Icon Mask" type="PointLight2D" parent="TextureButton"]
light_mask = 2
position = Vector2( 366.556, 363.437 )
texture = ExtResource( 10 )
mode = 3
range_item_cull_mask = 2
meta = {
"editor_description": "this is here so that icons are masked as the texture button fades in and out"
}

[node name="Highlight" type="Sprite2D" parent="TextureButton"]
modulate = Color( 1, 1, 1, 0 )
self_modulate = Color( 1, 0, 0, 1 )
show_behind_parent = true
position = Vector2( 400, 400 )
scale = Vector2( 1.1, 1.1 )
texture = ExtResource( 5 )

[node name="AnimationPlayer" type="AnimationPlayer" parent="TextureButton"]
"anims/Blink Highlight" = SubResource( 1 )

[node name="Time" type="Sprite2D" parent="TextureButton"]
show_behind_parent = true
light_mask = 2
position = Vector2( 400, 460 )
scale = Vector2( 0.7, 0.7 )
texture = ExtResource( 9 )

[node name="Label" type="Label" parent="TextureButton/Time"]
self_modulate = Color( 0, 0, 0, 1 )
offset_left = -48.2271
offset_top = -338.543
offset_right = 68.773
offset_bottom = -232.543
scale = Vector2( 8, 8 )
pivot_offset = Vector2( 58, 0 )
custom_fonts/font = ExtResource( 8 )
text = "9"
align = 1
valign = 1
meta = {
"edit_use_anchors": false
}

[node name="Energy" type="Sprite2D" parent="TextureButton"]
show_behind_parent = true
light_mask = 2
position = Vector2( 1517.82, 1158.82 )
scale = Vector2( 0.7, 0.7 )
texture = ExtResource( 7 )

[node name="Label" type="Label" parent="TextureButton/Energy"]
self_modulate = Color( 0, 0, 0, 1 )
offset_left = -48.0
offset_top = -83.0
offset_right = 69.0
offset_bottom = 23.0
scale = Vector2( 3, 3 )
pivot_offset = Vector2( 58, 0 )
custom_fonts/font = ExtResource( 8 )
text = "9999"
align = 1
meta = {
"edit_use_anchors": false
}

[node name="Health" type="Sprite2D" parent="TextureButton"]
show_behind_parent = true
light_mask = 2
position = Vector2( 1243.28, 397.898 )
scale = Vector2( 0.7, 0.7 )
texture = ExtResource( 6 )

[node name="Label" type="Label" parent="TextureButton/Health"]
self_modulate = Color( 0, 0, 0, 1 )
offset_left = -58.0
offset_top = -100.592
offset_right = 59.0
offset_bottom = 5.408
scale = Vector2( 3, 3 )
pivot_offset = Vector2( 58, 0 )
custom_fonts/font = ExtResource( 8 )
text = "9999"
align = 1
meta = {
"edit_use_anchors": false
}
[connection signal="mouse_entered" from="TextureButton" to="TextureButton" method="on_TextureButton_mouse_entered"]
[connection signal="mouse_exited" from="TextureButton" to="TextureButton" method="
on_TextureButton_mouse_exited"]
[connection signal="pressed" from="TextureButton" to="TextureButton" method="_on_TextureButton_pressed"]

`

  1. Are you trying to upgrade your existing project from Godot 3 to Godot 4?
  2. Do you have a backup / git versioning for the older project?
  3. Did you modify the scene code in manually? Or have it opened in an external text / ide editor?

    Vickylance

    1. Yes
    2. Yes
    3. I opened it but have not edited it as I do not know what to fix.

    I could try to isolate the scene and its dependencies to import it again, maybe it won't corrupt this scene with 4.1, but it would take less time to just create the scene again.

    12 days later

    I have the same error after upgrading to 4.1:
    scene/resources/packed_scene.cpp:92 - Condition "nc == 0" is true. Returning: nullptr

    I did upgrade from 4.0 but didn't try to open this scene in 4.0.
    Probably it has been broken after upgrade from 3.5 to 4.0.

    scene file content:

    [gd_scene load_steps=4 format=3 uid="uid://cbvsd6ky5mel6"]
    
    [ext_resource type="Script" path="res://scenes/settings.gd" id="1_mpgnx"]
    [ext_resource type="PackedScene" path="res://scenes/common/dialog.tscn" id="2_btk70"]
    [ext_resource type="PackedScene" uid="uid://c7gnfs5aymoro" path="res://scenes/common/ui_button.tscn" id="3_xl7jp"]
    
    [node name="settings" type="Node2D"]
    script = ExtResource("1_mpgnx")
    
    [node name="dialog_root" parent="." instance=ExtResource("2_btk70")]
    offset_left = 112.0
    offset_top = 89.0
    offset_right = 1155.0
    offset_bottom = 724.0
    
    [node name="GridContainer" type="GridContainer" parent="dialog_root"]
    layout_mode = 0
    offset_left = 35.0
    offset_top = 88.0
    offset_right = 983.0
    offset_bottom = 488.0
    columns = 2
    
    [node name="VSplitContainer" type="VSplitContainer" parent="dialog_root/GridContainer"]
    layout_mode = 2
    
    [node name="CheckButton" type="CheckButton" parent="dialog_root/GridContainer/VSplitContainer"]
    layout_mode = 2
    
    [node name="OptionButton" type="OptionButton" parent="dialog_root/GridContainer/VSplitContainer"]
    layout_mode = 2
    
    [node name="VSplitContainer2" type="VSplitContainer" parent="dialog_root/GridContainer"]
    layout_mode = 2
    
    [node name="ColorPickerButton" type="ColorPickerButton" parent="dialog_root/GridContainer/VSplitContainer2"]
    layout_mode = 2
    
    [node name="ButtonClose" parent="dialog_root" instance=ExtResource("3_xl7jp")]
    layout_mode = 2
    offset_left = 423.0
    offset_top = 524.0
    offset_right = 602.0
    offset_bottom = 601.0
    text = "OK"
    
    [connection signal="pressed" from="dialog_root/ButtonClose" to="." method="_on_button_close_pressed"]

    I don't have a solution, but I'm getting this same error on 2 scenes on one of my computers, but not the other. I have this file on GitHub and keep my files synced using it.

    a month later

    I'm getting the same error. It occurred when I moved a scene in my active scene editor from one folder into another folder. I had relatively recently upgraded from Godot 4.0 to 4.1, and also had been making changes to the folder structure from my computer's file explorer, which also had led to issues, though I'm not sure if either of those things are related.

    It happens. Take a look inside your .tscn file and make sure all paths and names are correct. If you know what files you moved around this should be fairly obvious.

    2 months later

    I'm having the same problem with a scene identical to other that it's working fine but with a different name. I checked the data inside the .tscn file and it's the same as when it was working before. But every time I try to open it, it says the file may be corrupt. I also get this output:

    scene/resources/packed_scene.cpp:92 - Condition "nc == 0" is true. Returning: nullptr

    • Toxe replied to this.

      Godoten I you haven't try the newest Godot version (4.2) and deleting your .godot directory.

      2 months later

      FIX - For me removing the scene from the tree and reinstantiating it the tree (also reloading the project for good measure) worked

      The cause was having the scene already in the tree while changing the packaging directions in the original scene.