I want to place gameobject to same place where I pressed with mouse in X,Y coordinates. Z should be the same always
How can I achieve this?
I tried currently
Vector3 a = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
myGameObject.transform.position = Vector3.Lerp(myGameObject.transform.position, a, 0.01f);
But this doesn't work. It just moves my object in Z coordinate.