ERRO:
PlayOneShot was called with a null AudioClip.
UnityEngine.AudioSource:PlayOneShot(AudioClip)
Bala:OnTriggerEnter(Collider) (at Assets/Scripts/Bala.cs:28)
Script audio:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ControlaAudio : MonoBehaviour
{
private AudioSource meuAudioSource;
public static AudioSource instancia;
void Awake ()
{
meuAudioSource = GetComponent<AudioSource>();
instancia = meuAudioSource;
}
}
Script BALA:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bala : MonoBehaviour {
public float Velocidade = 20;
private Rigidbody rigidbodyBala;
public AudioClip MorteZumbi;
private void Start()
{
rigidbodyBala = GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate () {
rigidbodyBala.MovePosition
(rigidbodyBala.position +
transform.forward * Velocidade * Time.deltaTime);
}
void OnTriggerEnter(Collider objetoDeColisao)
{
if(objetoDeColisao.tag == "Inimigo")
{
Destroy(objetoDeColisao.gameObject);
ControlaAudio.instancia.PlayOneShot(MorteZumbi);
}
Destroy(gameObject);
}
}