Acceleration/offset movent

Hi alI. I was not sure what forum put this so I figured I’d start here.

I have a simple game object that only moves on the x axis. Problem is when I move the cursor, while playing in Uniy3d, I can easily tell the object moves faster. Almost as if the object has some type of movement acceleration to it.

When I export it to xcode and run on my iPhone, the same thing occurs. I would put my finger on the left of the screen, start swiping to the right, and I can see the game object move faster as I get to the right edge of the screen. By the time my finger is 1/2 way through the screen, the object is about 3/4 or so on its way to the right side of the screen. The interesting thing is if I put my finger in the middle of the screen, the object appears slightly offset to the right in the same position as if I would have placed my finger on the left and started moving to the right.

public float minX, maxX;

void Update () {
    Vector3 paddlePos = new Vector3 (0.5f, this.transform.position.y, 0f);
    float mousePosInBlocks = Input.mousePosition.x  / Screen.width * 32;
    paddlePos.x = Mathf.Clamp(mousePosInBlocks, minX, maxX);
    this.transform.position = paddlePos;
   }

Seems logical - as Input.mousePosition.x increases, so does the returned value from your equation. Are you trying to position the object under your mouse / finger or have it slide as you move the mouse / slide your finger?

For the first one, just use ScreenToWorldPoint to properly convert your Input.mousePosition.x value to the actual world value and set that instead.

For sliding, check out the Mouse X axis as it gives the rate of change between the previous frame’s position and the current frame’s position. You could also build this value yourself quite easily by storing the different in positions every frame.

Yes, id like the rate of movement to be exactly as my finger. I will look into the suggestions. Thx!