Audio: Does Stop() affect PlayOneShot()?

I have a moving platform that triggers once you hit a switch. The platform moves into place and then waits for more input from the switch. After a short time the switch un-triggers and the platform moves back into place.

At the moment I am using PlayOneShot to play an audio clip when the switch tells the platform to start, and plays a different audio clip when the switch tells the platform to move back into place. I also have an ambient audio sound on the platform. This ambient audio only plays while the platform is moving mid-flight.

The problem I am running into is that my oneshots seem to play sometimes and not other times, and it’s hard for me to debug why this is happening inconsistently. My only current theory is that the following code is causing problems. It is attached to the update script in my platform and is meant to control ONLY the ambient audio:


soundStop is a bool that is true whenever the platform is NOT moving. elevatorAudio is the AudioSource I am using for both the ambient sound AND the OneShots.

If, in the same frame that I call a OneShot I also call “Stop” does that prevent the OneShot from working? My assumption was that OneShot’s whole purpose is to play no matter what the audiosource is doing, but I might be off base on that one.


Stop() does stop a one shot. I’ve done a test. Things played with PlayOneShot(), are also affected by subsequent panning, volume changes etc.

Audio.Stop does not affect it. I have found my problem and it was a mistake in my inspector. Two floating platforms’ scripts were referencing the one I was trying to move. This had the result of both scripts giving the platform conflicting information about whether it should be playing sound or not.