コード例 #1
0
        /*
         *      call to start the ragdoll process
         */
        public void GoRagdoll(string reason)
        {
            if (!profile)
            {
                Debug.LogWarning("No Controller Profile on " + name);
                return;
            }
            if (!ragdoll)
            {
                Debug.LogWarning("No Ragdoll for " + name + " to control...");
                return;
            }

            if (state == RagdollControllerState.Falling || state == RagdollControllerState.Ragdolled)
            {
                return;
            }

            Debug.Log("went ragdoll for: " + reason);

            /*
             *      store start positions to begin calculating the velocity of the playing animation
             */
            StoreAnimationStartPositions();

            fallDecay = 1;

            //teleport the whole ragdoll to fit the master
            ragdoll.TeleportToTarget(Ragdoll.TeleportType.SecondaryNonPhysicsBones);

            //enable physics for ragdoll
            ragdoll.UseGravity(true);
            ragdoll.IgnoreSelfCollisions(false);

            //turn on ragdoll renderers, disable master renderers
            EnableRenderers(false, true);

            // master renderers are disabled, but animation needs to play regardless
            // so dont cull
            animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;

            //change the state
            ChangeRagdollState(RagdollControllerState.Falling);

            if (onGoRagdoll != null)
            {
                onGoRagdoll();
            }
        }
コード例 #2
0
        /*
         *      call to start the ragdoll process
         */
        public void GoRagdoll(string reason)
        {
            if (CheckForControllerError())
            {
                return;
            }



            if (state == RagdollControllerState.Falling || state == RagdollControllerState.Ragdolled)
            {
                return;
            }

            // Debug.LogError("Ragdoll:: " + reason);
            // Debug.Break();


            /*
             *      store start positions to begin calculating the velocity of the playing animation
             */
            StoreAnimationStartPositions();

            fallDecay = 1;

            //teleport the whole ragdoll to fit the master
            ragdoll.TeleportToTarget(Ragdoll.TeleportType.NonBones);

            //enable physics for ragdoll
            ragdoll.UseGravity(true);
            ragdoll.IgnoreSelfCollisions(false);

            //turn on ragdoll renderers, disable master renderers
            EnableRenderers(false, true);

            // master renderers are disabled, but animation needs to play regardless
            // so dont cull
            animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;

            //change the state
            ChangeRagdollState(RagdollControllerState.Falling);
        }