コード例 #1
0
        void InitIK(Vector3 directionToPoint, bool opposite)
        {
            Vector3 relativeDirection = transform.InverseTransformDirection(directionToPoint);

            if (Mathf.Abs(relativeDirection.y) > 0.5f)
            {
                float targetAnim = 0;

                if (_targetState == ClimbState.onPoint)
                {
                    _ikLanding = ClimbIK.GetOppositeIK(_ikLanding);
                }
                else
                {
                    if (Mathf.Abs(relativeDirection.x) > 0)
                    {
                        if (relativeDirection.x < 0)
                        {
                            _ikLanding = AvatarIKGoal.LeftHand;
                        }
                        else
                        {
                            _ikLanding = AvatarIKGoal.RightHand;
                        }
                    }

                    targetAnim = _ikLanding == AvatarIKGoal.RightHand ? 1 : 0;
                    if (relativeDirection.y < 0)
                    {
                        targetAnim = _ikLanding == AvatarIKGoal.RightHand ? 0 : 1;
                    }

                    _anim.SetFloat("Movement", targetAnim);
                }
            }
            else
            {
                _ikLanding = relativeDirection.x < 0 ? AvatarIKGoal.LeftHand : AvatarIKGoal.RightHand;
                if (opposite)
                {
                    _ikLanding = ClimbIK.GetOppositeIK(_ikLanding);
                }
            }

            _ikT = 0;
            UpdateIKTarget(0, _ikLanding, _targetPoint);

            _ikFollowing = ClimbIK.GetOppositeLimb(_ikLanding);
            _fikT        = 0;
            UpdateIKTarget(1, _ikFollowing, _targetPoint);
        }
コード例 #2
0
        void InitIKDirect(Vector3 directionToPoint)
        {
            var delayedSide = AvatarIKGoal.LeftHand;

            if (directionToPoint.x < 0)
            {
                delayedSide = AvatarIKGoal.RightHand;
            }
            var instantSide = ClimbIK.GetOppositeIK(delayedSide);

            _ik.UpdateAllPointsOnOne(_targetPoint);


            _ik.UpdateTargetPosition(instantSide, _targetPoint.GetIK(instantSide).target.transform.position);
            _ik.UpdateTargetPosition(ClimbIK.GetOppositeLimb(instantSide), _targetPoint.GetIK(ClimbIK.GetOppositeLimb(instantSide)).target.transform.position);
        }