- must assign a value other than 0 “mp.z” in the below code, before translating to world space.
I swear I’ve never had this issue before, but suddently using “ScreenToWorldPoint” will only give me the camera’s transform point…extremely confusing/frustrating. I must be doing something different…?
Here is script I created to test it:
var testBox : Transform;
var mp : Vector3;
var mwp : Vector3;
function Update ()
{
mp = Input.mousePosition;
mwp = camera.ScreenToWorldPoint(mp);
testBox.position = mwp;;
}
When I hit play, and watch “mwp” in the inspector, it jumps right to the camera’s Vector3 position, and of course so does the “testBox”. I’ve tried moving the camera up and down just for giggles, and sure enough, the box moves right with it.
Am I making some sort of “doh!” mistake…I genuinely can’t find it. Something so simple, that has always worked for me before- no longer any good.
One thing, it DOES work just fine from an orthographic camera…again, I swear that didn’t used to be the case. ![]()