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) 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.
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).