敵の攻撃⑤(スパイラル弾)
![6b8ee8ea bdf6 4d85 a7af 46668a5d0156](https://codegenius.org/uploads/slide/image/4727/6b8ee8ea-bdf6-4d85-a7af-46668a5d0156.jpeg)
![17289799 85bd 474f 8fd9 0a461c0c9788](https://codegenius.org/uploads/slide/image/4728/17289799-85bd-474f-8fd9-0a461c0c9788.jpeg)
![C029c4c9 f7fa 4e39 b2fa 88506ac62f50](https://codegenius.org/uploads/slide/image/4729/c029c4c9-f7fa-4e39-b2fa-88506ac62f50.jpeg)
![Adaad2ca 97de 484a bbb3 f97b2c45e912](https://codegenius.org/uploads/slide/image/4730/adaad2ca-97de-484a-bbb3-f97b2c45e912.jpeg)
![5b3bd252 371f 40da 94f9 ea33b0d0f99f](https://codegenius.org/uploads/slide/image/4731/5b3bd252-371f-40da-94f9-ea33b0d0f99f.jpeg)
![7d9d8610 cac3 49f0 a5d7 1730bc930d7b](https://codegenius.org/uploads/slide/image/4732/7d9d8610-cac3-49f0-a5d7-1730bc930d7b.jpeg)
スパイラル弾
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyFireMissileB : MonoBehaviour
{
public GameObject enemyMissilePrefab;
public float speed;
private int timeCount;
void Update()
{
timeCount += 1;
if(timeCount % 5 == 0)
{
GameObject missile = Instantiate(enemyMissilePrefab, transform.position, Quaternion.identity);
Rigidbody missileRb = missile.GetComponent<Rigidbody>();
missileRb.AddForce(transform.forward * speed);
Destroy(missile, 10f);
}
// ★追加
// timeCountが500になった時、このオブジェクトにRotateスクリプトを付加する。
// 同時にRotation Yに90を設定する。
if(timeCount == 500)
{
this.gameObject.AddComponent<Rotate>().pos = new Vector3(0, 90, 0);
}
}
}
![955e3b2b 4795 4694 8c41 b81188add56b](https://codegenius.org/uploads/slide/image/4733/955e3b2b-4795-4694-8c41-b81188add56b.jpeg)
【2019版】Danmaku Ⅱ(基礎2/全38回)
他のコースを見る![6b8ee8ea bdf6 4d85 a7af 46668a5d0156](https://codegenius.org/uploads/slide/image/4727/6b8ee8ea-bdf6-4d85-a7af-46668a5d0156.jpeg)
![17289799 85bd 474f 8fd9 0a461c0c9788](https://codegenius.org/uploads/slide/image/4728/17289799-85bd-474f-8fd9-0a461c0c9788.jpeg)
![C029c4c9 f7fa 4e39 b2fa 88506ac62f50](https://codegenius.org/uploads/slide/image/4729/c029c4c9-f7fa-4e39-b2fa-88506ac62f50.jpeg)
![Adaad2ca 97de 484a bbb3 f97b2c45e912](https://codegenius.org/uploads/slide/image/4730/adaad2ca-97de-484a-bbb3-f97b2c45e912.jpeg)
![5b3bd252 371f 40da 94f9 ea33b0d0f99f](https://codegenius.org/uploads/slide/image/4731/5b3bd252-371f-40da-94f9-ea33b0d0f99f.jpeg)
![7d9d8610 cac3 49f0 a5d7 1730bc930d7b](https://codegenius.org/uploads/slide/image/4732/7d9d8610-cac3-49f0-a5d7-1730bc930d7b.jpeg)
スパイラル弾
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyFireMissileB : MonoBehaviour
{
public GameObject enemyMissilePrefab;
public float speed;
private int timeCount;
void Update()
{
timeCount += 1;
if(timeCount % 5 == 0)
{
GameObject missile = Instantiate(enemyMissilePrefab, transform.position, Quaternion.identity);
Rigidbody missileRb = missile.GetComponent<Rigidbody>();
missileRb.AddForce(transform.forward * speed);
Destroy(missile, 10f);
}
// ★追加
// timeCountが500になった時、このオブジェクトにRotateスクリプトを付加する。
// 同時にRotation Yに90を設定する。
if(timeCount == 500)
{
this.gameObject.AddComponent<Rotate>().pos = new Vector3(0, 90, 0);
}
}
}
![955e3b2b 4795 4694 8c41 b81188add56b](https://codegenius.org/uploads/slide/image/4733/955e3b2b-4795-4694-8c41-b81188add56b.jpeg)
敵の攻撃⑤(スパイラル弾)