ReferenceScripting APIVector2
Vector2
classA point or direction in 2D.
| Name | Vector2 |
|---|---|
| Kind | class |
| Script reaches it as | import { Vector2 } from "motion" |
| Since | 0.3 |
Syntax
class Vector2 { … }Properties
| Name | Type | Description |
|---|---|---|
xproperty | number | Across. |
yproperty | number | Down. |
zeroproperty | readonly Vector2 | (0, 0). |
lengthproperty | readonly number | How long it is. |
Methods
| Signature | Description |
|---|---|
new Vector2(x?: number, y?: number): Vector2constructor | A new vector. |
add(v: Vector2): Vector2method | This plus another. |
sub(v: Vector2): Vector2method | This less another. |
scale(k: number): Vector2method | This times a number. |
dot(v: Vector2): numbermethod | The dot product with another. |
normalised(): Vector2method | The same direction, 1 long (0, 0 for none). |
lerp(v: Vector2, t: number): Vector2method | Between this and another, t of the way. |
toArray(): [number, number]method | As [x, y]. |
Notes from the community
Written by creators and checked by the docs' editors. Not part of Motion's official reference.