Everything went fine until I out audioPlayer.PlayShootingClip(); in Shooter.cs. I tested everything else, and I found out that adding that one line of code makes the shooting glitch out
Could someone help me? This is my Audio.cs code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AudioPlayer : MonoBehaviour
{
[Header("Shooting")]
[SerializeField] AudioClip shootingClip;
[SerializeField] [Range(0f, 1f)] float shootingVolume = 1f;
[Header("Damage")]
[SerializeField] AudioClip damageClip;
[SerializeField] [Range(0f, 1f)] float damageVolume = 1f;
public void PlayShootingClip()
{
PlayClip(shootingClip, shootingVolume);
}
public void PlayDamageClip()
{
PlayClip(damageClip, damageVolume);
}
void PlayClip(AudioClip clip, float volume)
{
if(clip != null)
{
Vector3 cameraPos = Camera.main.transform.position;
AudioSource.PlayClipAtPoint(clip, cameraPos, volume);
}
}
}