ボスの攻撃を作るその4(ボスの守護ロボットの作成)


ドローン迎撃システム
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossGuard : MonoBehaviour
{
public GameObject effectPrefab;
public AudioClip sound;
public GameObject enemyCore;
private PlayerController pc;
private void Start()
{
pc = GameObject.Find("Player").GetComponent<PlayerController>();
}
private void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Drone"))
{
// 守護ロボットのEnemyCoreの周囲でエフェクトを出す
GameObject effect1 = Instantiate(effectPrefab, enemyCore.transform.position, Quaternion.identity);
Destroy(effect1, 0.5f);
AudioSource.PlayClipAtPoint(sound, transform.position);
// ドローンを破壊する
// rootがポイント
Destroy(other.transform.root.gameObject);
// ドローンの位置にエフェクトを出す。
GameObject effect2 = Instantiate(effectPrefab, other.transform.position, Quaternion.identity);
Destroy(effect2, 1.0f);
// ドローンモードを解除する
pc.StopSpyD();
}
}
}






【2019版】X_Mission(基礎/全51回)
他のコースを見る

ドローン迎撃システム
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossGuard : MonoBehaviour
{
public GameObject effectPrefab;
public AudioClip sound;
public GameObject enemyCore;
private PlayerController pc;
private void Start()
{
pc = GameObject.Find("Player").GetComponent<PlayerController>();
}
private void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Drone"))
{
// 守護ロボットのEnemyCoreの周囲でエフェクトを出す
GameObject effect1 = Instantiate(effectPrefab, enemyCore.transform.position, Quaternion.identity);
Destroy(effect1, 0.5f);
AudioSource.PlayClipAtPoint(sound, transform.position);
// ドローンを破壊する
// rootがポイント
Destroy(other.transform.root.gameObject);
// ドローンの位置にエフェクトを出す。
GameObject effect2 = Instantiate(effectPrefab, other.transform.position, Quaternion.identity);
Destroy(effect2, 1.0f);
// ドローンモードを解除する
pc.StopSpyD();
}
}
}






ボスの攻撃を作るその4(ボスの守護ロボットの作成)