any kind of audio.play_to_end() function?

there’s no way there is no built in way to play an audio file until it ends using a single command, but nothing in the scripting reference database has turned up

i’m trying to make it so that one sound will play when an observer value is between 25 and 75, but another, different sound will play if the value drops below 25. Not overlapped sound mind you, the first one will play until it ends its loop, then the next will play.

how do i do this without using some crazy audio.length - audio.time crap?

You don’t. Stop being lazy. The kind of funcionality you’re talking about would be useless to almost everybody and doesn’t belong in the API.

And the appropriate solution is probably to use the new sample delay feature that unity 3 introduced for AudioSource.Play().

wait
so
playing a sound when something happens, and having that sound play to conclusion is useless to almost everybody?
what

No. That’s what Play() does, already. What you’re talking about is having a clip play immediately after the end of another. That is not a common requirement, as Unity is designed to facilitate making 3D interactive content, not jukeboxes.

I’m not saying that what you’re doing should not be possible. I’ve actually made a jukebox in Unity before. And switching between various looping clips can be a great way to get variation into a sustained sound. However, unless Unity ever incorporates using an array of audio clips for AudioSource.clip, this just won’t be useful to many people.

In the meantime, the page for that that parameter already gives you one example of the type of code you need.

you mean yield waitforseconds? that would result in an update is not a coroutine error in my case

hrm, maybe if i just had an “isplaying” boolean, and the if statement would only execute while isplaying is false.

It wouldn’t if you read up on how to actually use a coroutine.

They already give you that, and they spell it with proper camelCase, too. :roll_eyes: