# How to place an object at the mouse position?

How can I place a object to position where I clicked in just x,y axis not in z, I am trying to achieve it with

Vector3 mousepos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
object.transform.position = new Vector3(mousepos,mousepos);


but it does not seem to work, in fact the object doesn't even move.

• new Vector3(mouspos,mousepos); This isn't valid syntax. There's no Vector3 constructor that takes two Vector3s as arguments. What is it you're trying to do with this? – DMGregory Dec 10 '17 at 2:12

 Vector3 mousepos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

• Or, as the mousepos vector is not being recomposed... object.transform.position = mousepos – Draco18s no longer trusts SE Dec 11 '17 at 0:38