Beispiel #1
0
    public bool BeginPushing()
    {
        RaycastHit hit;

        if (Physics.Raycast(_thisTransform.position + Vector3.up * 0.5f, _forwardRelativeToCamera, out hit, _blockInteractionDistance, _blockLayer))
        {
            _block          = hit.collider.GetComponent <InteractableCube>();
            _blockRigidbody = hit.collider.GetComponent <Rigidbody>();
            _blockJoint     = hit.collider.GetComponent <FixedJoint>();

            _blockRigidbody.isKinematic = false;
            _blockNormal = hit.normal;

            Vector3 newGolemPos = _blockRigidbody.position + (_blockNormal * _distFromBlock);
            newGolemPos.y = _thisTransform.position.y;

            _thisTransform.position = newGolemPos;
            _thisTransform.rotation = Quaternion.LookRotation(-_blockNormal);

            _blockJoint.connectedBody = _rb;
            _block.SetIsInteractable(true);
            return(true);
        }

        return(false);
    }
Beispiel #2
0
 public void StopPushing()
 {
     _block.SetIsInteractable(false);
     _blockJoint.connectedBody   = null;
     _blockRigidbody.isKinematic = true;
     _block          = null;
     _blockRigidbody = null;
     _blockJoint     = null;
 }