Beispiel #1
0
    private IEnumerator Co_StandEdge()
    {
        Vector3 finalPos = GetProjectedVector() + edgePosition + PlayerUtils.GetEdgeOffsetOnLocalSpace(edgeGameObject, edgeCompletedOffset);

        transform.position = finalPos;
        yield return(new WaitForEndOfFrame());

        standing = false;
        onEdge   = false;
        Destroy(standRb);
        characterController.enabled = true;
        SetState(new MoveState(this));
    }
Beispiel #2
0
    private IEnumerator Co_WaistStand()
    {
        StandDeactivatePlayer();
        Vector3 finalPos = GetProjectedVector() + edgePosition + PlayerUtils.GetEdgeOffsetOnLocalSpace(edgeGameObject, edgeCompletedOffset);

        while (Vector3.Distance(transform.position, finalPos) > 0.2f)
        {
            Debug.Log(Vector3.Distance(transform.position, finalPos));
            Vector3 lerpVector = Vector3.Lerp(transform.position, finalPos, lerpVelocity * 0.2f);
            transform.position = lerpVector;
            yield return(null);
        }

        standing = false;
        onEdge   = false;
        Destroy(standRb);
        characterController.enabled = true;
        SetState(new MoveState(this));
    }
Beispiel #3
0
    public override void Update()
    {
        if (_controller.standing || autoStand)
        {
            return;
        }

        //Puts player on grab position.
        //This will only be used on hang on edge.
        if (_controller.onEdge && !_controller.standing)
        {
            var     position   = _controller.transform.position;
            Vector3 moveVector = Vector3.zero;
            Vector3 lVector    = Vector3.Lerp(position, _controller.edgePosition + _projectedVector + PlayerUtils.GetEdgeOffsetOnLocalSpace(_controller.edgeGameObject, _controller.edgeOffset), _controller.lerpVelocity);

            moveVector = lVector - position;

            if (_controller.characterController.enabled)
            {
                _controller.characterController.Move(moveVector);
            }
        }

        if (PlayerUtils.InputEqualVector(-_controller.edgeGameObject.transform.forward, _controller.cameraTransform, _controller.movementVector) && !_controller.standing || _controller.inputToStand && !_controller.standing)
        {
            _controller.animator.SetTrigger("Climb");
            _controller.StandDeactivatePlayer();
        }
        if (PlayerUtils.InputEqualVector(_controller.edgeGameObject.transform.forward, _controller.cameraTransform, _controller.movementVector) && !_controller.standing)
        {
            _controller.onEdge        = false;
            _controller.edgeAvailable = false;
            ExitState();
        }
    }