Answer the question
In order to leave comments, you need to log in
Moving an object with hold & drag?
Good day, help me cope with one task, how to move a 3D object along the x axis by holding and dragging with a finger on the screen or with the mouse?
Sorry for not being able to formulate the question correctly!
Answer the question
In order to leave comments, you need to log in
Assign a collider to an object and:
void OnMouseDrag() {
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition) ;
mousePos.y = 0f; // только по Х
transform.position = mousePos ;
}
For the drag, we catch it with the TouchPhase.Moved phase. And also set the coordinate. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question