Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Drag object (Move, Scale, Rotate) on surface in ARCore

Discussion in 'ARCore' started by sweetan, Apr 23, 2018.

  1. sweetan

    sweetan

    Joined:
    Nov 21, 2017
    Posts:
    17
    Hi,
    I want to create an object draggable(Move, scale, rotate) on the surface.
    please help me.
    Thank you.
     
    robrtoprz likes this.
  2. syedimran199696

    syedimran199696

    Joined:
    Apr 4, 2018
    Posts:
    13
    Hello Sweetan,
    I prefer to watch this video on till end.


    Regards,
    Syed Imran SA
     
  3. darklift

    darklift

    Joined:
    Apr 11, 2016
    Posts:
    3
    Would love an example implementation of this as well. The video above doesn't have a drag functionality from what I am aware. Can't test the project either since it's outdated.

    For Resize and Rotate, the lean touch free asset found on the asset store seems to be working for me.
     
  4. saiakhil46

    saiakhil46

    Joined:
    Mar 17, 2018
    Posts:
    1
    I tried lean translate for dragging assert on the detected plane but assert was moving up and down but not on the detected plane. So, anyone helps me out of it
     
  5. blanx

    blanx

    Joined:
    Feb 26, 2016
    Posts:
    17
    Lean+ is great for moving objects on a plane.
     
  6. RoyDaipayan

    RoyDaipayan

    Joined:
    Jun 27, 2018
    Posts:
    1
    Any updates on the drag and drop functionality on the detected planes in ARCore
     
  7. VeerpalK

    VeerpalK

    Joined:
    Jul 4, 2018
    Posts:
    12
    i worked on Lean Touch and its working fine but For multiple objects its not working like if we move one objects second also moves .Any idea how to tackle it?
     
  8. robrtoprz

    robrtoprz

    Joined:
    May 15, 2017
    Posts:
    8
    @VeerpalK Hi, I think that this script will help you, only move the object that you're touching.
    Make sure that your object have the Layer "Surface" and a collider.
    It doesn't need Lean Touch.

    Code (CSharp):
    1. private bool holding;
    2.  
    3.     void Start()
    4.     {
    5.         holding = false;
    6.     }
    7.  
    8.     void Update()
    9.     {
    10.  
    11.         if (holding)
    12.         {
    13.             Move();
    14.         }
    15.  
    16.         // One finger
    17.         if (Input.touchCount == 1)
    18.         {
    19.          
    20.             // Tap on Object
    21.             if (Input.GetTouch(0).phase == TouchPhase.Began)
    22.             {
    23.                 Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
    24.                 RaycastHit hit;
    25.  
    26.                 if (Physics.Raycast(ray, out hit, 100f))
    27.                 {
    28.                     if (hit.transform == transform)
    29.                     {
    30.                         holding = true;
    31.                     }
    32.                 }
    33.             }
    34.  
    35.             // Release
    36.             if (Input.GetTouch(0).phase == TouchPhase.Ended)
    37.             {
    38.                 holding = false;
    39.             }
    40.         }
    41.     }
    42.  
    43.     void Move()
    44.     {
    45.         RaycastHit hit;
    46.         Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
    47.         // The GameObject this script attached should be on layer "Surface"
    48.         if (Physics.Raycast(ray, out hit, 30.0f, LayerMask.GetMask("Surface")))
    49.         {
    50.             transform.position = new Vector3(hit.point.x,
    51.                                              transform.position.y,
    52.                                              hit.point.z);
    53.         }
    54.     }
    55. }
     
  9. VeerpalK

    VeerpalK

    Joined:
    Jul 4, 2018
    Posts:
    12