unity 2018 2.7で3Dゲームを本を参照しながら作っています。
以下のエラーが出ます
error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement ```C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BasketController : MonoBehaviour
{
public AudioClip appleSE;
public AudioClip bombSE;
AudioSource aud;
GameObject director;
void Start(){ this.director = GameObject.Find("GameDirector"); this.aud = GetComponent<AudioSource>(); } //タグを表示、アイテムを破棄 void OnTriggerEnter(Collider other){ if(other.gameObject.tag == "Apple"){ this.director.GetComponent<GameDirector>().GetApple; this.aud.PlayOneShot(this.appleSE); } else { this.director.GetComponent<GameDirector>().GetBomb; this.aud.PlayOneShot(this.bombSE); } Destroy(other.gameObject); } // Update is called once per frame void Update() { if(Input.GetMouseButtonDown(0)){ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { float x = Mathf.RoundToInt(hit.point.x); float z = Mathf.RoundToInt(hit.point.z); transform.position = new Vector3(x, 0, z); } } }
}
this director.GetComponent<GameDirector>().GetApple; this director.GetComponent<GameDirector>().GetBomb; においてメソッドの参照をしていますが上のようなエラーが出ます。 getapple,getbombは他のスクリプトで以下のように書いています。 ```C# using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GameDirector : MonoBehaviour { GameObject timerText; GameObject pointText; float time = 60; int point = 0; //りんごをキャッチした時のポイント public void GetApple() { this.point += 100; } //爆弾をキャッチした時のポイント public void GetBomb() { this.point /= 2; }
様々なサイトを見て見ましたが解決方法がわかりません。
ご教授お願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/27 06:34