[..] The game is a platformer 2D, and when you hit an enemy the death calls the ragdoll.Apply() and then the code add some Impulse considering the hit direction... In most cases everything is ok, but sometimes (and now more often) the ragdoll move too fast as if there is a lot of collision between the bones then the whole character deforms streching the mesh while the movement of the bones are fast in opposite directions.
If behaviour is as expected most of the time, it seems more like a general issue with Unity's physics (and physics settings) than with the collider and rigidbody setup. You might want to check out different Project Settings - Physics 2D
settings, which might stabilize your simulation. It could e.g. be beneficial to set Max Linear Correction
, Max Angular Correction
, Max Translation Speed
, Max Rotation Speed
to the lowest values that still permit normal gameplay. Increasing iteration counts also stabilizes the physics simulation, however comes at an additional performance overhead.
In general I'm afraid there is not much that can be done on the spine-unity runtime side which fixes this issue. On the ragdoll side of things, you might just want to try if creating thinner colliders would improve the situation of overlapping colliders resulting in stretching or explosion.
Usually such undesired quick stretching or explosion effects are caused by a situation where strong forces or high velocity lead to parts intersecting (penetrating) each other by a large amount, which are not allowed to do that and should be colliding instead. This can't really be avoided in a discrete stepped simulation, the problem is just if rigidbodies overlap too much. The resulting de-penetration correction forces or velocities then lead to such sudden unnatural movement when things are pushed back out. The situation then gets worse when more than two rigidbodies overlap and the simulation can't find a simple way to "untangle" everything, moving parts too far apart.
General solutions to such issues include increasing simulation iteration counts, which reduces penetration distances and thus lowers the de-penetration correction forces; reducing maximum de-penetration distances, angles or forces, or even writing a custom script to move a GameObject back to it's normal position (e.g. at the joint). The latter however should be performed with caution and is likely not recommended your case, in order to not cause follow-up issues.
This Spine-Unity runtime works with data exported from Spine Editor version: 3.8.xx
Package version: spine-unity-3.8-2020-06-08.unitypackage
Thanks for the additional info. Please note that you're not using the latest available 3.8 spine-unity package (which is from 2021-11-10).
While you could check if using the latest 3.8 spine-unity runtime package resolves your issue, it is rather unlikely to help, unless the initial rigidbody angle limits are wrong (which was resolved in a bugfix for newer Unity versions). As always, be sure to backup your project before performing any updates.