Exemple #1
0
        // Unpin a specific muscle according to it's collision resistance, immunity and other values
        private void UnPinMuscle(int muscleIndex, float unpin)
        {
            // All the conditions to ignore this
            if (unpin <= 0f)
            {
                return;
            }
            if (puppetMaster.muscles[muscleIndex].state.immunity >= 1f)
            {
                return;
            }

            // Find the group properties
            BehaviourPuppet.MuscleProps props = GetProps(puppetMaster.muscles[muscleIndex].props.group);

            // Making the puppet more resistant to collisions while getting up
            float stateF = 1f;

            if (state == State.GetUp)
            {
                stateF = Mathf.Lerp(getUpCollisionResistanceMlp, 1f, puppetMaster.muscles[muscleIndex].state.pinWeightMlp);
            }

            // Applying collision resistance
            float cR     = collisionResistance.mode == Weight.Mode.Float? collisionResistance.floatValue: collisionResistance.GetValue(puppetMaster.muscles[muscleIndex].targetVelocity.magnitude);
            float damage = unpin / (props.collisionResistance * cR * stateF);

            damage *= 1f - puppetMaster.muscles[muscleIndex].state.immunity;

            // Finally apply the damage
            puppetMaster.muscles[muscleIndex].state.pinWeightMlp -= damage;
        }
		// Unpin a muscle and other muscles linked to it
		private void UnPin(int muscleIndex, float unpin) {
			BehaviourPuppet.MuscleProps props = GetProps(puppetMaster.muscles[muscleIndex].props.group);
			
			for (int i = 0; i < puppetMaster.muscles.Length; i++) {
				UnPinMuscle(i, unpin * GetFalloff(i, muscleIndex, props.unpinParents, props.unpinChildren, props.unpinGroup));
			}
		}
Exemple #3
0
        // Unpin a muscle and other muscles linked to it
        public void UnPin(int muscleIndex, float unpin)
        {
            if (muscleIndex >= puppetMaster.muscles.Length)
            {
                return;
            }

            BehaviourPuppet.MuscleProps props = GetProps(puppetMaster.muscles[muscleIndex].props.group);

            for (int i = 0; i < puppetMaster.muscles.Length; i++)
            {
                UnPinMuscle(i, unpin * GetFalloff(i, muscleIndex, props.unpinParents, props.unpinChildren, props.unpinGroup));
            }

            hasCollidedSinceGetUp = true;
        }