Hi! I am trying to move a object with touch input, it works flawlessly and i it looks like it is exactly where i want it to be, but it is not. I want the object to be fixed in the Y-axis, and only move on the X and Z axis.
I am using a orthographic camera that is rotated (X:45)(Y:30)
This is basically the code i am using;
if (Input.touchCount == 1) {
transform.position = new Vector3 (Camera.main.ScreenToWorldPoint (Input.mousePosition));
}
The object i am moving is the white cube. Ignore the text on the side, it´s just for debugging on my phone
Camera perspective:
The cube is selected and right above the camera icon.
Editor perspective:
As you can see, i want to move the object on the ground-plane, wheras a fixed Y position.
But the screenToWorldPoint function moves the Y pos. I have search everywhere and can´t seem to find a way to do this. Does anyone know how to do it?