Hello, i am very new to Dialogue System and so far i've really enjoyed it.
Right now I am trying to implement my own scripts in my game, tied with dialogue system.
I found a way to call a script from a different gameobject, using the event system. Here I am trying to send the message "2" to my PhoneInt script, linked to the Rectangle02 gameobject
My console log displays "SendMessage 2 has no receiver", implying that sending isn't the problem.
However, I fail to find a way to get that message in any way. Should I create a function inside my script that will automatically be called, or is it supposed to be used through the System Dialogue interface?
I am also open to any other solution to implement my scripts, especially if it also properly covers specific end-of-dialogue events.
Sorry if the answer is obvious, but I couldn't understand how to use sendMessage from its documentation page.
How to use sendMessage?
Re: How to use sendMessage?
Hi,
Thanks for using the Dialogue System!
What do you want to accomplish? (What's your end goal with the script?)
The SendMessage() sequencer command may or may not be the best way to get there.
Thanks for using the Dialogue System!
What do you want to accomplish? (What's your end goal with the script?)
The SendMessage() sequencer command may or may not be the best way to get there.
Re: How to use sendMessage?
Thanks for the reply.
This particular script is meant to change the material of the gameObject when hovering the mouse over it. It gives off a highlight to indicate that you can interact with it, opening a dialogue.
I initially wanted to use both separately, my script to highlight and the dialogue system. However I couldn't make the dialogue system's "usable" work on a mesh other than a cube, so I created a invisible cube instead. But then both hitboxes collide with each other, and my gameObject cannot detect the OnMouseEnter.
On the long term, I will also want to call different scripts for various actions at the end of dialogues, such as NPC movements and global variable manipulations. So even if there is a work-around solution for my particular problem, I would prefer to learn how to properly use the tools of Dialgue System.
This particular script is meant to change the material of the gameObject when hovering the mouse over it. It gives off a highlight to indicate that you can interact with it, opening a dialogue.
I initially wanted to use both separately, my script to highlight and the dialogue system. However I couldn't make the dialogue system's "usable" work on a mesh other than a cube, so I created a invisible cube instead. But then both hitboxes collide with each other, and my gameObject cannot detect the OnMouseEnter.
On the long term, I will also want to call different scripts for various actions at the end of dialogues, such as NPC movements and global variable manipulations. So even if there is a work-around solution for my particular problem, I would prefer to learn how to properly use the tools of Dialgue System.
Re: How to use sendMessage?
Hi,
The Dialogue System offers several options, allowing you to choose the one that best fits your needs.
For the highlight, you'll almost certainly want to hook it up to the Usable's OnSelect() and OnDeselect() UnityEvents.
For general script interaction, if you want something to happen at the start or end of a conversation, add a Dialogue System Trigger, and set the dropdown to OnConversationStart or OnConversationEnd. Then select Add Action > OnExecute() Event, and configure the UnityEvent to call your script method(s).
Within a conversation, you have three options:
1. If your script method accepts zero parameters or one string parameter, you can use the SendMessage() sequencer command. For example, say you have a GameObject named "Force Field". It has a script with a method "PowerUp()". You can call PowerUp() in a dialogue entry node by setting the node's Sequence field to:
(Above, the middle of the three arguments to SendMessage is blank because PowerUp() accepts no parameters.)
2. You can also write your own custom sequencer commands to use in the Sequence field. They're pretty easy to write, and the Dialogue System includes a thoroughly-commented starter template script.
3. You can also register your own methods with Lua and call them in nodes' Conditions and Script fields. The Dialogue System also includes a thoroughly-commented starter template script.
The Dialogue System offers several options, allowing you to choose the one that best fits your needs.
For the highlight, you'll almost certainly want to hook it up to the Usable's OnSelect() and OnDeselect() UnityEvents.
For general script interaction, if you want something to happen at the start or end of a conversation, add a Dialogue System Trigger, and set the dropdown to OnConversationStart or OnConversationEnd. Then select Add Action > OnExecute() Event, and configure the UnityEvent to call your script method(s).
Within a conversation, you have three options:
1. If your script method accepts zero parameters or one string parameter, you can use the SendMessage() sequencer command. For example, say you have a GameObject named "Force Field". It has a script with a method "PowerUp()". You can call PowerUp() in a dialogue entry node by setting the node's Sequence field to:
Code: Select all
SendMessage(PowerUp, , Force Field)
2. You can also write your own custom sequencer commands to use in the Sequence field. They're pretty easy to write, and the Dialogue System includes a thoroughly-commented starter template script.
3. You can also register your own methods with Lua and call them in nodes' Conditions and Script fields. The Dialogue System also includes a thoroughly-commented starter template script.
Re: How to use sendMessage?
Thanks a lot for your answer, I made it work perfectly fine using OnSelect(), I just needed to grasp the way this all works.