Forum rules - please read before posting.

scripting with usage of current active conversation

I'm trying to create the following while talking an npc.
when a the player needs to choose a dialogue option, instead of the normal menu, object will be spawned near the player and the player will need to click on the object that correspond with the dialogue option that s\he wants.

I tried doing that by trying to find what conversation is active now, but I can't find it in the docs. I tried linking the script with the ui (by searching for dialoguelist) but i can't make that work as well.

the question:
How do i get a list of dialogue options with all their properties? (while the player is asked with a question in a conversation)

Comments

  • Welcome to the community, @ostrich.

    It's possible to read the active Conversation with:

    AC.KickStarter.playerInput.activeConversation
    

    (See the Scripting Guide entry here.)

    However, the "cleaner" way to perform code when a Conversation is made active is to hook into the OnStartConversation custom event.

    Either way, you can then read the Conversation class's options variable for a list of all dialogue options associated with it. For example, here's how you can generate an array of all option labels when a new Conversation begins:

    using UnityEngine;
    using AC;
    
    public class GetConversationLabels : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnStartConversation += OnStartConversation; }
        private void OnDisable () { EventManager.OnStartConversation -= OnStartConversation; }
    
        private void OnStartConversation (Conversation conversation)
        {
            string[] optionLabels = new string[conversation.options.Count];
    
            for (int i=0; i<conversation.options.Count; i++)
            {
                optionLabels[0] = conversation.options[0].label;
            }
        }
    
    }
    
  • Just what i needed, thank you Chris!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.