How to have game audio loop at a certain point

Posted by Essential on Stack Overflow See other posts from Stack Overflow or by Essential
Published on 2013-11-04T07:46:03Z Indexed on 2013/11/04 9:54 UTC
Read the original article Hit count: 127

Filed under:
|
|
|

I have a storm in my game, and so I've made an ambient audio file which slowly grows into a storm and rain fades in, which then becomes a loopable storm audio file. Here is how I've done it:

// Play intro clip and merge into main loop
var introTime = stormIntro.length;
AudioSource.PlayClipAtPoint( stormIntro, Vector3.zero, 0.7 );
Invoke( "StormMusic", introTime );

The way I'm currently trying to do it is get the length of the storm_intro audio clip, play the clip, and then invoke storm_loop to begin after the length of the intro has completed. This kinda works, but not really because there's occasionally a gap between the two. So how can I do it so the transition is seamless?

© Stack Overflow or respective owner

Related posts about audio

Related posts about unity3d