Timing issues regarding sequences & conversation flow

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Raidenthequick
Posts: 34
Joined: Mon Jul 02, 2018 5:00 pm

Timing issues regarding sequences & conversation flow

Post by Raidenthequick »

Hi Tony,

We are on Dialogue System 2.2.4. We are experiencing some strange timing issues in Dialogue System's sequencing / conversation flows. Adding Continue()@0.01's (for example) in certain spots DOES seem to fix the issue, but also this is not ideal.

What I believe is happening is something like this:

A Dialogue System trigger fires off, there is a "Play Sequence" field with some SetVariable commands AND some custom sequencer commands I made that also (eventually) set variables too (based on more complicated things, might take a little bit longer to run than the plain SetVariable commands). The problem is that these variables in the "Play Sequence" field NEED to be set first BEFORE the conversation even starts, or else they become out of sync, since the conversation has nodes with "[var=]" tags in it. So basically, these [var=] are showing up blank/wrong, since the Play Sequence SetVariable (and similar custom commands) aren't quite setting their variables in time before the [var=] tags get processed. My custom sequencer commands ARE calling "Stop();" at the proper time, i.e. the very end.

We've noticed similar issues when using Continue(); within conversations too, so this problem is not isolated purely to "Play Sequence" field. It can also happen mid-conversation, e.g. setting a variable in one node, then later doing [var=] in a future node, yet when I debugged the [var=] gets processed FIRST, THEN the SetVariable finally runs. Is there any way around this besides just random Continue()@0.01's? Seems very ugly to have to consider this in every possible spot in our game. Thanks!
User avatar
Tony Li
Posts: 21069
Joined: Thu Jul 18, 2013 1:27 pm

Re: Timing issues regarding sequences & conversation flow

Post by Tony Li »

Hi,

If possible, would you please update to version 2.2.5? It has a fix for some sequencer timing issues.

If that doesn't fix it, please let me know how to reproduce the issue. As a test, I edited DemoScene1. In Private Hart's Dialogue System, I configured the Play Sequence action to run:

Code: Select all

SetVariable(Nickname, buddy)
Then I set the first node to:
"Hey [var=Nickname], we need to get the launch codes..."

It correctly showed "Hey buddy, we need to get the launch codes..."
Raidenthequick
Posts: 34
Joined: Mon Jul 02, 2018 5:00 pm

Re: Timing issues regarding sequences & conversation flow

Post by Raidenthequick »

Actually, I should've been more specific that the regular built-in SetVariable commands seem to work fine, this problem is only occuring on my custom ones. Here is one that we make regular use of, try testing with this:

Code: Select all

namespace PixelCrushers.DialogueSystem.SequencerCommands
{
    //assigns a variable to the value of a field of an articy entity
    public class SequencerCommandSetVariableField : SequencerCommand {

		public void Start() {
            var varName = GetParameter(0);
            var entityName = GetParameter(1);
            var articyField = GetParameter(2);

            //fetch articy entity
            var entity = DialogueManager.MasterDatabase.GetItem(entityName );

            //fetch field type
            object fieldValue = "";
            var field = entity.fields.Find(f => f.title == articyField);

            //type of variable set depends on type of field
            switch (field.type)
            {
                case FieldType.Boolean:
                    fieldValue = entity.LookupBool(articyField);
                    break;
                case FieldType.Number:
                    fieldValue = entity.LookupInt(articyField);
                    break;
                default:
                    fieldValue = entity.LookupValue(articyField);
                    break;
            }

            //set variable
            DialogueLua.SetVariable(varName, fieldValue);
            Stop();
		}
	}
}
You'll need to pass into it 1) a variable name, make sure it exists in your database, 2) an Item name, make sure that exists too, 3) a field on that Item, make sure the field exists on the Item you pass in.

Try seeing if there's any difference with this command vs. the built-in one. In the meantime I'll try updating to 2.2.5, thanks!
User avatar
Tony Li
Posts: 21069
Joined: Thu Jul 18, 2013 1:27 pm

Re: Timing issues regarding sequences & conversation flow

Post by Tony Li »

Hi,

Start() happens at the beginning of the next frame, which is right after [var=variable] is evaluated. Please try changing that method to Awake().
Raidenthequick
Posts: 34
Joined: Mon Jul 02, 2018 5:00 pm

Re: Timing issues regarding sequences & conversation flow

Post by Raidenthequick »

Thanks, that seemed to fix it!

I hadn't seen Awake being used anywhere in the docs or anything, so hadn't even considered it. Is it best practice to use Awake in general for seq commands? Since things fire a little faster.
User avatar
Tony Li
Posts: 21069
Joined: Thu Jul 18, 2013 1:27 pm

Re: Timing issues regarding sequences & conversation flow

Post by Tony Li »

Yes, generally use Awake() unless you need to run a coroutine. If you need a coroutine, use Start().
Post Reply