Vector2データ型

データ型日本語解説は準備中

ひとことで言うと

Vector2は、ロブロックス(Roblox)のデータ型です。くわしい日本語解説は準備中のため、下に公式の説明(英語)を載せています。

公式の説明(英語):Represents a 2D value with direction and magnitude.

コンストラクター(作り方)(1)

名前と書き方説明
new
Vector2.new(x: number, y: number)
Returns a Vector2 from the given x and y components.

プロパティ(4)

名前と書き方説明
X
Vector2.X: number
The x-coordinate of the Vector2.
Y
Vector2.Y: number
The y-coordinate of the Vector2.
Magnitude
Vector2.Magnitude: number
The length of the Vector2.
Unit
Vector2.Unit: Vector2
A normalized copy of the Vector2.

メソッド(11)

名前と書き方説明
Cross
Vector2:Cross(other: Vector2): number
Returns the cross product of the two vectors.
Abs
Vector2:Abs(): Vector2
Returns a new vector from the absolute values of the original's components.
Ceil
Vector2:Ceil(): Vector2
Returns a new vector from the ceiling of the original's components.
Floor
Vector2:Floor(): Vector2
Returns a new vector from the floor of the original's components.
Sign
Vector2:Sign(): Vector2
Returns a new vector from the sign (-1, 0, or 1) of the original's components.
Angle
Vector2:Angle(other: Vector2, isSigned: boolean): number
Returns the angle in radians between the two vectors.
Dot
Vector2:Dot(v: Vector2): number
Returns a scalar dot product of the two vectors.
Lerp
Vector2:Lerp(v: Vector2, alpha: number): Vector2
Returns a Vector2 linearly interpolated between this Vector2 and the given goal by the given alpha.
Max
Vector2:Max(others...: Tuple): Vector2
Returns a Vector2 with each component as the highest among the respective components of the provided Vector2 objects.
Min
Vector2:Min(others...: Tuple): Vector2
Returns a Vector2 with each component as the lowest among the respective components of the provided Vector2 objects.
FuzzyEq
Vector2:FuzzyEq(other: Vector2, epsilon: number): bool
Returns true if the X and Y components of the other Vector2 are within epsilon units of each corresponding component of this Vector2.

英語の説明とメンバーの一覧は、Roblox Creator Documentation(Vector2)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。

執筆:鈴木孝昌官公庁のWeb・システム開発を担当する現役プロジェクトマネージャー。沖縄マイクラ部 クロスウェーブで、ロブロックス(Roblox)・マインクラフト(マイクラ)・Scratchなどのプログラミングを指導。マイクラカップ沖縄代表チームを指導(第6回・第7回、第7回TBS賞)。
沖縄マイクラ部で、子どもたちにロブロックス(Roblox)やマインクラフト(マイクラ)のプログラミングを教えています。プロフィールと編集方針
Instagramで教室の様子を見る
noteで記事を読む