示例#1
0
        void HandleMount()
        {
            if (!initTransit)
            {
                initTransit          = true;
                isRootMovementEnbled = false;
                ikFollowSideReached  = false;
                ikLandSideReached    = false;
                _time          = 0;
                _startPosition = transform.position;
                _endPosition   = targetPosition + (targetPoint.climbPosition == ClimbPosition.climbing ? climbRootOffset : (hangRootOffset + modelTransform.forward * 0.15f)); //

                currentCurve = mountCurve;
                currentCurve.transform.rotation = targetPoint.transform.rotation;
                BezierPoint[] trailPoints = currentCurve.GetAnchorPoints();
                trailPoints[0].transform.position = _startPosition;
                trailPoints[trailPoints.Length - 1].transform.position = _endPosition;

                anim.SetFloat("GP_IsHang", targetPoint.climbPosition == ClimbPosition.climbing ? 0 : 1);
            }

            if (isRootMovementEnbled)
            {
                _time += Time.deltaTime * 2.5f;
            }

            // Snap to end to prevent undesirable boundary behavior
            if (_time >= 0.99f)
            {
                _time = 1;
                isRootMovementEnbled = false;
                waitToStartClimb     = false;
                lockInput            = false;
                initTransit          = false;
                ikLandSideReached    = false;
                climbState           = targetState;

                transitionHint.text = "";
                Neighbor n = currentClimbObjManager.GetNeighborForDirection(Vector3.up, currentPoint);
                if (n != null)
                {
                    transitionHint.text += "Press [W] to Climb Up\n";
                }

                n = currentClimbObjManager.GetNeighborForDirection(Vector3.down, currentPoint);
                if (n != null)
                {
                    transitionHint.text += "Press [S] to Climb Down\n";
                }
                else
                {
                    transitionHint.text += "Press [S] to Drop Down\n";
                }
            }

            //Debug.Log(_time);
            Vector3 onCurvePosition = currentCurve.GetPointAt(_time);

            transform.position = onCurvePosition;

            // IK application weight
            UpdateAllIKWeight(_time, a_mountCurve);

            HandleRotation();
        }