ボスの攻撃を作るその2(巨大ビーム砲の発射間隔の改良)
発射間隔の改良
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossCore : MonoBehaviour
{
public GameObject damageEffectPrefab;
private int hitCount;
private Animator anim;
// ★追加(発射間隔の変更)
private BossShotBeam bsb;
private void Start()
{
anim = transform.root.GetComponent<Animator>();
// ★追加(発射間隔の変更)
bsb = GetComponent<BossShotBeam>();
Invoke("GoToForm1", 3.0f);
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("Drone"))
{
hitCount += 1;
Destroy(collision.gameObject);
GameObject effect = Instantiate(damageEffectPrefab, collision.transform.position, Quaternion.identity);
Destroy(effect, 0.5f);
if (hitCount == 2)
{
anim.SetTrigger("Back_Idle");
Invoke("GoToForm2", 3.0f);
}
else if (hitCount == 5)
{
anim.SetTrigger("Back_Idle");
Invoke("GoToForm3", 3.0f);
}
}
}
void GoToForm1()
{
anim.SetTrigger("Form_1");
}
void GoToForm2()
{
anim.SetTrigger("Form_2");
// ★追加(発射間隔の変更)
bsb.shotInterval = 50;
}
void GoToForm3()
{
anim.SetTrigger("Form_3");
// ★追加(発射間隔の変更)
bsb.shotInterval = 30;
}
}
【2019版】X_Mission(基礎/全51回)
他のコースを見る発射間隔の改良
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossCore : MonoBehaviour
{
public GameObject damageEffectPrefab;
private int hitCount;
private Animator anim;
// ★追加(発射間隔の変更)
private BossShotBeam bsb;
private void Start()
{
anim = transform.root.GetComponent<Animator>();
// ★追加(発射間隔の変更)
bsb = GetComponent<BossShotBeam>();
Invoke("GoToForm1", 3.0f);
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("Drone"))
{
hitCount += 1;
Destroy(collision.gameObject);
GameObject effect = Instantiate(damageEffectPrefab, collision.transform.position, Quaternion.identity);
Destroy(effect, 0.5f);
if (hitCount == 2)
{
anim.SetTrigger("Back_Idle");
Invoke("GoToForm2", 3.0f);
}
else if (hitCount == 5)
{
anim.SetTrigger("Back_Idle");
Invoke("GoToForm3", 3.0f);
}
}
}
void GoToForm1()
{
anim.SetTrigger("Form_1");
}
void GoToForm2()
{
anim.SetTrigger("Form_2");
// ★追加(発射間隔の変更)
bsb.shotInterval = 50;
}
void GoToForm3()
{
anim.SetTrigger("Form_3");
// ★追加(発射間隔の変更)
bsb.shotInterval = 30;
}
}
ボスの攻撃を作るその2(巨大ビーム砲の発射間隔の改良)