Best way to set model state?

Announcements, support questions, and discussion for the Dialogue System.
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Best way to set model state?

Post 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!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best way to set model state?

Post 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.
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: Best way to set model state?

Post 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"); 
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best way to set model state?

Post 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.
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: Best way to set model state?

Post 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?
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best way to set model state?

Post by Tony Li »

Like the C# SendMessage() method, it calls Bomb() on all scripts on the GameObject that have a Bomb() method.
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: Best way to set model state?

Post by fkkcloud »

Makes sense- very helpful -thank you!
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: Best way to set model state?

Post 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:
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best way to set model state?

Post 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);
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: Best way to set model state?

Post 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 879 times
Still no function call happened.. What am I missing here..? hmm
Post Reply