Forum rules - please read before posting.

How to make an image-based conversation system

Hey!

I'm trying to make dialogues in my game using only images. The player can choose a conversation option, which is an image, then as a response, images appear. I understand that it is possible to make conversation options that appear only as icons, but as far as I see the "play speech" dialogues are only text-based. For now I added simple sprites to the scene, that appear as responses to conversation options, but it seems like a wrong way to do it if I plan to make more complicated dialogues with multiple choices. I wonder if there is a way to do it so I don't have to manually turn on and off gameobjects after each response. Any help or suggestion is much appreciated!

Comments

  • AC's image-based Conversations are limited to the dialogue options presented on-screen - not the lines spoken by the characters themselves.

    The best way to make an image-based speech system would be to use custom scripting to hook into the OnStartSpeech custom event, extract the line's ID number (as generated by the Speech Manager after gathering text), and then use that to update a Graphic menu element's image based on that value.

    See the Manual's "Speech scripting" and "Custom events" chapters for more information, as well as this tutorial for a guided example for the event in question.

    You'd then probably want to create a data struct that associates textures with line IDs, which you can then use to update your Graphic element. For example:

    using UnityEngine;
    using System.Collections;
    using AC;
    
    public class SpeechIconExample : MonoBehaviour
    {
    
        [SerializeField] private SpeechIcon[] speechIcons;
    
    
        private void OnEnable ()
        {
            EventManager.OnStartSpeech += StartSpeech;
            EventManager.OnStopSpeech += StopSpeech;
        }
    
    
        private void OnDisable ()
        {
            EventManager.OnStartSpeech -= StartSpeech;
            EventManager.OnStopSpeech -= StopSpeech;
        }
    
    
        private void StartSpeech (AC.Char character, string lineText, int lineID)
        {
            Texture texture = GetIconTexture (lineID);
            if (texture != null)
            {
                Menu graphicMenu = PlayerMenus.GetMenuWithName ("SpeechMenu");
                MenuGraphic graphicElement = graphicMenu.GetElementWithName ("IconGraphic") as MenuGraphic;
                graphicElement.SetNormalGraphicTexture (texture);
                graphicMenu.TurnOn ();
            }
        }
    
    
        private void StopSpeech (AC.Char character)
        {
            Menu graphicMenu = PlayerMenus.GetMenuWithName ("SpeechMenu");
            graphicMenu.TurnOff ();
        }
    
    
        private Texture GetIconTexture (int lineID)
        {
            if (lineID >= 0)
            {
                foreach (SpeechIcon icon in speechIcons)
                {
                    if (icon.lineID == lineID)
                    {
                        return icon.texture;
                    }
                }
    
            }
            return null;
        }
    
    
        [System.Serializable]
        private struct SpeechIcon
        {
    
            public int lineID;
            public Texture texture;
    
        }
    
    }
    

    Where "SpeechMenu" and "IconGraphic" are the respective names of your Menu and Graphic element used to display the icons.

  • Thanks Chris! That helps a lot!

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.