Open CentiGames opened 1 year ago
If anyone else encounters this problem, the workaround I am using in the meantime calls .queue_free()
on the Skeleton2D, then waits 2 physics frames await(get_tree().physics_frame)
before reloading the scene. Using this workaround the IK works after reloading.
Godot version: 4.0.1 I am using SkeletonBone2DTwoBoneIK modifier with the Skeleton2D bone rig, the bones which are modified turn yellow which ensures the influence of that modifier. However, when I reload the scene the bones turn white and the influence is disabled (in editor) while the property inspector remains unchanged. I am fixing it by deleting a modifier and undo it to restore the influence
Godot version: 4.1.3
Seeing the same problem. What I use to work around it is:
func _ready():
var mod_stack = $Skeleton2D.get_modification_stack()
var skl_mod = mod_stack.get_modification(0)
skl_mod.target_nodepath = skl_mod.target_nodepath
skl_mod.tip_nodepath = skl_mod.tip_nodepath #for SkeletonModification2DCCDIK
Seems that refreshing the nodepath helps clear whatever problem it's having.
This is what I do for all scenes that use the skeleton modification stack and it fixes this issue.
First, save your modification stack resource. To do that, click on your Skeleton Node, then in the inspector find 'Modification Stack', then click the down arrow -> Save As
Then use the code below to reload a fresh one to your skeleton when the scene starts. The fixes issues when switching to this scene after it has been loaded at least once (like when reloading a scene, or leaving it and coming back)
@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
I've only had this problem in the editor (I'm using the stack only to help record the animation, turn it off while running the game), and the solution was to save the stack as a resource, reset the stack and then load it in again. Reloading the project didn't help. (I am running 4.1.3 stable)
Godot version
v4.0.rc1.official
System information
Windows 10, GeForce RTX 3070 (Driver version 528.49), forward_plus rendering method
Issue description
When adding a SkeletonModification2DCCDIK modification to the Modification Stack, the inverse kinematics work as expected, however, when reloading the current scene (with
get_tree().reload_current_scene()
), the inverse kinematics of the CCIDK modification stops working and the skeleton only displays its rest pose.This video shows the behavior, at first its working, then I reload the scene and it stops working:
https://user-images.githubusercontent.com/105640257/218328590-cb4d3694-b7f5-42c2-9a14-8bb714a7945f.mp4
When reloading the scene, I also get the error message
"E 0:00:09:0835 _execute: Target node is not in the scene tree. Cannot execute modification!"
, so that might be the reason but I am not sure why the target node is not in the scene tree?Steps to reproduce
get_tree().reload_current_scene()
, the IK has stopped workingMinimal reproduction project
I created a small reproduction project, the mouse cursor moves the target position for the IK, pressing space bar (ui_accept) reloads the current scene, resulting in the SkeletonModification2DCCDIK not working anymore.
Skeleton2DReloadNotWorking.zip
I am also not sure if this is related, or has something to do with the CCDIK being experimental, or maybe I set something up incorrectly, but when starting the scene (for the first time) I get the following errors/warnings: