UnityとWiiの接続に関してです。
2人プレイの簡単なシューティングゲームを作ろうとしています。
下記の記事を参考に、Wiiリモコンを2つ制御できました。ですが、これをどうゲームに使うのかわかりません。
1人用でWiiリモコンを使わないスクリプトは下にある通りです。
初心者ですので、できるだけ具体的に教えていただきたいです。お願いいたします。
<参考にした記事>
http://swamptk.hatenablog.com/entry/2018/01/21/192414
<カーソル側>
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class ShotCursor : MonoBehaviour 6{ 7 8 // カーソルに使用するテクスチャ 9 [SerializeField] 10 private Texture2D cursor; 11 GameObject director; 12 13 14 void Start() 15 { 16 // カーソルを自前のカーソルに変更 17 this.director = GameObject.Find("GameDirector"); 18 Cursor.SetCursor(cursor, new Vector2(cursor.width / 2, cursor.height / 2), CursorMode.ForceSoftware); 19 20 } 21 22 void Update() 23 { 24 // マウスの左クリックで撃つ 25 if (Input.GetButtonDown("Fire1")) 26 { 27 Shot(); 28 29 } 30 } 31 32 // 敵を撃つ 33 void Shot() 34 { 35 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); 36 RaycastHit hit; 37 38 if (Physics.Raycast(ray, out hit, 100f, LayerMask.GetMask("Enemy"))) 39 { 40 this.director.GetComponent<GameDirector>().Get100(); 41 Destroy(hit.collider.gameObject); 42 } 43 } 44}
<UI更新側>
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.UI; 5 6public class GameDirector : MonoBehaviour 7{ 8 GameObject pointText; 9 int point = 0; 10 // Start is called before the first frame update 11 12 public void Get100() { 13 this.point += 100; 14 } 15 16 void Start() 17 { 18 this.pointText = GameObject.Find("Point"); 19 } 20 21 // Update is called once per frame 22 void Update() 23 { 24 this.pointText.GetComponent<Text>().text = this.point.ToString() + "point"; 25 } 26} 27
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。