攻撃力の強化①(オプションの作成)
![A158a063 7857 436e 80a4 f356baa5707e](https://codegenius.org/uploads/slide/image/7688/a158a063-7857-436e-80a4-f356baa5707e.jpeg)
![D8fb87c0 cef6 4fe4 92a7 105b5a48e00b](https://codegenius.org/uploads/slide/image/7689/d8fb87c0-cef6-4fe4-92a7-105b5a48e00b.jpeg)
![F80788b7 37a1 4cc3 949e 31d5204f7df9](https://codegenius.org/uploads/slide/image/7690/f80788b7-37a1-4cc3-949e-31d5204f7df9.jpeg)
Optionの攻撃
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OptionFire : MonoBehaviour
{
public GameObject missilePrefab;
private int count;
private void FixedUpdate()
{
if (Input.GetKey(KeyCode.Space))
{
count += 1;
if (count % 5 == 0)
{
GameObject missile = Instantiate(missilePrefab, transform.position, Quaternion.identity);
Rigidbody missileRb = missile.GetComponent<Rigidbody>();
missileRb.AddForce(transform.forward * 900);
Destroy(missile, 2.0f);
}
}
}
}
![23d779f0 1cea 4377 a3fa ceff30a62084](https://codegenius.org/uploads/slide/image/7691/23d779f0-1cea-4377-a3fa-ceff30a62084.jpeg)
【2021版】Danmaku(基礎/全55回)
他のコースを見る![A158a063 7857 436e 80a4 f356baa5707e](https://codegenius.org/uploads/slide/image/7688/a158a063-7857-436e-80a4-f356baa5707e.jpeg)
![D8fb87c0 cef6 4fe4 92a7 105b5a48e00b](https://codegenius.org/uploads/slide/image/7689/d8fb87c0-cef6-4fe4-92a7-105b5a48e00b.jpeg)
![F80788b7 37a1 4cc3 949e 31d5204f7df9](https://codegenius.org/uploads/slide/image/7690/f80788b7-37a1-4cc3-949e-31d5204f7df9.jpeg)
Optionの攻撃
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OptionFire : MonoBehaviour
{
public GameObject missilePrefab;
private int count;
private void FixedUpdate()
{
if (Input.GetKey(KeyCode.Space))
{
count += 1;
if (count % 5 == 0)
{
GameObject missile = Instantiate(missilePrefab, transform.position, Quaternion.identity);
Rigidbody missileRb = missile.GetComponent<Rigidbody>();
missileRb.AddForce(transform.forward * 900);
Destroy(missile, 2.0f);
}
}
}
}
![23d779f0 1cea 4377 a3fa ceff30a62084](https://codegenius.org/uploads/slide/image/7691/23d779f0-1cea-4377-a3fa-ceff30a62084.jpeg)
攻撃力の強化①(オプションの作成)