public void HoldGrabObject(GameObject target)
    {
        _grabTarget = target;
        HoldableObjectContoller targetComponent = _grabTarget.GetComponent <HoldableObjectContoller>();

        if (!targetComponent.CheckHoldByPlayer())
        {
            Vector3 offset = transform.forward + transform.right * (_isLeftHand ? 1 : -1);
            offset = offset * 0.05f;

            targetComponent.HoldObject(_photonView.ViewID, offset);

            _isHandUsing = true;
        }
    }
Example #2
0
    private void OnTriggerStay(Collider other)
    {
        Transform colObject = other.transform;

        if (colObject.tag == "Ingredient" && !_ingredientList.Contains(colObject))
        {
            HoldableObjectContoller hoc = colObject.GetComponent <HoldableObjectContoller>();
            if (hoc.photonView.IsMine && !hoc.CheckHoldByPlayer())
            {
                other.attachedRigidbody.isKinematic = true;
                other.enabled = false;

                colObject.position = _currentPosition + _offsetVector * _ingredientList.Count;
                colObject.rotation = Quaternion.identity;
                colObject.Rotate(new Vector3(0, Random.Range(0f, 360f), 0));

                InteractObjectListsAdd(colObject);
                photonView.RPC("BroadcastInteractID", RpcTarget.Others, hoc.componentID);
            }
        }
    }