Esempio n. 1
0
        /// <summary>
        /// Custom On Scene GUI
        /// </summary>
        protected virtual void OnSceneGUI()
        {
            TPCharacter          _TPCharacter      = (TPCharacter)target;
            TPCInverseKinematics inverseKinematics = _TPCharacter.GetInverseKinematics();

            if (debugFootIK)
            {
                if (inverseKinematics.LeftFootPivot == null && inverseKinematics.RightFootPivot == null)
                {
                    return;
                }

                Handles.color = Color.black;
                Handles.DrawLine(inverseKinematics.LeftFootPivot.transform.position, inverseKinematics.LeftFootPivot.transform.position - Vector3.up * inverseKinematics.RayRange);
                Handles.DrawWireArc(inverseKinematics.LeftFootPivot.transform.position - Vector3.up * inverseKinematics.RayRange, Vector3.up, Vector3.forward, 360, 0.03f);
                Handles.color = new Color(0.25f, 0.25f, 0.25f, 0.1f);
                Handles.DrawSolidArc(inverseKinematics.LeftFootPivot.transform.position - Vector3.up * inverseKinematics.RayRange, Vector3.up, Vector3.forward, 360, 0.03f);

                Handles.color = Color.black;
                Handles.DrawLine(inverseKinematics.RightFootPivot.transform.position, inverseKinematics.RightFootPivot.transform.position - Vector3.up * inverseKinematics.RayRange);
                Handles.DrawWireArc(inverseKinematics.RightFootPivot.transform.position - Vector3.up * inverseKinematics.RayRange, Vector3.up, Vector3.forward, 360, 0.03f);
                Handles.color = new Color(0.25f, 0.25f, 0.25f, 0.1f);
                Handles.DrawSolidArc(inverseKinematics.RightFootPivot.transform.position - Vector3.up * inverseKinematics.RayRange, Vector3.up, Vector3.forward, 360, 0.03f);
            }

            if (debugUpperBodyIK)
            {
                Animator animator = _TPCharacter.GetComponent <Animator>();
                if (animator == null)
                {
                    return;
                }

                Transform head  = animator.GetBoneTransform(HumanBodyBones.Head);
                Transform spine = animator.GetBoneTransform(HumanBodyBones.Spine);

                Vector3 startPos = Extensions.CenterOfVectors(head.position, spine.position);

                if (inverseKinematics.LookTarget != null)
                {
                    Handles.color = Color.black;
                    Handles.DrawLine(startPos, inverseKinematics.LookTarget.position);
                }
            }
        }