Hi Chris,
dialogue options have the nice feature "Only show if carrying specific inventory item?". Would it be a lot of work to implement a "Only show if specific variable has a certain value?" option to the dialogue options?
Most dialogue options in our game are only visible if a specific variable is true or a counter of an integer has a defined value and the preparing action lists of these conversations can get quite extended because of this. This amount of work could be drastically reduced by having such an option.
MAC
Comments
I can appreciate your situation, however. In this case, I'd say it's best to script it, which is quite simple because of AC's API. Here's an example script named "ConversationVariables":
using UnityEngine;
using System.Collections;
using AC;
public class ConversationVariables : MonoBehaviour
{
public Conversation conversation;
public void PrepareConversation ()
{
// Set option 0 according to Global boolean 2 being True
bool option0IsOn = GlobalVariables.GetBooleanValue (2);
conversation.SetOptionState (0, option0IsOn, false);
// Set option 3 according to Global integer 5 being 10
bool option3IsOn = (GlobalVariables.GetIntegerValue (5) == 10);
conversation.SetOptionState (3, option3IsOn, false);
}
}
Then, place the script on an empty GameObject in your scene, assign the Conversation / tweak the code to suit, and then call the PrepareConversation function using the Object: Call event Action before your Dialogue: Start Converasation Action.
Thanks for the script. This feature would be great, as I need now need it as well
Hi,
I think this is how I want to approach my character's knowledge of the environment as it allows me to control dialogue options from a variety of sources in a central place.
Recently a Variable Component was introduced. What would the script reference to a variable component look like? The examples I've seen show Global and Local variables, but not Variable Components.
E.g.
I have a DetectiveKnows GameObject with Variables (Script) attached to it.
Component 0: CoffeeMachineBroken is a boolean
Should it be something similar to:
gameObject.Variables.GetBooleanValue(0)
?See the Scripting Guide's entry on the Variables class here.
In your example, the correct code would be:
Since my first post in this thread, AC now offers the OnStartConversation custom event, which can be used to run initialisation code automatically (no need to call "PrepareConversation" manually).
The updated equilvalent of the above script would now be: