Esempio n. 1
0
    public void SelectJewelleryPiece()
    {
        var mouseRay = GenerateMouseRay();

        if (Physics.Raycast(mouseRay.origin, mouseRay.direction, out var hit))
        {
            if (hit.transform.CompareTag(_selectableTag))
            {
                Vibration.VibratePop();
                _gObj            = hit.transform.gameObject;
                _objectBehaviour = _gObj.GetComponent <ObjectBehaviour>();
                _objectBehaviour.EnableBehaviour();

                var planePos = new Vector3(_gObj.transform.position.x, _gObj.transform.position.y + .3f, _gObj.transform.position.z);
                _plane = new Plane(Camera.main.transform.forward * -1f, planePos);

                var mRay = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                _plane.Raycast(mRay, out var rayDistance);
                _offset = _gObj.transform.position + new Vector3(0, 0f, 0.2f) - mRay.GetPoint(rayDistance);
            }
        }
    }