Last active
January 13, 2017 06:54
-
-
Save TeraokaAkihiro/5ffe4de68aafbc891b2400d2beef8045 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [Unity3D]2点を通る垂直なオブジェクトを生成する | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class wallSet : MonoBehaviour { | |
public Vector3[] point = new Vector3[] {}; | |
void Start () { | |
GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad); | |
float xPos = point[0].x; | |
float zPos = point[0].z; | |
quad.transform.position = new Vector3(xPos,0f,zPos); // 高さ以外を移動 | |
Vector3 heading = point [0] - point [1]; // ベクトルを求める | |
Quaternion rotation = Quaternion.LookRotation(heading); | |
quad.transform.rotation = rotation; // とりあえずその方向を向かせる | |
float yAngle = quad.transform.eulerAngles.y + 90f; | |
quad.transform.eulerAngles = new Vector3 (0f, yAngle, 0f); // y軸以外の回転を初期化 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment