How to get Layered Character's OnStartedSpeaking and OnFinishedSpeaking to work?

Using Naninovel C# APIs: adding custom actor implementations or commands, overriding engine services, integrating with other systems, etc.
Post Reply
ville.helin
Posts: 2
Joined: 21 Aug 2021 16:47

How to get Layered Character's OnStartedSpeaking and OnFinishedSpeaking to work?

Post by ville.helin »

Hi!

I'm adding custom objects + code that basically run lip sync animations and analyses the currently playing audio sample to a project that is built using Naninovel. Currently I've added OnStartedSpeaking and OnFinishedSpeaking callbacks to a LayeredCharacterBehaviour, but what happens in that when a character starts to speak OnFinishedSpeaking is called right away and that's it.

What do I need to do / where to look to make both OnStartedSpeaking and OnFinishedSpeaking to work properly? :)

ville.helin
Posts: 2
Joined: 21 Aug 2021 16:47

Re: How to get Layered Character's OnStartedSpeaking and OnFinishedSpeaking to work?

Post by ville.helin »

Problem solved! The reason why OnStartedSpeaking was not called was that the LayeredCharacter wasn't set as author.

This didn't work:

@print "Hello World" wait:false

... but what worked was

@print "Hello World" wait:false author:Eve

There still are two problems in our case:

  1. OnFinishedSpeaking is called first, before any OnStartedSpeaking is called - logic error. We could work around this in our custom code...
  2. Naninovel<Runtime>/AudioController has two AudioSources:
    • One for the character's speech
    • One for "text_bleed" sound
      As I attach my script that has OnAudioFilterRead() to that AudioController object, we get this error in the Console:
      "GameObject has multiple AudioSources and/or AudioListeners attached. While built-in filters like lowpass are instantiated separately, the custom script DSP filter components may only be used by either one AudioSource or AudioListener at a time."
      ... Still everything works, but it would be nice if "text_bleeb" had its own GameObject...
idaot
support
Posts: 275
Joined: 01 Aug 2020 08:25

Re: How to get Layered Character's OnStartedSpeaking and OnFinishedSpeaking to work?

Post by idaot »

1) I am not getting this error, tested with the latest pre-release. Make sure the callback is set up correctly. I used this script:

Code: Select all

void Start()
    {
        GetComponent<Naninovel.LayeredCharacterBehaviour>().OnIsSpeakingChanged += IsSpeaking;
    }

private void IsSpeaking(bool speaking)
{
    if (speaking)
    {
        Debug.Log(true);
    }
    else
    {
        Debug.Log(false);
    }
}

2) Under the character configuration, there is a field called Voice Source in which you can add an Audio Source object which will be instantiated under the character object during runtime. This object can be accessed via GetConfiguration<CharactersConfiguration>(). More information on accessing configuration objects can be found here: https://naninovel.com/guide/custom-conf ... figuration

AmberRose
Posts: 8
Joined: 22 Jan 2022 01:40

Re: How to get Layered Character's OnStartedSpeaking and OnFinishedSpeaking to work?

Post by AmberRose »

I actually have the same problem. I set the animation to start under the finish speaking command, and stop on the start command. Just as a temporary workaround, but hoping to find the source of the issue soon.

idaot
support
Posts: 275
Joined: 01 Aug 2020 08:25

Re: How to get Layered Character's OnStartedSpeaking and OnFinishedSpeaking to work?

Post by idaot »

The problem is probably to do with the animation, not Naninovel. The callback works correctly. If you are using Animator, be sure to check tutorials as there are state settings you have to be mindful of when setting them up.

Post Reply