My ragdoll works very good at first time. Firstly i change spine skin and apply ragdoll everthing works perfectly. After that my character come to live (Remove ragdoll and SetBonesToSetupPose applied). Everthing is okay. If my character again fall to Ragdoll character exploded. I added ScreenShot below :
First time :
Second time :
SkeletonRagdoll2D with differen skin problem
Please check out the example scene Spine Examples/Other Examples/SkeletonUtility Ragdoll
. This scene shows how you can switch to and from a ragdoll multiple times.
This scene does not contain skin switching @Harald . I know this scene but it cant help us. With one skin everything is fine but when i change skin this issue comes up
@fshakhverdiyev Thanks for the additional info. It's still hard to help based on the limited information above though.
What is the exact code that you use to switch skins and enable/disable ragdolls that leads to your issue?
What does your skin setup look like before and after the problematic switching?
Do you have skin-bones which are present in one skin and not present in another?
What does your bone hierarchy look like in Spine at the problematic skin, and how does the respective SkeletonUtilityBone
hierarchy look like in the Unity Hierarchy window?
Harald Sorry for late response. We have many issues.
public static void ChangeSkin(SkeletonAnimation skeletonAnimation, Skin newSkin)
This is Skin change code part. I just call this method change my skin to another one after call skeletonRagdoll.Apply(). Everything is good at firstTime but second.....
{
Skeleton skeleton = skeletonAnimation.skeleton;
skeleton.SetSkin(newSkin);
skeleton.SetSlotsToSetupPose();
skeletonAnimation.state.Apply(skeleton);
}
This situation happened on only skin change procedure.
` public void Die(Vector2 damageComeFrom)
{
SlowMotionManager.Instance.ResetSlowMotion();
isTriggered = false;
SkeletonSkinUtil.ChangeSkin(skeletonAnimation, _skeletonAnimation.skeleton.Data.FindSkin("Exploded"));
_skeletonRagdoll2D.Apply();
_capsuleCollider2D.enabled = false;
_rigidbody2D.velocity = Vector2.zero;
_rigidbody2D.angularVelocity = 0;
enabled = false;
}
public void OnRestart()
{
enabled = true;
if (_skeletonRagdoll2D.IsActive)
{
_skeletonRagdoll2D.Remove();
}
_skeletonAnimation.ClearState();
SkeletonSkinUtil.ChangeSkin(_skeletonAnimation, _skeletonAnimation.skeleton.Data.FindSkin("Normal"));
_skeletonAnimation.skeleton.SetBonesToSetupPose();
transform.position = _wakeUpPosition;
_isTriggered = false;
_rigidbody2D.isKinematic = false;
_rigidbody2D.velocity = Vector2.zero;
_capsuleCollider2D.enabled = true;
_isJumped = false;
_skeletonAnimation.state.SetAnimation(0, "Idle", true);
}`
Die method called when character die and after Restart called everthing go to start position. First time everthing works fine (Ragdoll functionality). But second time when Die called (After restart) character exploded
Harald And yes some skin-bones present in one skin and not present in another
fshakhverdiyev I just checked regarding skin bones, the SkeletonRagdoll2D
component should actually be able to add the rigidbody chains for disabled bones anyway, so this should not be the problem.
Could you perhaps create a minimal Unity project which still shows this issue? You can send it as a zip file to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context. Then we can have a look at it.
Harald Okay
Harald I think i can handle this problem. I realize some bones must not collide but it is collide with ground. One answer i need : If my bones on "Exploded" Skin (which bone only has on this skin. Called this bone BoneX) goes to somewhere and after that i Remove ragdoll and change skin to "Normal" is BoneX goes to default position ? If not how can i reset all bones on Exploded Skin ?
Any feedback ?
Harald kindly reminder. Help pls
@fshakhverdiyev Please note that bumping your thread to the top will make us reply last to yours, as we're replying by age. We will usually reply within a workday, no new posting will not be missed.
fshakhverdiyev One answer i need : If my bones on "Exploded" Skin (which bone only has on this skin. Called this bone BoneX) goes to somewhere and after that i Remove ragdoll and change skin to "Normal" is BoneX goes to default position ?
Bones do not change position back to the setup pose position by calling SkeletonRagdoll2D.Remove
, if that's what you're asking. They stay where they are. However, subsequently applying animations might set your bone positions again, depending on what bones your active animations actually key.
fshakhverdiyev If not how can i reset all bones on Exploded Skin ?
See skeletonAnimation.Skeleton.SetBonesToSetupPose()
. You may need to call skeletonAnimation.Update(0);
afterwards as documented here to immediately reflect your changes.
Harald Thanks a lot
Harald Sample project sent to contact@esotericsoftware.com this mail. skeletonAnimation.Skeleton.SetBonesToSetupPose(); skeletonAnimation.Update(0); this 2 line doesnt reset bone positions for Exploded Skin.
fshakhverdiyev Thank you for sending us your Unity project. However, the .zip file you sent us was very large (about 1 GB) and not minimal in content. Please note that you can delete any files other than “Assets,” “Packages,” and “ProjectSettings. The Library folder in particular tends to be huge.
By the way, I could not reproduce the same state you described with your Unity project. For more information, please see my reply to you by email with a video recording of my test results.
Misaki Okay. I will send again with video recording and new .zip
fshakhverdiyev Thank you for resubmitting your Unity project! I have confirmed that I can reproduce the problem as shown in the video you sent us with the latest project files. We will check the cause of the problem later and give you a detailed answer. We appreciate your patience.
@fshakhverdiyev Thanks for sending the reduced reproduction project.
To fix the issue you need to call skeletonAnimation.Update(0);
after skeleton.SetSkin()
when the call is followed by_skeletonRagdoll2D.Apply();
. This is necessary because the world transform values need to be updated before SkeletonRagdoll2D.Apply
, and they are only updated for active bones.
So to fix your code, modify it as follows:
private static void ChangeSkin(SkeletonAnimation skeletonAnimation, Skin newSkin, bool updateWorldTransforms = false)
{
Skeleton skeleton = skeletonAnimation.skeleton;
skeleton.SetSkin(newSkin);
skeleton.SetSlotsToSetupPose();
if (updateWorldTransforms)
skeletonAnimation.Update(0);
else
skeletonAnimation.state.Apply(skeleton);
}
...
if (_isEnable)
{
ChangeSkin(_skeletonAnimation, _skeletonAnimation.skeleton.Data.FindSkin(_skinName), true);
_skeletonRagdoll2D.Apply();
}
Harald Man thanks a lot! Issue fixed.
@fshakhverdiyev Glad it helped, thanks for getting back to us!