If you assing a new behaviour dialogTreeController.behaviour = tree;
1st.
The TreeController receives a copy of the tree, not the same object. It’s copied over via serialization. Somehow any IDialogueActors that are not assigned via the Editor are lost on the way. Most likely because it’s serialization state when starting the dialogue is from before the assignment.
2nd.
Because of that, you have to actually assign any actor reference after the call to StartDialog and to the behaviour member of the controller itself.
Hello and very sorry for late reply due to summer vacation!
Yes, that is correct. Indeed, a copy of the original asset (Dialogue Tree in this case) is instantiated as soon as the Dialogue starts, if the dialogueTreeController.behaviour is not already an instance previously created.
Thus, the correct way of setting the actor references or altering the dialogue tree in any other way, would be what you came up doing :). You can also replace this, dialogTreeController.behaviour.SetActorReference(“Other”, other);, directly with this dialogueTreeController.SetActorReference("Other", other). Of course after you call “StartDialogue” like you do first.
I could also probably add a new method override like DialogueTreeController.StartDialogue(DialogueTree tree, IDialogueActor instigator, Action<bool> callback, so that you both set and start a new tree with one call for more convenience.
the thing is, that when you alter the original behaviour asset right before you start it, one expects it to have the changes in the new instance. But it is not. If thats intended behaviour that I should not be allowed to set the actor reference on the asset through code, only on the instance. Or it should prompt a warning at least.
I think it’s pretty weird that it was deserialized from a previous, outdated state.
Not sure about the callback idea, I think that’s even more non-intuitive, but thats propably just because I come from a c++ background. 😉
I missed at that point a way to start the DialogueTree AND pass the actor referecens at the same time.
Something like: DialogueTreeController.StartDialogue(DialogueTree tree, IDialogueActor instigator, ("actorRef1", actorRef1), ("actorRef2", actorRef2), ..)
The Actor references in the DialogueTree Asset, are correctly set and when the dialogue is started, the assignment remains.
Hmm. can you confirm that when you call SetActorReference, the reference is indeed assigned/set correctly in the DialogueTree asset itself?
Thank you.
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.