What does "Vector2" do and why is it in not called Vector1 e.g.?

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 :slight_smile:


See also;

Privacy & Terms