攻撃力の強化①(オプションの作成)



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);
}
}
}
}

【2021版】Danmaku(基礎/全55回)
他のコースを見る


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);
}
}
}
}

攻撃力の強化①(オプションの作成)