0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Unity Vector3/Vector2の変数 まとめ

Posted at

##0.0 はじめに
座標や方向を表すVector3やVector2のベクトルでよく使う変数をまとめました。

##1.0 Static変数
forwardとback以外はVector2も同じStatic変数を持っています。
下記はVector3での例です。

変数   使い方    意味
zero  Vector3.zero  Vector3(0, 0, 0)
one  Vector3.one  Vector3(1, 1, 1)
up  Vector3.up  Vector3(0, 1, 0)
down  Vector3.down  Vector3(0, -1, 0)
right  Vector3.right  Vector3(1, 0, 0)
left  Vector3.left  Vector3(-1, 0, 0)
forward  Vector3.forward   Vector3(0, 0, 1) 
back  Vector3.back  Vector3(0, 0, -1)

##2.0 変数
magnitudeは速さなどの大きさを取得するときに使われます。
normalizedは大きさを1にするので正規化と呼ばれています。

変数 使い方 意味
magnitude vector.magnitude ベクトルの長さ(読み取り専用)
normalized vector.normalized magnitude を 1 としたベクトル(読み取り専用)
sqrMagnitude vector.sqrMagnitude ベクトルの 2 乗の長さを返します(読み取り専用)
this[int] vector.this[int] [0]、[1]、[2] を使用して x や y や z 成分にアクセス
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?