예제 #1
0
    private void HandleMoveTowardsBlock()
    {
        _blockFacePosition.y = transform.position.y;
        Vector3 playerToBlock = _blockFacePosition - transform.position;
        Vector3 dir           = playerToBlock.normalized;

        _playerController.MoveInDir(dir);

        if (Vector3.Distance(transform.position, _blockFacePosition) <= 0.1f)
        {
            // we have reached the block face, time to move it
            _isMovingTowardsBlock = false;
            Vector3 direction = _block.GetMoveDirection(_face);
            if (direction == Vector3.zero)
            {
                OnMoveBlockEnd();
                return;
            }


            LookAtBlock();
            _animator.SetTrigger("Pull Back");

            // player will translate with block
            _isMovingBlock = true;
            SetAsChildOfBlock();
        }
    }
예제 #2
0
    public void AttemptToInteractWith(BlockBehaviour block, BlockFace face)
    {
        Vector3 direction = block.GetMoveDirection(face);

        if (direction == Vector3.zero)
        {
            return;
        }

        _block = block;
        _face  = face;
        _playerController.SetMobility(false);
        _playerController.SetGravity(false);

        _isMovingTowardsBlock = true;
        _blockFacePosition    = block.transform.position + face.GetNormal() * (0.5f + _playerController.GetBoxCollider().bounds.extents.z);
    }