はじめに
「UnityFruitCutter」は
Fruit Ninja を Unity で再現しようとしたプロジェクトです
プレイ方法
「Scene1」シーンを開いて Unity を再生するとプレイできます
補足
Unity エディタ上でプレイするためには
いくつかスクリプトを編集する必要があります
Apple.cs
8行目を下記のように書き換えて
private Vector3 randomPos;
Start 関数を次のように変更します
void Start() { randomPos = new Vector3(Random.Range(-1, 1), Random.Range(0.3f, 0.7f), Random.Range(-6.5f, -7.5f)); scoreReference = GameObject.Find("Score").GetComponent<GUIText>(); }
LinesHandler.cs
Update 関数を下記のように書き換えます
void Update() { if(Input.GetMouseButton( 0 )) { lineRenderer.SetVertexCount(i+1); Vector3 mPosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 15); lineRenderer.SetPosition(i, Camera.main.ScreenToWorldPoint(mPosition)); i++; /* Add Collider */ BoxCollider bc = lineGO.AddComponent<BoxCollider>(); bc.transform.position = lineRenderer.transform.position; bc.size = new Vector3(0.1f, 0.1f, 0.1f); } if(Input.GetMouseButtonUp( 0 )) { /* Remove Line */ lineRenderer.SetVertexCount(0); i = 0; /* Remove Line Colliders */ BoxCollider[] lineColliders = lineGO.GetComponents<BoxCollider>(); foreach(BoxCollider b in lineColliders) { Destroy(b); } } }