Forum rules - please read before posting.

Conversation - How could NPC dialogue be displayed in 3D world space above the character?

edited June 2018 in Technical Q&A
Howdy,

The customisation questions doth continue!

In my original design I want to handle dialogue in two different ways when it comes to rendering:

- Dialogue from the player (things they say) and conversation choices they choose are on a 2D UI
- Dialogue and lines from any NPCs appear in 3D world space above the character in question

Could someone please give me some pointers as to how this would be workable alongside AC? My research so far has started to point towards switching over to use "Unity UI in scene" in various menus such as subtitles. So far I've managed to get the default subtitles to output to a Unity Canvas linked to different text objects so I think I'm starting to understand how you target AC bits at UI things.

In my original LD project I had a TextMeshPro object above the NPCs and fed the string into the text object. Could the same thing work here?

Thanks!
Tem

Comments

  • Delving into this a bit more, I've noticed that the 'linked text' can only be passed something with a text component. Is there a way of extending / alterting this to accept Text Mesh Pro objects?
  • "Unity Ui In Scene" is generally the best way to hook up "world space" Canvases.  Subtitle menus can also be configured to only display / not display for certain characters - so you can create one for NPCs and another for the Player within the Menu Manager's properties.

    There isn't a need for TMPro just to get World-Space Text connected with AC, but a Text component is required.  What you can do, however, is rely on a "dummy" Text component and have TMPro use it as a reference - see the wiki entry here: http://adventure-creator.wikia.com/wiki/Text_Mesh_Pro_integration

  • edited June 2018
    Hi Chris,

    I've got the subtitle menu configuration for certain chracters working, so that's great (well, one for the player and then 'all except specific characters'). Seems to do the job! Another really useful feature.

    I had a look at the text mesh pro integration page.

    There is a point there which says:

    Each label you want to replace with TMPro will need both a Unity UI Text component, and a Text Mesh Pro UGUI component.  The Text component can be hidden or given an invisible colour, but should not be disabled.

    I'm interpreting that as I need a gameobject with both those components on. However in Unity I'm unable to add a dummy text component to a text mesh pro object:




    Where abouts am I going wrong in this process?
  • edited June 2018
    Actually, another useful thing to know would be is there a variable in script which I can reference which just has the 'current' text being displayed?

    I tried accessing things like:

    public class test : MonoBehaviour { MenuLabel testText; void Update () { testText = AC.PlayerMenus.GetElementWithName("SubtitlesNPC", "SubsSpeakerLabel") as AC.MenuLabel; print(testText.label); print(testText.title); print(testText.uiText); } } My idea was to query what was coming through the element, but during runtime I was only getting output like 'null' 'brain'...not the dialgoue text I was seeing on the screen which uses that element.

    I'm thinking if I can just access the current string then I can hook up the text mesh pro stuff in my own way.
  • Ok, I think I'm in a good position now. I misunderstood the integration setup but it started to work when I created a few different objects attached to the same parent. Now I can see the text appearing in the scene, linked to AC via the menu element.

    I've also just become aware of EventManager.OnStartSpeech as a means to access conversation data as it occurs.

    I think with those tools that ought to keep me occupied for a while. :)
  • Yes - the TextMeshProUGUI and Text components should be on different GameObjects, but both children of the same Canvas.  Since the fields are public, you assign them manually - so they can be wherever you like.
  • edited June 2018
    For anyone who is interested (I'd love to be able to edit forum titles with [SOLVED] for stuff like this) I've satisfied this for now by using the delegate AC.EventManager.OnStartSpeech

    In my case I went ahead and:
    • Made a child gameObject for my NPC
    • The child gameObject is just a TextMeshPro 3D object
    • Added a script to the main NPC parent object
    • The script has a reference to the TextMeshPro object & the NPC itself
    • The script then registers with EventManager.OnStartSpeech
    • When speech starts, it does a check to see if the NPC talking (Char speakingCharacter) matches the NPC reference.
    • If so (which means the script is attached to the NPC who should be talking), it sets the TextMeshPro object .text to equal speechText

    There might be better ways to do it, but this appears to work for now and it means I haven't had to dabble with Unity canvases or create new menus...etc
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.