Unity/Csharp/位置
提供: 初心者エンジニアの簡易メモ
中間位置
Vector3 center = Vector3.Lerp(fromObj, toObj, 0.5f);
3dの回転
Unity/3d/回転 [ショートカット]
方向
以下それぞれ2つは同じ意味
new Vector3(0f, 0f, 0f) Vector3.zero
new Vector3(1f, 1f, 1f) Vector3.one
new Vector3(2f, 2f, 2f) Vector3.one * 2;
new Vector3(0, 1, 0) Vector3.up
Vector3(0, -1, 0) Vector3.down
Vector3(1, 0, 0) Vector3.right
Vector3(-1, 0, 0) Vector3.left
Vector3(0, 0, 1) Vector3.forward
Vector3(0, 0, -1) Vector3.back
指定場所へ徐々に移動
返されるpositionは、少し移動した座標となる
Vector startPosition = new Vector(1f, 0f, 0f); Vector endPosition = new Vector(1f, 1f, 1f); float speed = 2f; float step = speed * Time.deltaTime; Vector3 position = Vector3.MoveTowards( startPosition, endPosition, step );