appsinacup / godot-softbody2d

Godot SoftBody2D - Plugin that adds deformable 2D soft body.
MIT License
257 stars 13 forks source link

Error while loading from nested scenes. bones array is empty. #5

Closed nelsonayamashita closed 9 months ago

nelsonayamashita commented 1 year ago

Maybe related to godotengine/godot#73247 and #3.

Steps to reproduce:

A Out of bounds get index '0' (on base: 'Array[Node]') error will appear, saying that the line with

softbodyrb.bone = bones.filter(func(bone): return bone.name == child.name)[0]

Caused the error, which is strange, since in the debugger the bones array appears to be populated...

My current workaround is to delete the World scene from the Main scene and add a script to the Main scene that adds the World scene via code:

extends Control

var path_to_level := preload("res://world.tscn")

func _ready() -> void:
    var next_level = path_to_level.instantiate()
    add_child(next_level)

I believe this is related to the way Godot is having problems with how bones are being cached and loading them, so I don't think this can be easily fixed within the plugin. But the workaround might help someone also facing the problem.

Minimal reproduction project

Soft-Body-Issue.zip

Steps to reproduce the issue in the MRP

Ughuuu commented 1 year ago

Hm, sorry for late respond. I'm checking it now, but it does seem weird error, at least I never saw it happen.

Also, can't seem to download ur minimal reproduction project.

nelsonayamashita commented 1 year ago

Hey, no problem! Thanks for checking the issue. I've re-uploaded the file in the OP, let me know if it's working now.

Ughuuu commented 1 year ago

Seems to be the plugin tries to recreate the softbody even if there aren't any changes in it. Will try to fix so it doesn't happen(eg. add a dirty state if there is such a thing).

Ughuuu commented 9 months ago

Seems to no longer occur in 4.3