Feel  5.1
The best way to improve your game's feel and make it extra juicy
MoreMountains.Tools.MMRagdoller Class Reference

Use this class to pilot a ragdoll on a character that is usually driven by an animator and have it fall elegantly If you have parts of your ragdoll that you don't want to be affected by this script (a weapon for example), just add a MMRagdollerIgnore component to them More...

Inheritance diagram for MoreMountains.Tools.MMRagdoller:

Public Types

enum  RagdollStates { RagdollStates.Animated, RagdollStates.Ragdolling, RagdollStates.Blending }
 The possible states of the ragdoll : More...
 

Public Member Functions

virtual void ForceRigidbodiesToSleep ()
 Forces all rigidbodies in the ragdoll to sleep More...
 
Vector3 GetPosition ()
 Returns the current position of the ragdoll (technically the hips position) More...
 

Public Attributes

RagdollStates CurrentState = RagdollStates.Animated
 the current state of the ragdoll More...
 
float RagdollToMecanimBlendDuration = 0.5f
 the duration in seconds it takes to blend from Ragdolling to Animated More...
 
Rigidbody MainRigidbody
 The rigidbody attached to the main body part of the ragdoll (usually the Pelvis) More...
 
bool ForceSleep = true
 if this is true, all rigidbodies will be forced to sleep every frame More...
 
bool AllowBlending = true
 whether or not blending will occur when going from ragdolling to animated More...
 

Protected Member Functions

virtual void Start ()
 On start we initialize our ragdoller More...
 
virtual void Initialization ()
 Grabs rigidbodies, adds body parts and stores the animator More...
 
virtual void RegisterAnimatorParameters ()
 Registers our animation parameters More...
 
virtual void SetIsKinematic (bool isKinematic)
 Sets all rigidbodies in the ragdoll to kinematic and stops them from detecting collisions (or the other way around) More...
 
virtual void LateUpdate ()
 On late update, we force our ragdoll elements to sleep and handle blending More...
 
virtual void HandleBlending ()
 Blends between ragdolling and animated and switches to Animated at the end More...
 
Vector3 GetRootPosition ()
 Returns the offset root position More...
 

Protected Attributes

float _mecanimToGetUpTransitionTime = 0.05f
 
float _ragdollingEndTimestamp = -float.MaxValue
 
Vector3 _ragdolledHipPosition
 
Vector3 _ragdolledHeadPosition
 
Vector3 _ragdolledFeetPosition
 
List< RagdollBodyPart_bodyparts = new List<RagdollBodyPart>()
 
Animator _animator
 
List< Component > _rigidbodiesTempList
 
Component[] _rigidbodies
 
HashSet< int > _animatorParameters
 
int _getUpFromBackAnimationParameter
 
int _getUpFromBellyAnimationParameter
 
bool _initialized = false
 

Static Protected Attributes

const string _getUpFromBackAnimationParameterName = "GetUpFromBack"
 
const string _getUpFromBellyAnimationParameterName = "GetUpFromBelly"
 

Properties

bool? Ragdolling [get, set]
 Use this to get the current state of the ragdoll or to set a new one More...
 

Detailed Description

Use this class to pilot a ragdoll on a character that is usually driven by an animator and have it fall elegantly If you have parts of your ragdoll that you don't want to be affected by this script (a weapon for example), just add a MMRagdollerIgnore component to them

Member Enumeration Documentation

◆ RagdollStates

The possible states of the ragdoll :

  • animated : driven by an animator controller, rigidbodies asleep
  • ragdolling : full ragdoll mode, purely physics driven
  • blending : transitioning between ragdolling and animated
Enumerator
Animated 
Ragdolling 
Blending 

Member Function Documentation

◆ ForceRigidbodiesToSleep()

virtual void MoreMountains.Tools.MMRagdoller.ForceRigidbodiesToSleep ( )
virtual

Forces all rigidbodies in the ragdoll to sleep

◆ GetPosition()

Vector3 MoreMountains.Tools.MMRagdoller.GetPosition ( )

Returns the current position of the ragdoll (technically the hips position)

Returns

◆ GetRootPosition()

Vector3 MoreMountains.Tools.MMRagdoller.GetRootPosition ( )
protected

Returns the offset root position

Returns

◆ HandleBlending()

virtual void MoreMountains.Tools.MMRagdoller.HandleBlending ( )
protectedvirtual

Blends between ragdolling and animated and switches to Animated at the end

◆ Initialization()

virtual void MoreMountains.Tools.MMRagdoller.Initialization ( )
protectedvirtual

Grabs rigidbodies, adds body parts and stores the animator

◆ LateUpdate()

virtual void MoreMountains.Tools.MMRagdoller.LateUpdate ( )
protectedvirtual

On late update, we force our ragdoll elements to sleep and handle blending

◆ RegisterAnimatorParameters()

virtual void MoreMountains.Tools.MMRagdoller.RegisterAnimatorParameters ( )
protectedvirtual

Registers our animation parameters

◆ SetIsKinematic()

virtual void MoreMountains.Tools.MMRagdoller.SetIsKinematic ( bool  isKinematic)
protectedvirtual

Sets all rigidbodies in the ragdoll to kinematic and stops them from detecting collisions (or the other way around)

Parameters
isKinematic

◆ Start()

virtual void MoreMountains.Tools.MMRagdoller.Start ( )
protectedvirtual

On start we initialize our ragdoller

Member Data Documentation

◆ _animator

Animator MoreMountains.Tools.MMRagdoller._animator
protected

◆ _animatorParameters

HashSet<int> MoreMountains.Tools.MMRagdoller._animatorParameters
protected

◆ _bodyparts

List<RagdollBodyPart> MoreMountains.Tools.MMRagdoller._bodyparts = new List<RagdollBodyPart>()
protected

◆ _getUpFromBackAnimationParameter

int MoreMountains.Tools.MMRagdoller._getUpFromBackAnimationParameter
protected

◆ _getUpFromBackAnimationParameterName

const string MoreMountains.Tools.MMRagdoller._getUpFromBackAnimationParameterName = "GetUpFromBack"
staticprotected

◆ _getUpFromBellyAnimationParameter

int MoreMountains.Tools.MMRagdoller._getUpFromBellyAnimationParameter
protected

◆ _getUpFromBellyAnimationParameterName

const string MoreMountains.Tools.MMRagdoller._getUpFromBellyAnimationParameterName = "GetUpFromBelly"
staticprotected

◆ _initialized

bool MoreMountains.Tools.MMRagdoller._initialized = false
protected

◆ _mecanimToGetUpTransitionTime

float MoreMountains.Tools.MMRagdoller._mecanimToGetUpTransitionTime = 0.05f
protected

◆ _ragdolledFeetPosition

Vector3 MoreMountains.Tools.MMRagdoller._ragdolledFeetPosition
protected

◆ _ragdolledHeadPosition

Vector3 MoreMountains.Tools.MMRagdoller._ragdolledHeadPosition
protected

◆ _ragdolledHipPosition

Vector3 MoreMountains.Tools.MMRagdoller._ragdolledHipPosition
protected

◆ _ragdollingEndTimestamp

float MoreMountains.Tools.MMRagdoller._ragdollingEndTimestamp = -float.MaxValue
protected

◆ _rigidbodies

Component [] MoreMountains.Tools.MMRagdoller._rigidbodies
protected

◆ _rigidbodiesTempList

List<Component> MoreMountains.Tools.MMRagdoller._rigidbodiesTempList
protected

◆ AllowBlending

bool MoreMountains.Tools.MMRagdoller.AllowBlending = true

whether or not blending will occur when going from ragdolling to animated

◆ CurrentState

RagdollStates MoreMountains.Tools.MMRagdoller.CurrentState = RagdollStates.Animated

the current state of the ragdoll

◆ ForceSleep

bool MoreMountains.Tools.MMRagdoller.ForceSleep = true

if this is true, all rigidbodies will be forced to sleep every frame

◆ MainRigidbody

Rigidbody MoreMountains.Tools.MMRagdoller.MainRigidbody

The rigidbody attached to the main body part of the ragdoll (usually the Pelvis)

◆ RagdollToMecanimBlendDuration

float MoreMountains.Tools.MMRagdoller.RagdollToMecanimBlendDuration = 0.5f

the duration in seconds it takes to blend from Ragdolling to Animated

Property Documentation

◆ Ragdolling

bool? MoreMountains.Tools.MMRagdoller.Ragdolling
getset

Use this to get the current state of the ragdoll or to set a new one


The documentation for this class was generated from the following file: