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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Why is it elegant when moving models

Discussion in 'AR' started by JeadongAAA, Oct 9, 2017.

  1. JeadongAAA

    JeadongAAA

    Joined:
    Aug 11, 2017
    Posts:
    2
    This is how I move the model

    void OnMouseDown()
    {
    distance = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y,Camera.main.WorldToScreenPoint(transform.position).z)) - transform.position;
    }

    void OnMouseDrag()
    {
    Vector3 distance_to_screen = Camera.main.WorldToScreenPoint(transform.position);
    Vector3 pos_move = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance_to_screen.z ));
    transform.position = new Vector3( pos_move.x - distance.x , transform.position.y, pos_move.z -distance.z );

    }


    In the scenario the moving model will float and why is that