前提・実現したいこと
2DRPGでランダムエンカウントシステムを作成しています。
ジョイスティックを用いた移動を採用しているのですが、
ジョイスティックでの移動入力をどう取得すればよいかわかりません。
①UpDate内の
If文の条件の記載方法を知りたいです。
Float JoyStick を使っています。
あるいは、ジョイスティックとか抜きで、
Playerが〇マス移動するごとに判定を行う条件でも構いません。
②このスクリプトをどこに張り付ければよいでしょうか。
Playerが存在するレイヤーにエンカウントエリアのオブジェクトを作ればよいでしょうか。
なにとぞよろしくお願いいたします。
(例)PHP(CakePHP)で●●なシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
エンカウントが発生しない。
該当のソースコード
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class EnemyEncount : MonoBehaviour { public int number; [SerializeField] private GameObject Chara; bool isEncount = false; // Start is called before the first frame update void Start() { Chara = GameObject.FindGameObjectWithTag("Player"); } // Update is called once per frame void Update() { if ( ジョイスティックでPlayerが移動する) { isEncount = true; } } void OnTriggerStay(Collider other) { if (isEncount) { number = Random.Range(0, 100); print(number); if (number <= 15) { SceneManager.LoadScene("BattleScene"); } isEncount = false; } } }
あなたの回答
tips
プレビュー