08-31-2018, 04:37 PM
(En son düzenleme: 08-31-2018, 05:46 PM furkann3142.)
Selamlar arkadaşlar;
Doğukan hocamın videosunu izlediğim kadarıyla. Yaptığı her işlemi uyguladım. Belki göz önünden bişeyler kaçmış olabilir yardımcı olur musunuz?
Oyun Preview bölümüne girince direk console kısmından üst üste basmadığım halde hatalar geliyor ve artıyor.(Fotoğrafta var)
Yazdığım kodlar ise şöyle
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GunFire : MonoBehaviour {
float gunTimer;
public float gunCooldown; // ateş etme sıklığı
public Transform firePoint;
RaycastHit rayHit;
public GameObject Bulethole;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButton("Fire1"))
if(Time.time > gunTimer)
if(Physics.Raycast(firePoint.position, firePoint.forward, out rayHit))
gunTimer = Time.time + gunCooldown;
Debug.Log("batuhan");
Vector3 BuletholePosition = rayHit.point + rayHit.normal * 0.01f;
Quaternion BuletholeRotation = Quaternion.FromToRotation (-Vector3.forward, rayHit.normal);
GameObject obj = Instantiate (Bulethole, BuletholePosition, BuletholeRotation) as GameObject;
}
}
Acaba nerede yanlış yapıyorum yardımcı olur musunuz??
Hata: UnassignedReferenceException: The variable Bulethole of GunFire has not been assigned.
You probably need to assign the Bulethole variable of the GunFire script in the inspector.
UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineObjectBindings.gen.cs:52)
UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:156)
UnityEngine.Object.Instantiate[GameObject] (UnityEngine.GameObject original, Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:206)
GunFire.Update () (at Assets/Script/GunFire.cs:34)
Doğukan hocamın videosunu izlediğim kadarıyla. Yaptığı her işlemi uyguladım. Belki göz önünden bişeyler kaçmış olabilir yardımcı olur musunuz?
Oyun Preview bölümüne girince direk console kısmından üst üste basmadığım halde hatalar geliyor ve artıyor.(Fotoğrafta var)
Yazdığım kodlar ise şöyle
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GunFire : MonoBehaviour {
float gunTimer;
public float gunCooldown; // ateş etme sıklığı
public Transform firePoint;
RaycastHit rayHit;
public GameObject Bulethole;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButton("Fire1"))
if(Time.time > gunTimer)
if(Physics.Raycast(firePoint.position, firePoint.forward, out rayHit))
gunTimer = Time.time + gunCooldown;
Debug.Log("batuhan");
Vector3 BuletholePosition = rayHit.point + rayHit.normal * 0.01f;
Quaternion BuletholeRotation = Quaternion.FromToRotation (-Vector3.forward, rayHit.normal);
GameObject obj = Instantiate (Bulethole, BuletholePosition, BuletholeRotation) as GameObject;
}
}
Acaba nerede yanlış yapıyorum yardımcı olur musunuz??
Hata: UnassignedReferenceException: The variable Bulethole of GunFire has not been assigned.
You probably need to assign the Bulethole variable of the GunFire script in the inspector.
UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineObjectBindings.gen.cs:52)
UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:156)
UnityEngine.Object.Instantiate[GameObject] (UnityEngine.GameObject original, Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:206)
GunFire.Update () (at Assets/Script/GunFire.cs:34)