当我安装炸弹时,它会制造多个炸弹,有时一次最多制造3个炸弹,我希望它制造1个炸弹,而不是2或3个炸弹。
我需要一种方法来确保它只使用一次真空投弹。
我期待着你的帮助,我想说sry为糟糕的英语,也许这一点,我可能已经错过了一些重要的我的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlaneBombDroper : MonoBehaviour
{
public GameObject bomb;
public GameObject bombDropPostion;
public GameObject planePostion;
int bombDropRandomNum;
public float[] dropPostionsX;
bool bombIsDroped;
void Start()
{
bombDropRandomNum = Random.Range(1, 3);
}
void Update()
{
if (bombDropRandomNum == 1 && bombIsDroped != true)
{
if (planePostion.transform.position.x < -2.75f && planePostion.transform.position.x > -3)
{
dropBomb();
}
}
if (bombDropRandomNum == 2&& bombIsDroped != true)
{
if (planePostion.transform.position.x < -9.5 && planePostion.transform.position.x > -10)
{
StartCoroutine("WaitForSeconds");
StopCoroutine("WaitForSeconds");
}
}
}
void dropBomb()
{
Instantiate(bomb, gameObject.transform.position, gameObject.transform.rotation);
}
IEnumerator WaitForSeconds()
{
dropBomb();
yield return new WaitForSeconds(1);
}
}