障害物を破壊する(1)
DestroyObject
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyObject : MonoBehaviour {
public GameObject effectPrefab;
public AudioClip effectSound;
void OnCollisionEnter(Collision other){
// (ポイント)「||」の意味を調べましょう!
if (other.gameObject.tag == "Bullet" || other.gameObject.tag == "Rocket") {
Destroy (other.gameObject);
Destroy (gameObject);
AudioSource.PlayClipAtPoint (effectSound, Camera.main.transform.position);
GameObject effect = (GameObject)Instantiate (effectPrefab, transform.position, Quaternion.identity);
Destroy (effect, 1.0f);
}
}
}
EscapeCombat(メモ)
他のコースを見るDestroyObject
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyObject : MonoBehaviour {
public GameObject effectPrefab;
public AudioClip effectSound;
void OnCollisionEnter(Collision other){
// (ポイント)「||」の意味を調べましょう!
if (other.gameObject.tag == "Bullet" || other.gameObject.tag == "Rocket") {
Destroy (other.gameObject);
Destroy (gameObject);
AudioSource.PlayClipAtPoint (effectSound, Camera.main.transform.position);
GameObject effect = (GameObject)Instantiate (effectPrefab, transform.position, Quaternion.identity);
Destroy (effect, 1.0f);
}
}
}
障害物を破壊する(1)