ray.origin, ray.direction
originプロパティ:開始点
directionプロパティ:方向(単位ベクトル)
public bool unproject_mouse_position(out Vector3 world_position, Vector3 mouse_position) { // returnでtrue、falseを返す。 // ret、ローカル変数にする。 bool ret; float depth; // ピースの中心を通る、水平(法線がY軸。XZ平面)な面. // プレーン型の変数に、planeを生成する Plane plane = new Plane(Vector3.up, new Vector3(0.0f, this.transform.position.y, 0.0f)); // カメラ位置とマウスカーソルの位置を通る直線. Ray ray = this.game_camera.GetComponent<Camera>().ScreenPointToRay(mouse_position); // planeとのあたり判定をチャック if(plane.Raycast(ray, out depth)) { // originプロパティ:開始点 // directionプロパティ:方向(単位ベクトル) world_position = ray.origin + ray.direction*depth; ret = true; } else { world_position = Vector3.zero; ret = false; } return(ret); }