private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { th = GameObject.Find("Tank").GetComponent <TankHealth>(); th.AddHP(reward); Destroy(gameObject); GameObject effect = Instantiate(effectPrefab, transform.position, Quaternion.identity); Destroy(effect, 0.5f); AudioSource.PlayClipAtPoint(getSound, transform.position); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { th = other.gameObject.GetComponent <TankHealth>(); th.AddHP(50); th.SetHealthUI(); Destroy(gameObject); GameObject effect = (GameObject)Instantiate(effectPrefab, transform.position, Quaternion.identity); Destroy(effect, 0.7f); } }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player") { th = GameObject.Find("Tank").GetComponent <TankHealth> (); //AddHp()メソッドを呼び出して引数にrewardを与えている th.AddHP(reward); Destroy(gameObject); GameObject effect = (GameObject)Instantiate(effectPrefab, transform.position, Quaternion.identity); Destroy(effect, 0.5f); AudioSource.PlayClipAtPoint(getSound, transform.position); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { // Find()メソッドの使い方をマスターすること th = GameObject.Find("Tank").GetComponent <TankHealth>(); // AddHP()メソッドを呼び出して「引数」にrewardを与えている。 th.AddHP(reward); Destroy(gameObject); GameObject effect = (GameObject)Instantiate(effectPrefab, transform.position, Quaternion.identity); Destroy(effect, 0.5f); AudioSource.PlayClipAtPoint(getSound, Camera.main.transform.position); } }