0
Not a Bug

possible bug in ScreenToWorldPoint.

jaybdemented 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 3

Maybe I did something wrong but no matter the mouse position ScreenToWorldPoint just returns the cameras position.  I'm trying to setup a drag and drop system.  This section is in the update.
Bolt Version:
2.0.0a3
Unity Version:
2018.3.2f1
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
Bolt 2
+2

Nope!  This is by design of the ScreenToWorldPoint method, and it actually comes down to the z-value of the input position vector.  

See here:
https://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html

The z position is in world units from the camera.

By feeding Mouse Position directly in (notice that it has only X and Y populated), you're essentially asking for the transformed point "0 units away from the camera", which will of course return the camera position.  You need to calculate the distance to your target plane and feed that into the input vector and you should get the transformed vector you're expecting.

+2

Your right, just adjusted it based on what you said and now it works.  I learned something new today.