
unity CS1061 エラーについてです。
下記のこの2つの文章のエラーについてですが、
インターネットで調べたことを試してみたのですが、エラーの原因がよくわかりません。
どなたか原因を教えてください。よろしくお願いいたします。
エラー1つ目「Assets\FpsGunControler.cs(82,63): error CS1061: 'float' does not contain a definition for 'forward' and no accessible extension method 'forward' accepting a first argument of type 'float' could be found (are you missing a using directive or an assembly reference?)」
エラー2つ目「Assets\FpsGunControler.cs(82,41): error CS1061: 'float' does not contain a definition for 'position' and no accessible extension method 'position' accepting a first argument of type 'float' could be found (are you missing a using directive or an assembly reference?)」
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FpsGunControler : MonoBehaviour
{
[SerializeField]
ParticleSystem muzzleFlashParticle = null;
[SerializeField]
GameObject bulletHitEffectPrefab = null;
// ★変更その2
[SerializeField]
float resupplyInterval = 10;
[SerializeField]
Image ammoGauge = null;
[SerializeField]
Image resupplyGauge = null;
float FireTimer;
int maxAmmo;
float maxRange;
float hitLayers;
int damage; float fireInterval; public float bulletSpawn; bool fireTimerIsActive = false; RaycastHit hit; WaitForSeconds fireIntervalWait; int currentAmmo = 0; bool resupplyTimerIsActive = false; public int CurrentAmmo { set { currentAmmo = Mathf.Clamp(value, 0, maxAmmo); float scaleX = currentAmmo / (float)maxAmmo; ammoGauge.rectTransform.localScale = new Vector3(scaleX, 1, 1); } get { return currentAmmo; } } void Start() { fireIntervalWait = new WaitForSeconds(fireInterval); // WaitForSecondsをキャッシュしておく(高速化) // ★変更その2 CurrentAmmo = maxAmmo; } void Update() { if (Input.GetButton("Fire1")) { Fire(); } // ★変更その2 if (!resupplyTimerIsActive) { StartCoroutine(nameof(ResupplyTimer)); } } // 弾の発射処理 void Fire() { // ★変更その2 if (fireTimerIsActive || CurrentAmmo <= 0) { return; } // ★変更その1 muzzleFlashParticle.Play(); if (Physics.Raycast(bulletSpawn.position, bulletSpawn.forward,out hit, maxRange, hitLayers, QueryTriggerInteraction.Ignore)) { BulletHit(); } StartCoroutine(nameof(FireTimer)); // ★変更その2 CurrentAmmo--; } // 省略 // ★変更その2。一定時間経過ごとに弾薬を全回復するタイマー IEnumerator ResupplyTimer() { resupplyTimerIsActive = true; float timer = 0; while (timer < resupplyInterval) { resupplyGauge.rectTransform.localScale = new Vector3(timer / resupplyInterval, 1, 1); timer += Time.deltaTime; yield return null; } CurrentAmmo = maxAmmo; resupplyTimerIsActive = false; } // ★変更その2。弾薬回復タイマーをキャンセルする処理 public void StopResupplyTimer() { StopCoroutine(nameof(ResupplyTimer)); resupplyTimerIsActive = false; } void BulletHit() { Instantiate(bulletHitEffectPrefab, hit.point, Quaternion.LookRotation(hit.normal)); if(hit.collider.gameObject.tag == "Enemy") { EnemyController enemy = hit.collider.gameObject.GetComponent<EnemyController>(); enemy.Damage(damage); } }
}





回答4件
あなたの回答
tips
プレビュー