Call custom actions without breaking default sequence

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
zarnes
Posts: 7
Joined: Fri Dec 29, 2017 9:36 am

Call custom actions without breaking default sequence

Post by zarnes »

Hi,

I'm currently working on a visual novel style game.
Sometimes I need to do custom actions, like change background, or do some others customs actions.
First I though that sequence could be perfect, with custom sequencer commands I could do whatever I like !
But as soon a I type a single letter in sequence field, the node is passed in a matter of milliseconds !
I later found that when I added something in this field, the default seqence was override, I now understand that it's not for customs action but for stylish purposes.
Then I tried the script field, but it's only for lua scripting. I could do something if the lua could call unity methods, but I really don't know lua and I didn't find anything interresting.
Finally I found the On Execute Event, but it's a special one, I can't call my function, I tried to make it static but no change.

At this point I'm a bit blocked, a bit of help could really boost my project :)
Thx for reading !
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Call custom actions without breaking default sequence

Post by Tony Li »

Hi,

The node passes immediately because the sequence only lasts for as long as all of its commands last.

In the Sequence field, use {{default}} to include the Dialogue Manager's Default Sequence.

The Dialogue Manager's Default Sequence starts as:

Code: Select all

Delay({{end}})
The Delay command tells the Dialogue System to delay for a duration based on the text length.

If you set a dialogue entry node's Sequence field to this:

Code: Select all

Camera(Closeup);
{{default}}
It is the same as this:

Code: Select all

Camera(Closeup);
Delay({{end}})
Let's say your player has a C# script with a method like this:

Code: Select all

public void DropEverything() {
    // Example. Your code here to make the player drop everything.
}
Then you can set up a Sequence like this:
  • Dialogue Text: "Here's everything I have."
  • Sequence:

    Code: Select all

    SendMessage(DropEverything); {{default}}
Or, if you want to delay 5 seconds instead of playing the Dialogue Manager's Default Sequence, use this:

Code: Select all

SendMessage(DropEverything); 
Delay(5)
The SendMessage command runs a method on any scripts on a GameObject. The method can accept no parameters or a string parameter.

Sequences are very useful. You can read more about how to write sequences here.
zarnes
Posts: 7
Joined: Fri Dec 29, 2017 9:36 am

Re: Call custom actions without breaking default sequence

Post by zarnes »

Ok, thanks a lot :D
I just found out how to add my function on the On Conversation Line with the Dialogue System Event Script.
So I now have 2 solutions.

As always thanks for your support !
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Call custom actions without breaking default sequence

Post by Tony Li »

Glad to help!
Post Reply