If it's a smaller collision, he'll stumble, which involves ragdolling, adding a 'bounce' force to his hips along with a bit of torque and some root rotation to turn him away from whatever he hit, and then the 'get up' function will be called automatically after about a tenth of a second.įor transitioning from ragdolled to animated (from a stumble or from input), his final position is based on his velocity at the hips as long as that velocity won't put him inside of another collider (so that if he's moving, the transition doesn't suddenly stop him in place). If he hits or is hit by something hard enough to be ragdolled, the animator is disabled, his limbs are switched from kinematic rigidbodies to regular ones, and velocity is added depending on the type of collision. For normal rigidbody collisions, I just used his velocity along with the collision information from the kinematic ragdoll colliders on his head, spine, hips, and limbs (it would definitely be possible to consolidate all of the collision detection, but I wanted to try to figure out how a few different methods could work). His velocity is calculated according to his change in position over time, and roughly the same calculation is applied to other kinematic rigidbodies within a few meters of him, which lets him move with things that he is standing on and collide appropriately if he gets too close. The character controller is written from scratch he can walk on non-flat terrain, fall with accurate gravity and drag, and collide with static objects appropriately, (based on how quickly he is moving, the collision angle, and whether the static object is level with his head, midsection, or legs). Finally, create a recipe to add the slot and add the recipe to the "Addition Recipes" section on the DynamicCharacterAvatar.So, I made a guy. Create a new slot and link the "Character Completed" event to the prefab's Definitions script and have it call the "OnSkeletonAvailable" function. Configure the parameters and add the Physics Elements to the elements list.
This is important so that the player collider isn't constantly colliding with the ragdoll colliders.Įlements: List of Physics Elements to add to the avatar for physics. PlayerLayer: The collision layer to set the player collider on.
RagdollLayer: The collision layer to set the colliders on. This is usefull if the gameobject will move around after it is done ragdolling, otherwise it will snap back to it's original position at the start of ragdolling.
#Spine2d ragdoll colliders update
UpdateTransformAfterRagdoll: Enabling this causes the gameobject's transform to update even during ragdoll. If using the physics component directly on the avatar (as opposed to being added by a recipe), then you will need the capsule collider and rigidbody added before runtime.ĮnableColliderTrigger: Enabling this will cause the ragdoll colliders to act as triggers while they are not in the ragdoll state. The system will update the collider and rigidbody then. SimplePlayerCollider: Turn this on if the avatar will be using a simple capsule and rigidbody for itself. Ragdolled: Property that enables or disables the physics for the ragdoll.