> For the complete documentation index, see [llms.txt](https://kree.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kree.gitbook.io/documentation/core-components/vector2.md).

# Vector2

This component contains two points x and y

> Component Author: [Jabo](https://github.com/jabo-bernardo)\
> Release Date: April 11, 2020

{% tabs %}
{% tab title="Usage" %}

```java
new Vector2(float x, float y);
```

{% endtab %}

{% tab title="Methods" %}

```java
static distance(Vector2 v1, Vector2 v2); // Returns the distance between two vector

// Vector2 Math
add(Vector2 vec); // Add to another vector

subtract(Vector2 vec); // Add to another vector

multiply(Vector2 vec); // Add to another vector

divide(Vector2 vec); // Add to another vector

// Math
addX(float n); // Add n to Vector2's X

subtractX(float n); // Subtract n to Vector2's X

addY(float n); // Add n to Vector2's Y

subtractY(float n); // Subtract n to Vector2's Y

// Misc
moveTowards(Vector2 target, float speed); // Move towards a Vector2

setX(float x); // Change x

setY(float y); // Change y

getX(); // Returns float

getY(); // Returns float
```

{% endtab %}
{% endtabs %}
