Message does not work when the node is active.

Announcements, support questions, and discussion for Quest Machine.
EVG
Posts: 27
Joined: Sun Jul 04, 2021 4:55 pm

Message does not work when the node is active.

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

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

Post 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".
EVG
Posts: 27
Joined: Sun Jul 04, 2021 4:55 pm

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

Post 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 1317 times
And here is the debug method, which is not called.:
scr_03.png
scr_03.png (12.22 KiB) Viewed 1317 times
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
EVG
Posts: 27
Joined: Sun Jul 04, 2021 4:55 pm

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

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

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

Post by Tony Li »

Quest Machine does not handle actions differently in those states. Can you send a reproduction project to tony (at) pixelcrushers.com?
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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 1304 times
EVG
Posts: 27
Joined: Sun Jul 04, 2021 4:55 pm

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

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

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

Post 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.
EVG
Posts: 27
Joined: Sun Jul 04, 2021 4:55 pm

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

Post 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
Post Reply