void Update()
{
float mousePosInUnits = Input.mousePosition.x / Screen.width * screenWidthInUnits;
Vector2 paddlePos = new Vector2(mousePosInUnits, transform.position.y);
transform.position = paddlePos;
}
Hi Svetlin,
To quote the Unity documentation;
Description
Representation of 2D vectors and points.
This structure is used in some places to represent 2D positions and vectors (e.g. texture coordinates in a Mesh or texture offsets in Material). In the majority of other cases a Vector3 is used.
Also, please apply code fencing/formatting when copy/pasting your code, see the link below for instructions.
Hope this helps
See also;
- Unity - Scripting API : Vector2
- Forum User Guides : How to apply code formatting within your post