Hi.
i am working on random conversation.
so i want to change a variable in my script before starting conversation.
eg. script chooses one of characters randomly, and then starts conversation of first choosen character.
so i want to set variable at each character. and dialoguesystemtrigger's condition checks the variable.
but in my scripts it doesn't work.
"
public void putCharacter()
{
PixelCrushers.DialogueSystem.DialogueLua.SetVariable("who", names[who]);
gameObject.GetComponent<DialogueSystemTrigger>().OnUse();
who++;
"
above is my code.
names[who] is first character's name.
i am confused what is wrong. please help me!
i can't change variable in script
Re: i can't change variable in script
Hi,
If you want to set a Dialogue System variable named "who", that code should work. To confirm, you can view the value of Variable["who"] in the Dialogue Editor's Watches tag at runtime.
I don't understand this part:
If you want to start a conversation from script, you can use DialogueManager.StartConversation(). Example:
If you want a Dialogue System Trigger to start a conversation, you can change its conversation, conversationActor, and conversationCovnersant properties before using OnUse():
If you want to change the name used by an actor, such as the Player actor, before starting a conversation, set its Display Name field:
If you want to set a Dialogue System variable named "who", that code should work. To confirm, you can view the value of Variable["who"] in the Dialogue Editor's Watches tag at runtime.
I don't understand this part:
How does the variable "who" relate to starting a conversation?
If you want to start a conversation from script, you can use DialogueManager.StartConversation(). Example:
Code: Select all
DialogueManager.StartConversation("Title", actorTransform, conversantTransform);
Code: Select all
var dsTrigger = GetComponent<DialogueSystemTrigger>();
dsTrigger.conversation = "Title";
dsTrigger.conversationActor = actorTransform;
dsTrigger.conversationConversant = conversantTransform;
dsTrigger.OnUse();
Code: Select all
DialogueLua.SetActorField("Player", "Display Name", names[who]);
dsTrigger.OnUse();
Re: i can't change variable in script
Thanks for good solution!
i need variable because i wanted to shuffle randomly and start its own conversation of each characters.
but your solution looks better.
i start conversation with your code.
DialogueManager.StartConversation("Title"); (i think Transform is not necessary)
i want to start at first default conversation such as 'greeting'
and i tried to execute function putCharacter() by scene event at the end of conversation .
(you can see the picture1)
public void putCharacter()
{
title = names[who];
DialogueManager.StartConversation(title);
who++;}
it is the function.
but it says that another conversation is already active. (picture2)
what can i do? if i want to run some conversation by script right after previous conversation?
thanks always!
i need variable because i wanted to shuffle randomly and start its own conversation of each characters.
but your solution looks better.
i start conversation with your code.
DialogueManager.StartConversation("Title"); (i think Transform is not necessary)
i want to start at first default conversation such as 'greeting'
and i tried to execute function putCharacter() by scene event at the end of conversation .
(you can see the picture1)
public void putCharacter()
{
title = names[who];
DialogueManager.StartConversation(title);
who++;}
it is the function.
but it says that another conversation is already active. (picture2)
what can i do? if i want to run some conversation by script right after previous conversation?
thanks always!
- Attachments
-
- questions.png (96.43 KiB) Viewed 363 times
-
- questions2.png (46.91 KiB) Viewed 363 times
Re: i can't change variable in script
I recommend linking your 'greeting' conversation to a different conversation for each character. Add Conditions that check the "who" variable. Before starting the greeting conversation, set the "who" variable. In fact, you don't even need the "who" variable if you specify the conversant GameObject. Example:
Greeting Conversation:
Linked conversations:
Code: Select all
DialogueManager.StartConversation("Greeting Conversation", player.transform, adam.transform);
Greeting Conversation:
Linked conversations: