初心者なのでサイトをまねして作っていたら2つエラーが発生してしまいましたどうすればいいですか?
真似しているサイト→ (https://unity.moon-bear.com/zombie-slayer/gauge-and-score/)
エラーメッセージ↓
1つ目 The name"Shoot Timer"does not exist in the current context
2つ目 The name"GetInput"does not exist in the current context
バージョンunity 2019 2.1
コード↓
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FirstPersonGunController : MonoBehaviour
{
public enum ShootMode { AUTO, SEMIAUTO }
public bool shootEnabled = true; [SerializeField] ShootMode shootMode = ShootMode.AUTO; [SerializeField] int maxAmmo = 100; [SerializeField] int maxSupplyValue = 100; [SerializeField] int damage = 1; [SerializeField] float shootInterval = 0.1f; [SerializeField] float shootRange = 50; [SerializeField] float supplyInterval = 0.1f; [SerializeField] Vector3 muzzleFlashScale; [SerializeField] GameObject muzzleFlashPrefab; [SerializeField] GameObject hitEffectPrefab; [SerializeField] Image ammoGauge; [SerializeField] Text ammoText; [SerializeField] Image supplyGauge; bool shooting = false; bool supplying = false; int ammo = 0; int supplyValue = 0; GameObject muzzleFlash; GameObject hitEffect; public int Ammo { set { ammo = Mathf.Clamp(value, 0, maxAmmo); //UIの表示を操作 //テキスト ammoText.text = ammo.ToString("D3"); //ゲージ float scaleX = (float)ammo / maxAmmo; ammoGauge.rectTransform.localScale = new Vector3(scaleX, 1, 1); } get { return ammo; } } public int SupplyValue { set { supplyValue = Mathf.Clamp(value, 0, maxSupplyValue); if (SupplyValue >= maxSupplyValue) { Ammo = maxAmmo; supplyValue = 0; } float scaleX = (float)supplyValue / maxSupplyValue; supplyGauge.rectTransform.localScale = new Vector3(scaleX, 1, 1); } get { return supplyValue; } } void Start() { InitGun(); } void Update() { if (shootEnabled & ammo > 0 & GetInput()) //ここの行 { StartCoroutine(ShootTimer()); //ここの行 } if (shootEnabled) { StartCoroutine(SupplyTimer()); } }0. public void InitGun() { Ammo = maxAmmo; SupplyValue = 0; } //--中略-- IEnumerator SupplyTimer()> { if (!supplying) { supplying = true; SupplyValue++; yield return new WaitForSeconds(supplyInterval); supplying = false; } }
}
できればどこが間違っていたのかを教えてください。
回答2件
あなたの回答
tips
プレビュー