Object not visible

Just made this so the objects gets placed at the bottom and you can move it with a key but after the start the object is invisible (it is still there cause it collides with other objects). After i move it with the key it gets visible. Pls help

void Start()
        {
                transform.position = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width / 2, Screen.height * 0.05f));
        }

        void Update()
        {
            if(Input.GetKey(LeftKey))
            {
                transform.position = new Vector2(transform.position.x - speed / 50, transform.position.y);
            }
        }

That’s because the line in the Start() method places the object in the camera, which has a near clipping plane, which means that objects very close to the camera can not be seen.

You could use this

transform.position = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width / 2, Screen.height * 0.05f)) + Camera.main.transform.forward * z;

to place the object so it can be seen. Replace ‘z’ with a number to adjust the distance from the camera.

Also, since the transform.position in the Update() function only gets a Vector2, it replaces the 3rd coordinate with 0. You could add

transform.position.z

as the 3rd component, and replace Vector2 with Vector3 to maintain the distance from the camera which was set in the Start() method.