UnassignedReferenceException: The variable shotSpawn of WeaponController has not been assigned.
You probably need to assign the shotSpawn variable of the WeaponController script in the inspector.
UnityEngine.Transform.get_position () (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineTransformBindings.gen.cs:26)
WeaponController.Fire () (at Assets/Script/WeaponController.cs:23)
とエラーが出ました。
WeaponControllerには
using UnityEngine; using System.Collections; public class WeaponController : MonoBehaviour { public GameObject shot; public Transform shotSpawn; public float fireRate; public float delay; public AudioClip[] clips = new AudioClip[2]; // public AudioClip[] clips; private AudioSource audioSource; // Use this for initialization void Start () { audioSource = GetComponent<AudioSource> (); InvokeRepeating ("Fire", delay, fireRate); } void Fire () { Instantiate (shot, shotSpawn.position, shotSpawn.rotation); AudioClip clip = clips [Random.Range (0, clips.Length)]; audioSource.clip = clip; audioSource.Play (); } }
と書きました。
これのどこにshotSpawn を代入すれば良いのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。