Page 1 of 1

Speaker Sequencer Command Returning Null

Posted: Wed Jun 10, 2020 7:12 pm
by dbclutis
Hello again!

I'm trying to use sequencer code to reference my speaker, and it looks like this:
Sequence Speaker.JPG
Sequence Speaker.JPG (12.1 KiB) Viewed 459 times
The problem is, despite that my speaker exists as well as this field, I am receiving that this subject is null:
Error Speaker.JPG
Error Speaker.JPG (10.89 KiB) Viewed 459 times
Am I doing this right? I will trace back over all my variables again in a little bit to make sure I didn't make any small mistakes, but I wanted to check with you to make sure this is even the correct format.

Thanks,
DC

Re: Speaker Sequencer Command Returning Null

Posted: Wed Jun 10, 2020 8:46 pm
by Tony Li
Hi,

Variable["ActorIndex"] is the Actor[] table index of the conversation's actor. If the conversation's conversant or another character is speaking a particular dialogue entry, Variable["ActorIndex"] won't match the speaker.

You can add a Lua Console component to your scene and press ~+L to open it when that dialogue entry is visible. Then enter:

Code: Select all

return Variable["ActorIndex"]
to see its current value. You can also enter:

Code: Select all

return Actor[Variable["ActorIndex"]].CurrentVNLocation
to see what the field's value is. The value should match the name of a GameObject in the scene.

BTW, to reference the speaker's GameObject, you can just do:

Code: Select all

AnimatorPlay(Talk, speaker)
Or, since speaker is the default value for the second parameter, this is the same as:

Code: Select all

AnimatorPlay(Talk)
If the speaker's actor name doesn't match the GameObject name, add a Dialogue Actor component to the GameObject and select the actor it's associated with.

If you don't want to use a Lua Console component, you can enter those Lua expressions into the bottom bar of the Dialogue Editor's Watches page.

Re: Speaker Sequencer Command Returning Null

Posted: Wed Jun 10, 2020 9:11 pm
by dbclutis
Ok that is all very helpful! I will certainly be using the Lua console in the future!

So there is no way to access the current speaker actor fields directly from the lua code? The way I have my system set up, this would be very helpful to me, but if I need to find a work around, that is no problem!

Thanks,
-DC

Re: Speaker Sequencer Command Returning Null

Posted: Wed Jun 10, 2020 9:20 pm
by Tony Li
That's correct. Of course, if you know the speaker ahead of time, you can always include the speaker's actor name explicitly:

Code: Select all

AnimatorPlay(Talk, [lua(Actor["Bob"].CurrentVNLocation)])

Re: Speaker Sequencer Command Returning Null

Posted: Wed Jun 10, 2020 9:27 pm
by dbclutis
Understandable!
I will look into a work around tomorrow!

As always, thanks for the quick responses :D
-DC

Re: Speaker Sequencer Command Returning Null

Posted: Wed Jun 10, 2020 9:58 pm
by Tony Li
Glad to help. You could always write a custom sequencer command. In your custom sequencer command, you can get the current speaker's actor name like this:

Code: Select all

string speakerActorName = DialogueManager.currentConversationState.subtitle.speakerInfo.nameInDatabase;
Then you can get that actor's field(s):

Code: Select all

string currentVNLocation = DialogueLua.GetActorField(speakerActorName, "CurrentVNLocation");