worldPos = Camera.main.ScreenToWorldPoint(touch.position);
worldPos.z=0;
Instantiate(cut,worldPos,Quaternion.Euler(0,0,Random.Range(80,100)));
What did I do wrong? When i touch the screen the Prefab only appears in the middle of the screen.
worldPos = Camera.main.ScreenToWorldPoint(touch.position);
worldPos.z=0;
Instantiate(cut,worldPos,Quaternion.Euler(0,0,Random.Range(80,100)));
What did I do wrong? When i touch the screen the Prefab only appears in the middle of the screen.
Touch.position is a Vector2. The implicit conversion from Vector2 to Vector3 ( see here), since ScreenToWorldPoint expects a Vector3 as a parameter, leads to the following statement:
worldPos = Camera.main.ScreenToWorldPoint(touch.position.x, touch.position.y,0);
you set the near clipping plane distance to zero. This basically means you projected the scene into one single point. Use something like this instead:
worldPos = Camera.main.ScreenToWorldPoint(touch.position.x, touch.position.y,Camera.main.nearClipPlane);