Ejemplo n.º 1
0
    private IEnumerator TakeOff(JointPlacingHelper.LadderState ladderState)
    {
        Transform goalTransform = null;

        print("take off called::::" + ladderState.ToString());
        switch (ladderState)
        {
        case JointPlacingHelper.LadderState.DownLadder:
            goalTransform = _climbingLadder.LadderStart;
            break;

        case JointPlacingHelper.LadderState.UpLadder:
            goalTransform = _climbingLadder.LadderEnding;
            break;
        }

        float timer = 0;

        while (timer < _takeOffTime)
        {
            timer += Time.deltaTime;
            JointPlacing.BodyGoal.position = Vector3.MoveTowards(JointPlacing.BodyGoal.position, goalTransform.position, _moveJointSpeed);

            JointPlacing.IkWeight = Mathf.Lerp(JointPlacing.IkWeight, 0, 0.05f);
            print("moving to ladder ending position");
            yield return(new WaitForEndOfFrame());
        }
        FinishClimbing();
    }
Ejemplo n.º 2
0
    private IEnumerator ClimbLerp(bool up)
    {
        _canMove = false;
        print("climb lerp called");
        float timer1 = 0;
        float timer2 = 0;
        float timer3 = 0;

        JointPlacingHelper.LadderState climbState = JointPlacing.UpdateIndex(up, _climbingLadder);
        if (climbState != JointPlacingHelper.LadderState.OnLadder)
        {
            StartCoroutine(TakeOff(climbState));
            yield break;
        }


        while (timer1 < _stateTime)
        {
            timer1 += Time.deltaTime;
            print(timer1);
            yield return(new WaitForEndOfFrame());

            JointPlacing.RightHandGoal.position = Vector3.MoveTowards(
                JointPlacing.RightHandGoal.position,
                new Vector3(_climbingLadder.RightSide.position.x,
                            _climbingLadder.Rungs[JointPlacing.RightHandIndex].position.y,
                            _climbingLadder.Rungs[JointPlacing.RightHandIndex].position.z),
                _moveJointSpeed);

            JointPlacing.RightFootGoal.position = Vector3.MoveTowards(
                JointPlacing.RightFootGoal.position,
                new Vector3(_climbingLadder.RightSide.position.x,
                            _climbingLadder.Rungs[JointPlacing.RightFootIndex].position.y,
                            _climbingLadder.Rungs[JointPlacing.RightFootIndex].position.z),
                _moveJointSpeed);
        }
        while (timer2 < _stateTime)
        {
            print(timer2);
            timer2 += Time.deltaTime;
            yield return(new WaitForEndOfFrame());

            JointPlacing.BodyGoal.position = Vector3.MoveTowards(
                JointPlacing.BodyGoal.position,
                _climbingLadder.Rungs[JointPlacing.BodyIndex].position +
                ((transform.position.z - _climbingLadder.transform.position.z) /
                 Mathf.Abs((transform.position.z - _climbingLadder.transform.position.z))) * _distanceFromLadder,
                _moveJointSpeed);
        }
        while (timer3 < _stateTime)
        {
            print(timer3);
            timer3 += Time.deltaTime;
            yield return(new WaitForEndOfFrame());

            JointPlacing.LeftHandGoal.position = Vector3.MoveTowards(
                JointPlacing.LeftHandGoal.position,
                new Vector3(_climbingLadder.LeftSide.position.x,
                            _climbingLadder.Rungs[JointPlacing.LeftHandIndex].position.y,
                            _climbingLadder.Rungs[JointPlacing.LeftHandIndex].position.z),
                _moveJointSpeed);

            JointPlacing.LeftFootGoal.position = Vector3.MoveTowards(
                JointPlacing.LeftFootGoal.position,
                new Vector3(_climbingLadder.LeftSide.position.x,
                            _climbingLadder.Rungs[JointPlacing.LeftFootIndex].position.y,
                            _climbingLadder.Rungs[JointPlacing.LeftFootIndex].position.z),
                _moveJointSpeed);
        }



        _canMove = true;
    }