九九のゲームを作ってまして、正解だと花火があがるようにしたいのです。クエスチョンマネージャーにある答えとプレイヤーの答えがあったらというIf文をスポーンマネージャーで作ってみたのですが、間違っているようでエラーがでます。どうやって呼び込んだらいいのでしょうか?
スポーンマネージャーのTextは、プレイヤーが入力するゲームオブジェクトです。
どうぞよろしくお願いいたします。
クエスチョンマネージャーのスクリプト public class QuestionManager : MonoBehaviour { [Header("Questions")] [SerializeField] QuestionDataList[] questionDataLists; [Header("Question UI")] [SerializeField] Text questionText = null; [Header("Question UI")] [SerializeField] Text answerText = null; private int questionNumber; private void Start() { SetupQuestion(); } private void SetupQuestion() { questionNumber = Random.Range(0, 81); questionText.text = questionDataLists[questionNumber].GetQuestion(); } private void SetupAnswer() { answerText.text = questionDataLists[questionNumber].GetAnswer(); } public void QuestionButton() { SetupQuestion(); } public void AnswerButton() { SetupAnswer(); } public void ClearText() { answerText.text = ""; } }
public class SpawnManager : MonoBehaviour { public GameObject[] firePrefabs; void Update() { if (QuestionManager.GetComponent<QuestionManager>().AnswerText == Text.GetComponent<Text>()) { int fireIndex = Random.Range(0,3); Instantiate(firePrefabs[fireIndex], new Vector2(0, 235), firePrefabs[fireIndex].transform.rotation); } } } コード
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/05/07 09:58