- Home /
Dialogue that changes with instances / occurences
So I'm making a simple game in which you talk to characters and "give them objects", which are not 3D objects or game objects, just imaginary, spoken about in the dialogue. However, if you don't talk to people in the right order, you can't progress in the game, because you have to find the person who has an item that someone else will want. Does this make sense? I'm just trying to program the dialogue so that, once a character has talked to the correct person, they will "gain an item" and when they talk to the next person, they will have a new choice in the dialogue, which allows them to "give the item." Is this possible with any dialogue generators, and how can I do this?
Your help would be much appreciated!!!
Answer by Statement · Dec 15, 2010 at 03:45 AM
So I'm making a simple game in which you talk to characters and "give them objects", which are not 3D objects or game objects, just imaginary, spoken about in the dialogue.
Ok, I guess you can get away with text. "A comb." or "A pair of scissors."
However, if you don't talk to people in the right order, you can't progress in the game, because you have to find the person who has an item that someone else will want. Does this make sense?
Yes. John needs a comb and will give you a pair of scissors for the exchange. Sarah need scissors for you to complete the game.
I'm just trying to program the dialogue so that, once a character has talked to the correct person, they will "gain an item" and when they talk to the next person, they will have a new choice in the dialogue, which allows them to "give the item."
Okay you need to keep a game state. Basically each person has a request and give something in return. The player can carry one or several of these objects (texts). Its easily set up with an enumeration.
public enum Items { Comb, Scissors, EndOfGame }
public class Person { public Player player; public Items request; public Items reward;
public string requestDialogue;
public string rewardDialogue;
bool isDialogueOpen = false;
bool isRewardGiven = false;
void OnGUI()
{
if (isDialogueOpen == false)
return;
if (isRewardGiven)
{
// display gui like "oh thanks so much" using rewardDialogue
}
else
{
// display gui like "i need this and that" using requestDialogue
if (player.Has(request))
{
if (GUILayout.Button("Give blah to person"))
{
player.Give(reward);
isRewardGiven = true;
}
}
}
}
}
public class Player { private List<Items> items = new List<Items>();
public bool Has(Items item) { return items.Contains(item); }
public void Give(Items item) { items.Add(item); if (item == Items.EndOfGame) { // game completed } } }
Is this possible with any dialogue generators, and how can I do this?
Your help would be much appreciated!!!
I don't know of any "dialogue generators" but you can do this pretty easily yourself.
I'm sorry I can't write an entire game for you.
The script won't work by itself.
You have to fix the obvious parts.
Answer by LeiterJakab · Nov 01, 2010 at 11:17 PM
If I understand your question correctly than you simply have to set a boolean variable true when the plyaer starts the dialogue and when they start the next one you check for that variable and initiate the dialogue based on whether it's true or false.
You could add a collider component to the player controller and set it to be a trigger. Than you could add a script like this to the player controller gameobject.
I'm not sure if this is what you were asking for. I would make the dialogue itself with GUI scripting. Here are some links that might help:
GUI Scripting Guide more on GUI Unity Scripting Reference
private var mirror : boolean = false;
function OnTriggerEnter (collisionInfo : Collider) { if (collisionInfo.name == John) { //script of dailogue here mirror = true; }
if (collisionInfo.name == Julia)
{
if (mirror == true)
{
//script dialogue alternative 1
}
else
{
//script diaolgue alternative 2
}
}
}
Thanks for your reply! So, where should I put this script? And when you say "something else", what would go there?
Your answer
![](https://koobas.hobune.stream/wayback/20220613081623im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make dialogue in Unity3D? 2 Answers
Dialogue Code 0 Answers
Auto-type text does not change to the next sentence 1 Answer
How can i create a conversion like whatsapp in unity3d 0 Answers
Need help with dialogue system script 0 Answers