Screen position = world position (2D)

I would like to set up the camera so whatever position a game object is 2D space it equals what it would be on the screen.

for example spawn object at position screen.width - 10, screen.height - 10

this game is targeted at mobile phones.

Thanks

Instantiate the object at

Vector3 pos = Camera.main.ScreenToWorldPoint (Screen.width - 10, Screen.height - 10);

In order to make this work there are two changes you have to make. I’m assuming an Orthographic camera. The first change is to set the orthographic size. Orthographic size is 1/2 the vertical size seen by the camera in the world, so you need to set this value to 1/2 of Screen.height. The second change is to translate the camera so that the origin is in the lower left corner. At runtime you can do:

function Start () {
	Camera.main.orthographicSize = Screen.height / 2.0;
	Camera.main.transform.position = Vector3(Screen.width/2.0, Screen.height/2.0, -10);
}

Both of these changes can be done at edit time instead. Note with such a huge orthographic size, you will also have to make a substantial increase in the object size since 1 unit in world space is now one pixel. For sprites you likely would want to change Pixels to Units.

create a private vector 3 and just start the positioning system at start . that will load the position at your vector 3 position, you can also . you can also use vector by transform it to vector 2 to make it more useful for the game .
please accept.

private Vector3 screensize;

	void Start () {

		Vector3 screensize = Camera.main.ScreenToWorldPoint (Screen.width - 10, Screen.height - 10);
		
	}