(攻撃の作成)爆発のエフェクトを出す






エフェクトの生成
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class DestroyTrigger : MonoBehaviourPunCallbacks
{
public AudioClip sound;
private void OnTriggerEnter(Collider other)
{
PhotonNetwork.Destroy(this.gameObject);
AudioSource.PlayClipAtPoint(sound, Camera.main.transform.position);
// ★追加
// エフェクトを出す。
// (ポイント)エフェクトの破壊は、エフェクト自身に任せる(PhotonNetwork.Destroyは時間を指定できないので)
PhotonNetwork.Instantiate("ExplosionX", transform.position, Quaternion.identity);
}
}

エフェクトの自動破壊
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class AutoDestroy : MonoBehaviourPunCallbacks
{
void Start()
{
// 生成後、0.5秒経過で自動破壊する。
Invoke("DestroyMine", 0.5f);
}
void DestroyMine()
{
PhotonNetwork.Destroy(this.gameObject);
}
}


【2021版】BattleOnline(全37回)
他のコースを見る





エフェクトの生成
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class DestroyTrigger : MonoBehaviourPunCallbacks
{
public AudioClip sound;
private void OnTriggerEnter(Collider other)
{
PhotonNetwork.Destroy(this.gameObject);
AudioSource.PlayClipAtPoint(sound, Camera.main.transform.position);
// ★追加
// エフェクトを出す。
// (ポイント)エフェクトの破壊は、エフェクト自身に任せる(PhotonNetwork.Destroyは時間を指定できないので)
PhotonNetwork.Instantiate("ExplosionX", transform.position, Quaternion.identity);
}
}

エフェクトの自動破壊
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class AutoDestroy : MonoBehaviourPunCallbacks
{
void Start()
{
// 生成後、0.5秒経過で自動破壊する。
Invoke("DestroyMine", 0.5f);
}
void DestroyMine()
{
PhotonNetwork.Destroy(this.gameObject);
}
}


(攻撃の作成)爆発のエフェクトを出す