D
D
Dmitry Korolev2017-07-29 15:24:57
C++ / C#
Dmitry Korolev, 2017-07-29 15:24:57

How to drag an object across world space?

https://pastebin.com/Q3Em5rDj
here is the code where there is some kind of error in OnDrag
why the same coordinate is shown in the debug when calling

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pparma, 2017-08-02
@adressmoeistranici

Perhaps the problem is that when converting the mouse position to world coordinates, you do not specify z (becomes 0 by default). Accordingly, due to insufficient accuracy, the position in the log is written the same.
https://docs.unity3d.com/ScriptReference/Camera.Sc...
"The z position is in world units from the camera."
You have:
pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Input.mousePosition is a Vector2.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question