Set ambient Audio to DynamicSMActor

It’s possible set an ambient sound to an dynamicSMActor through unrealscript inside the actor’s default properties?

Yeah, you just need to subclass it and declare AudioComponent in default properties, like this:


var(Beamos, Sounds) AudioComponent SpinSound;

defaultproperties
{
	Begin Object Class=AudioComponent Name=SpinSoundComp
		SoundCue = SoundCue'Enemies.Beamos.Sounds.Beamos_Spin_Cue'
		bAutoPlay = False
		bAutoDestroy = False
		bStopWhenOwnerDestroyed = True
	End Object
	SpinSound = SpinSoundComp
	Components.Add(SpinSoundComp)
}

But, if you want to play it constantly, right after the game starts, I suggest you to use this code instead, or you might encounter a bug, which mutes all sounds, until you restart UDK.


var(LZ_KActor, Sounds) SoundCue AmbientSound;
var AudioComponent AmbientSoundComp;

simulated function PostBeginPlay()
{
	SetTimer(0.05, False, 'CreateAmbientSound');
}

function CreateAmbientSound()
{
	if (AmbientSound != None)
	{
		If (WorldInfo.GetDetailMode() != DM_Low)
		{
			AmbientSoundComp = CreateAudioComponent(AmbientSound, true, true);
			if (AmbientSoundComp != None )
				AmbientSoundComp.bShouldRemainActiveIfDropped = true;
		}
	}
}

Oh Nice… It works!! Thank you very much!!!