Unity + Niantic ARDK Aumeted Reality: Objects moving opposite to finger direction when camera is in front. need assistance drag and drop funcionality

Include the following details (edit as applicable):

  • Issue category: Lightship Maps / Semantic Segmentation / Multiplayer / Real-time Mapping-Depth / ARDK Documentation / Unity Example Package / Sample App aka ‘AR Voyage’ / ARDK Virtual Studio Tools / Developer Tools / Networking / VPS / Scanning Framework
  • Device type & OS version: Android / iOS / Other Ex. iPhone 8+ on iOS 13
  • Host machine & OS version: Windows /
  • Issue Environment : Unity Mock / On Device
  • ARDK version:
  • Unity version:2021.3.15f1

Description of the issue:

 Ray ray = Camera.main.ScreenPointToRay(touch.position);
    RaycastHit hit;

    if (Physics.Raycast(ray, out hit))
    {
        if (hit.collider.tag == "apple")
        {
            dragObject = hit.transform;
            distanceToCamera = dragObject.position.z - Camera.main.transform.position.z;
            relativePositionTouch = new Vector3(_touchPosition.x, _touchPosition.y, distanceToCamera);
            relativePositionTouch = Camera.main.ScreenToWorldPoint(relativePositionTouch);
            cameraToObjectOffset = dragObject.position - relativePositionTouch;
            isHeld = true;
            Debug.Log($"Esta es la fase del touch: {touch.phase}");
        }
    }
}

private void MovedObjet(Touch touch)
{
    Vector2 _touchPosition = touch.position;
    relativePositionTouch = new Vector3(_touchPosition.x, _touchPosition.y, distanceToCamera);
    relativePositionTouch = Camera.main.ScreenToWorldPoint(relativePositionTouch);
    dragObject.position = relativePositionTouch + cameraToObjectOffset;
}

Hey Sergio,

Can I get some more specific details about your project? How is the user supposed to be interacting and how is AR involved?

Additionally, please make sure that you’re using our API in order to get information on the camera feed for better accuracy, looking at the code that’s currently provided you’re only grabbing feed from the Unity camera itself but you also need to interface with some of our features to create an AR experience such as grabbing the current frame. If you’re unsure on how to do that, I would recommend checking out some of our tutorials: https://lightship.dev/docs/ardk/tutorials.html