敵の攻撃⑥(スパイラル弾)
速射弾からスパイラル弾への変化
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyFireMissileB : MonoBehaviour
{
public GameObject enemyMissilePrefab;
public float missileSpeed;
private int timeCount = 0;
void Update()
{
timeCount += 1;
if (timeCount % 5 == 0)
{
GameObject enemyMissile = Instantiate(enemyMissilePrefab, transform.position, Quaternion.identity) as GameObject;
Rigidbody enemyMissileRb = enemyMissile.GetComponent<Rigidbody>();
enemyMissileRb.AddForce(transform.forward * missileSpeed);
Destroy(enemyMissile, 10.0f);
}
// ★追加
// timeCountが500になった時、このオブジェクトにRotateスクリプトを付加する。
if (timeCount == 500)
{
this.gameObject.AddComponent<Rotate>().pos = new Vector3(0, 90, 0);
}
}
}
Danmaku Ⅱ(基礎2/全24回)
他のコースを見る速射弾からスパイラル弾への変化
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyFireMissileB : MonoBehaviour
{
public GameObject enemyMissilePrefab;
public float missileSpeed;
private int timeCount = 0;
void Update()
{
timeCount += 1;
if (timeCount % 5 == 0)
{
GameObject enemyMissile = Instantiate(enemyMissilePrefab, transform.position, Quaternion.identity) as GameObject;
Rigidbody enemyMissileRb = enemyMissile.GetComponent<Rigidbody>();
enemyMissileRb.AddForce(transform.forward * missileSpeed);
Destroy(enemyMissile, 10.0f);
}
// ★追加
// timeCountが500になった時、このオブジェクトにRotateスクリプトを付加する。
if (timeCount == 500)
{
this.gameObject.AddComponent<Rotate>().pos = new Vector3(0, 90, 0);
}
}
}
敵の攻撃⑥(スパイラル弾)