Screentoworldpoint Help

Using an orthographic camera set at 0,0,-10, I’m trying to set the position of an object to the bottom left of the screen on any device. I’m using

Vector3 newPos = Camera.main.ScreenToWorldPoint(new Vector3(0,0, 10));
gameObject.transform.position = newPos;

But the objects x & y are way off to the left of the screen. The newPos ends up being at -2.1, -4.7 for the x and y.I thought with screen coordinates 0,0 was always the exact bottom left, not sure if what I’m doing wrong here. I’ve also tried ViewportToWorldPoint using 0,0 but I get the same result, any help would be appreciated. Thanks.

Depending on the size of the orthographic camera and aspect ratio of your screen, that sounds about right. If your camera is at (0, 0, -10) and is facing (0, 0, 1), I would expect both x and y to be negative at the bottom-left of the camera view. World coordinates (0, 0) would be at the very center of the camera view ((.5, .5) in viewport coordinates). What values are you expecting to get?

1 Like

Solved, I overlooked the origin in Blender of the model was not set to geometry origin so it was causing the coordinates to be off in Unity. Silly me.

1 Like