5
7

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 5 years have passed since last update.

unityの世界に30秒で飛び込む

5
Posted at

用意するもの

  • androidかiOS
  • Unity環境

30秒で準備する

新規プロジェクトを作ったら
1.Assets>Import Package>SkyBoxes
をインポート。
空のテクスチャがインポートされる。

2.MainCameraのインスペクタから
Add compornent>Skybox

3.インスペクタに追加されたSkyboxに
Standerd Assets>Skyboxes>Sunny Skybox
を追加

4.新しくC#スクリプトを作成し

MainCamera.cs
using UnityEngine;
using System.Collections;

public class MainCamera : MonoBehaviour {
	void Start () {
		Input.gyro.enabled = true;
	}
	void Update () {
		Quaternion q = Input.gyro.attitude;
		Quaternion qq = Quaternion.AngleAxis(-90.0f, Vector3.left);
		q.x *= -1.0f;
		q.y *= -1.0f;
		transform.localRotation = qq * q;
	}
}

をコピペ

4.MainCameraに上記のスクリプトを追加する

5.ビルド!!

Screenshot_2015-02-18-21-20-51.png

Screenshot_2015-02-18-21-20-41.png

unityの世界に入り込めた!!!

30秒で出来る!!!

今日一日で躓いていた所

ジャイロじゃなくて、加速度センサーで頑張っていた。
加速度センサーで頑張るとめっちゃガクガクになるばかりか、それっぽく動くので頑張れば頑張るほど沼る。

5
7
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
5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?