Hey I am facing some problems with ScreenToWorldPoint casting, if you could help me.
Vector3 mouspos = new Vector3 (Input.mousePosition.x, Input.mousePosition.z, Input.mousePosition.y);
mouspos = Camera.main.ScreenToWorldPoint(mouspos);
Instantiate (obj, mouspos, Quaternion.identity);
So basically what I want to do, is to use the mouseposition and to instantiate an object only on x,z axis, but it’s not working.
If I am just using
Vector3 mouspos =Input.mousepoint;
mous.pos.z = 5.0f;
mouspos = Camera.main.ScreenToWorldPoint(mouspos);
Instantiate (obj, mouspos, Quaternion.identity);
With this snippet of code, it will work, but this will place my object on x and y axis.
Would really need a little bit of help