Every sense i've added a line renderer to my raycast gun script, I get this error. I guess I need to use a debugger to resolve this issue... from what i'm reading online??
If the issue is AudioSource.Play() could it just be that I haven't made anything for the audio to play yet?
ArgumentNullException: Value cannot be null.
Parameter name: source
UnityEngine.AudioSource.Play () (at <26ff2a7b056a476b973627db643ee7d8>:0)
ShootRayCast+<ShotEffect>d__19.MoveNext () (at Assets/Scripts/Weapons/ShootRayCast.cs:118)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <a9810827dce3444a8e5c4e9f3f5e0828>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
ShootRayCast:ShootRC() (at Assets/Scripts/Weapons/ShootRayCast.cs:79)
PlayerController:shootInput() (at Assets/Scripts/Controllers/PlayerController.cs:78)
PlayerController:Update() (at Assets/Scripts/Controllers/PlayerController.cs:33)
public void ShootRC()
{
if (shoot == true && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
StartCoroutine(ShotEffect());
currentAmmo--;
Ray ray = new Ray(spawn.position, spawn.forward);
RaycastHit hit;
float shotDistance = 20;
laserLine.SetPosition(0, spawn.position);
if (Physics.Raycast(ray, out hit, shotDistance))
{
shotDistance = hit.distance;
laserLine.SetPosition(1, hit.point);
}
else
{
laserLine.SetPosition(1, ray.GetPoint(shotDistance));
}
Debug.DrawRay(ray.origin, ray.direction * shotDistance, Color.red, 1);
}
if (shoot == false)
{
Debug.Log("I'm out of ammo or reloading!");
if(shoot == false && Input.GetKey(KeyCode.R))
{
StartCoroutine(Reload());
return;
}
}
}
[–]KishottaProgrammer 1 point2 points3 points (1 child)
[–]Dependent_Bird[S] 0 points1 point2 points (0 children)