Can't access Audiocomponent.Isplaying() from server

Hello, I’ve been trying to get a very simple dialog system working for my AI, using an audiocomponent and a delay based on AudioComponent.IsPlaying()

I’ve gotton the replication to work on the clients so they can hear the bots talking, but the AmbientSound.Isplaying function always returns false on the server end, and the OnAudioFinished function is never called on the server.
However, when playing singleplayer, the IsPlaying() function returns properly and my OnAudioFinished is called just fine when the soundcue ends.
The bot itself is role_authority (checked with `log(role):wink: so everything in the bot should be exposed to the server, correct?

This is the relevant code in my Pawn class:


var AudioComponent AmbientSound;
var repnotify SoundCue AmbientSoundCue;
var bool Talking;

replication
{
	if(bNetDirty)
	AmbientSoundCue;
}

/**
* Check on various replicated data and act accordingly.
*/
simulated event ReplicatedEvent(name VarName)
{
	if (VarName == 'AmbientSoundCue')
	{	
		playAmbientSound(AmbientSoundCue);		
	}	
}

simulated function playAmbientSound(SoundCue NewSound)
{	
	AmbientSoundCue = NewSound;
	AmbientSound.Stop();
	AmbientSound.SoundCue = AmbientSoundCue;
	AmbientSound.OnAudioFinished=DoneTalking;
`log(AmbientSound.OnAudioFinished);
	`log(role);
	if(NewSound != None)
	{
		AmbientSound.play();
	}
	talking=true;
}

simulated function DoneTalking (AudioComponent AC)
{
	playAmbientSound(AmbientSoundCue);
	Talking=false;
	`log("I FINISHED TALKING");
}

The highlighted debug text above returns:


[0003.43] ScriptLog: test3.TheWorld:PersistentLevel.RCTBot_1.DoneTalking
[0003.43] ScriptLog: ROLE_AUTHORITY

So, the server has full authority over my bot, it verifies that OnAudioFinished has successfully been set to the correct function, but never calls. :frowning:

EDIT: Interestingly, even in multiplayer it is successfully returning the OnAudioFinished function:


[0005.59] ScriptLog: test3.TheWorld:PersistentLevel.RCTBot_5.DoneTalking
[0005.59] ScriptLog: ROLE_SimulatedProxy
[0005.59] ScriptLog: I FINISHED TALKING

But I have been unsuccessful in calling a server function to send the message from my SimulatedProxy that the audioclip has finished, or replicating a variable onto the server (since ReplicationEvent does not get called on servers). :frowning:

If it’s an actual dedicated server (not listen) then it does not do any rendering, graphics and sound wise. Since no player is actually sitting in front of the server and playing on that machine, it does not need to perform any sound/graphics operations. In other words sounds are not actually played on that server.
I guess you’ll have to use a timer instead.

Are you sure the second log is also from your server? Because it is no longer Role_Authority? Also it seems a bit weird that the time stamp (5.59) is the same for the three log statements (could make sense on the server since it basically finishes playing any sound immediately as they are never played anyways).

Err the second log is from the client connected to the dedicated server. They are all the same time because they are logged from the same function.

Yeah, I figured the sound functionality was missing because it was a server but I was hoping there would be an easier way to determine the length of a random sound other than creating an array and iterating through it.
I ended up simply creating an array of SoundCues, picking a random int from the array, then running a timer with AmbientSound.Soundcue.Duration to determine how long the (randomly picked) soundcue was for the talking. Hopefully somebody smarter than me could elaborate on a better method.