animationgame-developmentreloadgodot4

Character fail to load differently everytime the scene is reloaded


Every time my character dies, the scene is full reloaded with reload_current_scene(). but anytime it is reloaded the player is loaded differently: -1st time it works perfectly -2nd time some animations are missing -3rd time some sprites change their position -4th time the main scene closes few seconds after being loaded.

Video showing the "issue": https://drive.google.com/file/d/10hVHOhppU2c4_BgBGz14poDamjhtL790/view?usp=sharing

I'm new to godot and I don't know where to start to look for a solution. Any guiadance will be appreciated.

I don't know where to start to look for a solution, there ios no error in the debugger. I change the way animations where played and now i'm using AnimationTree, but it didn't solve the problem.


Solution

  • Thanks to for the orientation Mr Bugfish! I investigate the issue and it seems to be a bug. The error was the one descrived here: https://github.com/godotengine/godot/issues/73168 And the workaround I use was the one commented by seffa1.

    Basicaly there is a problem reloading the Skeleton modifier stack after get_tree().reload_current_scene(). So the workaround for this is save the modifier stack resource, and reload it in the _ready(). I used this code:

    onready var modification_stack = preload("res://Player/player_skeleton_modification_stack.tres")
    func _ready():
        %Skeleton.set_modification_stack(modification_stack.duplicate())
        %Skeleton.get_modification_stack().enabled = true
    

    That's a simple workaround for the problem. Hope it'll be useful!