So I've been struggling over my code for a few hours with no luck. I'm trying to play and audio clip when walking into a box collider on top of a sword. But instead of playing the audio clip, I get the error "Cannot playa disabled audio source." It's very frustrating and I am quite confused. This is my code below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pickup2 : MonoBehaviour
{
public GameObject RealSword;
public GameObject FakerSword;
public AudioSource stab;
// Use this for initialization
void Start()
{
GetComponent();
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter(Collider other)
{
if (gameObject.tag == "MegaFake")
RealSword.SetActive(true);
FakerSword.SetActive(false);
stab.Play();
Any help is incredibly appreciated!
↧