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






エフェクトの生成
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("DestroySelf", 0.5f);
}
void DestroySelf()
{
PhotonNetwork.Destroy(gameObject);
}
}


【2020版】BattleOnline(基礎/全34回)
他のコースを見る





エフェクトの生成
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("DestroySelf", 0.5f);
}
void DestroySelf()
{
PhotonNetwork.Destroy(gameObject);
}
}


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