Page 1 of 2

Message does not work when the node is active.

Posted: Fri Feb 04, 2022 2:14 pm
by EVG
Good afternoon. I want to send a message when the state of the node is active, but it does not send it (or does the listener not receive it?).
scr_01.png
scr_01.png (28.26 KiB) Viewed 1326 times
But for example, the activation of the game object, which is located in the same place, works correctly.
But if the message sending is created in the True state, that is, when the node is executed, the message sending works correctly.

Re: Message does not work when the node is active.

Posted: Fri Feb 04, 2022 2:26 pm
by Tony Li
Using the configuration in your screenshot, does the node deactivate 'CubeStairs' when it becomes active?

If so, then the Message action should also be sending the message. Make sure you have something that listens for the message = "Text", parameter = "Stairs".

Re: Message does not work when the node is active.

Posted: Fri Feb 04, 2022 3:10 pm
by EVG
Deactivation of "CubeStairs" works correctly.
Here's how I'm trying to listen to it:
scr_02.png
scr_02.png (26.21 KiB) Viewed 1319 times
And here is the debug method, which is not called.:
scr_03.png
scr_03.png (12.22 KiB) Viewed 1319 times

Re: Message does not work when the node is active.

Posted: Fri Feb 04, 2022 3:14 pm
by Tony Li
Hi,

Good, since deactivation of "CubeStairs" works correctly, we know that Quest Machine is running the actions.

Is the Message Events component on CubeStairs? If so, then because you've deactivated the GameObject it won't receive the message. If this is the case, try moving the Deactivate action after the Message action.

Re: Message does not work when the node is active.

Posted: Fri Feb 04, 2022 3:18 pm
by EVG
I tried to do with different objects, and without the deactivation action, it did not help.
Sending a message does not work only in the Active state, in the True state the message is sent successfully.

Re: Message does not work when the node is active.

Posted: Fri Feb 04, 2022 3:26 pm
by Tony Li
Quest Machine does not handle actions differently in those states. Can you send a reproduction project to tony (at) pixelcrushers.com?

Re: Message does not work when the node is active.

Posted: Sat Feb 05, 2022 12:36 pm
by Tony Li
Thanks for sending the reproduction project.

The issue in the reproduction project is that the quest becomes active before the Message Events component's OnEnable() method has run and registered to listen for the message.

If you temporarily tick the Quest Machine GameObject's Debug Settings > Debug and Debug Message System checkboxes, you may see this line in the Console:

MessageSystem.SendMessage(sender= target=: Send,Hello)

before this line:

MessageSystem.AddListener(listener=CubeQuestMessageEvent (PixelCrushers.Wrappers.MessageEvents): Send,Hello)


As a test, try this:

1. Set the FakePlayer GameObject inactive.

2. Play the scene in the editor's play mode.

3. Manually activate the FakePlayer GameObject.

This should work. You should see that MessageSystem.AddListener() occurs before MessageSystem.SendMessage().


One way to resolve this in your project is to activate the quest after the scene has started, or at least after Awake() and OnEnable() methods have run. Set the quest asset's state to Waiting To Start. Start the quest either in script or using a component such as TimedEvent:

startFakePlayerQuest.png
startFakePlayerQuest.png (51.14 KiB) Viewed 1306 times

Re: Message does not work when the node is active.

Posted: Sat Feb 05, 2022 1:30 pm
by EVG
Thanks for the answer. But what if I have a lot of quests that must be activated at the start? For each of them to start the timer?
Is it possible to change the code of the quest component so that it is activated after registering the event system?

Re: Message does not work when the node is active.

Posted: Sat Feb 05, 2022 2:22 pm
by Tony Li
If all of those quests are assigned to your Quest Journal component, you could leave the Quest Journal component inactive at design time and activate it after one frame using a Timed Event component.

Re: Message does not work when the node is active.

Posted: Sat Feb 05, 2022 2:39 pm
by EVG
Tony Li wrote: Sat Feb 05, 2022 2:22 pm If all of those quests are assigned to your Quest Journal component, you could leave the Quest Journal component inactive at design time and activate it after one frame using a Timed Event component.
It didn't work