Audio triggers as soon as i enter play mode.

I don’t know why as soon as i enter play mode the audio for opening a door automatically plays i dont want it to trigger as i enter play mode only when it is colided with an object

here’s my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DoorOpenFirst : MonoBehaviour
{
public GameObject theDoor;
public AudioSource doorFX;

void OnTriggerEnter(Collider other)
{
doorFX.Play();
theDoor.GetComponent().Play(“DoorOpen”);

}
void OnTriggerExit(Collider other)
{
doorFX.Play();
theDoor.GetComponent().Play(“DoorClose”);

}

}

Please help

Check the audio component, for PlayOnAwake

oh yeah tnx it worked

1 Like