Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Why is it elegant when moving models

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

  1. JeadongAAA


    Aug 11, 2017
    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