Exemple #1
0
        void MoveBones(Vector3 target)
        {
            Vector3 temp = target;

            var basePos = (_bones[_bones.Count - 1].position);

            for (int i = 0; i < _bones.Count - 1; i++)
            {
                var result = IK.Reach(_bones[i].position, _bones[i + 1].position, temp);
                _bones[i].position = result[0];
                temp = result[1];
            }
            _bones[_bones.Count - 1].position = (temp);

            temp = (basePos);
            for (int i = _bones.Count - 1; i > 0; i--)
            {
                var result = IK.Reach(_bones[i].position, _bones[i - 1].position, temp);
                _bones[i].position = result[0];
                temp = result[1];
            }
            _bones[0].position = (temp);
            DrawLine();
        }