Page 1 of 2

Best way to set model state?

Posted: Tue Oct 06, 2020 2:21 pm
by fkkcloud
Hi,

I am changing 3 things based on each dialogue node.
1. Animator' animation of 3d model
2. Facial expression - I have a custom component that sets "angry"/"smile" etc
3. Additional emote fx - sweat, exclamation mark and etc

What is the best way to implement these in Dialogue System? I didn't find any tutorial for it so wanted to get it right from the start. Let me know if I have missed any good resources that are already available!

Re: Best way to set model state?

Posted: Tue Oct 06, 2020 2:36 pm
by Tony Li
Hi,

Cutscene sequences were designed for that. (Tutorial series)

Sequences are very flexible and have a lot of options, including shortcuts and custom sequences. If you have any questions, just let me know.

Re: Best way to set model state?

Posted: Tue Oct 06, 2020 3:43 pm
by fkkcloud
Great- Watching through it and I love the ideas/implementations.

One quick question-
Would Message "Done" or any custom message from Node can be propagated to the regular script? so I can subscribe?
Like opposite way of

Code: Select all

PixelCrushers.DialogueSystem.Sequencer.Message("TouchedPlatform"); 

Re: Best way to set model state?

Posted: Tue Oct 06, 2020 4:08 pm
by Tony Li
No, to send a message to a script, use the SendMessage() sequencer command, which works like the C# SendMessage() method:

Sequence:

Code: Select all

SendMessage(Explode,,Bomb)
C# script on GameObject named "Bomb":

Code: Select all

public class Bomb : MonoBehaviour
{
    public void Explode() { ... }
}
Or you can write a custom sequencer command. For example, the Dialogue System's PlayMaker integration adds a custom sequencer command that sends a message to a PlayMaker FSM.

Re: Best way to set model state?

Posted: Tue Oct 06, 2020 4:41 pm
by fkkcloud
Great.
So youi said that the third argument of SendMessage(functionname, ,Bomb) is the game object's Name but also you stated Bomb Class as well.
Is third argument is going to be Specific game object with the Class in the scene? or Game Object with the name?
Would it send to all the GameObject with the name + GameObject with the component?

Re: Best way to set model state?

Posted: Tue Oct 06, 2020 4:52 pm
by Tony Li
Like the C# SendMessage() method, it calls Bomb() on all scripts on the GameObject that have a Bomb() method.

Re: Best way to set model state?

Posted: Tue Oct 06, 2020 5:07 pm
by fkkcloud
Makes sense- very helpful -thank you!

Re: Best way to set model state?

Posted: Wed Oct 07, 2020 6:46 am
by fkkcloud
I've called

Code: Select all

AudioWait(VA/test/test_v02);
AnimatorTrigger(Idle);
SendMessasge(SendMsgText, ,EmotionAnimator);
and I have a script

Code: Select all

public class EmotionAnimator : MonoBehaviour
{
    public void SendMsgText()
    {
        Debug.Log("test");
    }
}
I've tested attaching the component to the NPC or Dialogue Manager as well.
None worked. (which gameobject should I attach it to btw?)

Let me know what I am missing! :shock:

Re: Best way to set model state?

Posted: Wed Oct 07, 2020 9:44 am
by Tony Li
The third parameter to the SendMessage() sequencer command must be a GameObject name or the special keyword 'speaker' or 'listener'. For example, if your NPC's GameObject is named "NPC X", then use:

Code: Select all

SendMessasge(SendMsgText, , NPC X);

Re: Best way to set model state?

Posted: Wed Oct 07, 2020 2:36 pm
by fkkcloud
Any GameObject in the scene, right?

In the Dialogue Node Seqeunce Command textfield.

Code: Select all

SendMessasge(SendMsgText, ,Yuna_3P);
Code that is attached to Yuna_P

Code: Select all

public class EmotionAnimator : MonoBehaviour
{
    public void SendMsgText()
    {
        Debug.Log("test");
    }
}
GameObject Inspector V
kkkk.png
kkkk.png (82.83 KiB) Viewed 883 times
Still no function call happened.. What am I missing here..? hmm