Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question New input system touch (vector2) to collide with 3d objects

Discussion in 'Input System' started by RPereiraGoXplora, Nov 23, 2020.

  1. RPereiraGoXplora

    RPereiraGoXplora

    Joined:
    Dec 10, 2019
    Posts:
    11
    Hello Unity members,
    I'm having trouble to do the touch of a object with the new input system, before with the OnMouseDown in each object i could detect it, and by the name i could get the object that had the collision, but now what can i do with the new Input system?
     
  2. RPereiraGoXplora

    RPereiraGoXplora

    Joined:
    Dec 10, 2019
    Posts:
    11
    I'm using AR fundation too, and AR Camera, maybe it's that?
    On Android platform.

    var touchPosition = context.ReadValue<Vector2>();
    var world = Camera.main.ScreenToViewportPoint(touchPosition);
    Ray ray = Camera.main.ViewportPointToRay(world);
    RaycastHit raycastHit;
    if (Physics.Raycast(ray, out raycastHit))
    {
    Debug.LogError("I'm looking at " + raycastHit.transform.name);
    }