Hi,
I’ve been trying to set up a rectangle than moves with the X axis of a mouse. Similar to a Breakout paddle. I have the following code:
public static int zAxisPos = 0; //Static because other scripts may need to get this.
private float yAxisPos = -5.23f;
public float xAxisBoundry = 7.5f;
public float speed = 10f;
// Update is called once per frame
void Update () {
Vector3 mouse = Input.mousePosition;
Debug.Log (mouse);
this.transform.position = new Vector3(mouse.x, yAxisPos, zAxisPos);
It works, kind of. The rectangle moves, but the difference in position to the x-axis of the mouse looks fairly big. Is there a reason this would be happening?