Joyetta
1
I’m using onMouseDown event to record the mouse position and OnMouseDrag event to change the position of the object which I selected. The following is the code,
void OnMouseDown() { screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position); offset = _trans.position - Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenPoint.z)); }
void OnMouseDrag() { Vector3 cursorPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z); Vector3 cursorPosition = Camera.main.ScreenToWorldPoint(cursorPoint) + offset; _trans.position = cursorPosition; }
========================================
It works fine with gameobject that create in unity, but not working with the .fbx/.3ds model in the scene. Can anybody know how to make it works for .fbx/.3ds model? Thanks in advance!
Joyetta
2
I know it. The fbx model needs a collider component.