Page 1 of 1
"Required Target" not working when Message sent with "Target ID" set
Posted: Wed Apr 27, 2022 4:13 pm
by mroshaw
Sorry, me again!
I have "Message Events", "Dialogue System Quest Giver" and "Dialog Actor" components set up on my NPC. In the "Dialog System Quest Giver" component, I've configured:
In "Message Events", I've created an entry:
Code: Select all
Required Sender: None
Required Target: (I've dragged my NPC Game Object here, with "Dialog System Quest Giver in the root of the GO)
Message: Quest Target Start
On Message (MessageArgs): AnEventHandler
In the "Success" node of my Quest, I have an entry under the "Start" node, "Active" state, Actions:
Code: Select all
Message
Sender: Quest Giver
Target: Other
Target ID: NpcId
Message: Quest Target Start
When I run the scene and accept the Quest, the event code does not run. If I remove the "Required Target" from the "Message Events" component, the event code DOES run.
I just want the Message to be picked up by the "target" NPC - am I doing something wrong?
Thanks once again!
Re: "Required Target" not working when Message sent with "Target ID" set
Posted: Wed Apr 27, 2022 9:03 pm
by Tony Li
Hi,
I'm not sure how to reproduce this. Can you please send a
reproduction project to tony (at) pixelcrushers.com?
Working in the Demo scene, I added this action to the "Pesky Rabbits" quest's Success node:
- requiredTarget1.png (55.45 KiB) Viewed 1108 times
And I added this MessageEvents to the Villager:
- requiredTarget2.png (31.4 KiB) Viewed 1108 times
I also added a similar MessageEvents to the Knight but set its Required Target to Knight.
Upon completing the Pesky Rabbits quest, the Villager's TestQM.Report() method ran.
Re: "Required Target" not working when Message sent with "Target ID" set
Posted: Thu Apr 28, 2022 3:37 am
by mroshaw
Thank you so much again, Tony.
I think what I find confusing is that "Required Target" is a Game Object, while "Target ID" is effectively a string. The "Required Target" tooltip suggests something about the Game Object needing a "Quest Giver" or "Element" component, but no other hint as to what "connection" there needs to be between the GO and string.
So, I'm assuming (perhaps incorrectly?) that the "Target ID" string needs to equal the string of the "Id" of the "(Dialogue System) Quest Giver". What I don't quite understand if this is the case, is that the "Element" component has no such ID - so not sure how the "Target ID" gets associated to that "Element" component.
Can you clarify exactly how these two reconcile?
Many thanks again!
Re: "Required Target" not working when Message sent with "Target ID" set
Posted: Thu Apr 28, 2022 8:20 am
by mroshaw
Just to add, I've created a debugging script and if I use the API, which takes an Object for Target rather than a string, then it works:
Code: Select all
MessageSystem.SendMessageWithTarget(this, targetObject, messageToSend, String.Empty, null );
So, I guess I'm still confused as to how the "Message" Quest Action interprets it's string input for "Target ID" and translates that into the underlying API call that requires an Object.
Re: "Required Target" not working when Message sent with "Target ID" set
Posted: Thu Apr 28, 2022 8:24 am
by mroshaw
Unless I'm totally overthinking this, and the "Target ID" is simply the name of the Game Object?!
Re: "Required Target" not working when Message sent with "Target ID" set
Posted: Thu Apr 28, 2022 8:27 am
by Tony Li
Yes, you're correct -- the Message Quest Action's Target ID should match the target's GameObject name. This is the closest equivalent to assigning the GameObject itself, which you can't do because the quest asset exists separately from the scene.
The next Quest Machine update will introduce a Quest Machine Message Events component (a subclass of Message Events) that will also match the Target ID to the target's Quest Machine ID. To associate a Quest Machine ID with a GameObject, add one of these components: (Dialogue System) Quest Giver, Quest Journal, or Quest Machine ID. (Quest Machine ID is a simple component whose only purpose is to associate an ID with the GameObject.)
Re: "Required Target" not working when Message sent with "Target ID" set
Posted: Thu Apr 28, 2022 10:28 am
by mroshaw
Amazing, thank you! I was totally overthinking things! Working just the way I want it now, awesome!
Re: "Required Target" not working when Message sent with "Target ID" set
Posted: Thu Apr 28, 2022 10:56 am
by Tony Li
Great! Happy to help.