Forum rules - please read before posting.

Dialogue Option: Above speaking Character

Hello,

How to position Dialogue Options, above an NPC, because in Interaction, there is no Speaker Option (as in Play Speech)?

About a 2D game, I want to move some text (dialogue and subtitle) over the scene, in different positions. The best solution was to create an invisible NPC, and move it to different locations, and the subtitles to appear above it, selecting: Above speaking Character to their position in the Menu. (If you have a better solution for this, please tell me :))

But for Dialog Options (respectively conversations) , after selecting Above speaking Character from Conversations from Menu, I can't find any option to move the options box next to an NPC or any character.

Is that option valid only for subtitles, and not for conversations?

Thanks!

Comments

  • The option is valid for both - but will only position above the character speaking, not the one you're currently engaged in a Conversation with. Though it sounds similar to describe, on a technical level these are two separate behaviours.

    Because a Conversation is essentially a list of options, it's not linked to any character in particular - so you'll need to make this connection, and use it to re-position a Menu - through a simple script.

    Set your Menu's Position type to Manual, then attach the following script to your Conversation object:

    using UnityEngine;
    using AC;
    
    public class MapConvToNPC : MonoBehaviour
    {
    
        public NPC npc;
    
        void OnEnable () { EventManager.OnMenuTurnOn += OnMenuTurnOn; }
        void OnDisable () { EventManager.OnMenuTurnOn -= OnMenuTurnOn; }
    
        void OnMenuTurnOn (Menu menu, bool isInstant)
        {
            if (menu.title == "Conversation")
            {
                if (KickStarter.playerInput.activeConversation == GetComponent <Conversation>())
                {
                    Vector2 screenPosition = npc.GetSpeechScreenPosition (menu.fitWithinScreen);
                    if (menu.IsUnityUI ())
                    {
                        menu.SetCentre (MainCamera.ConvertRelativeScreenSpaceToUI (screenPosition));
                    }
                    else
                    {
                        menu.SetCentre (new Vector2 (screenPosition.x + (menu.manualPosition.x / 100f) - 0.5f,
                                                     screenPosition.y + (menu.manualPosition.y / 100f) - 0.5f),
                                        true);
                    }
                }
            }
        }
    
    }
    

    Rename "Conversation" to match the name of your Menu, and then assign the NPC it should appear over in the Inspector. That should then reposition it when the Conversation it's attached to is run.

  • Well, now I have another problem, an error at MainCamera.ConvertRelativeScreenSpaceToUI (screenPosition) :

    An object reference is required for the non-static field method or property 'MainCamera.ConvertRelativeScreenSpaceToUI(UnityEngine.Vector2)'

  • The script above requires the latest version of AC to be installed. Which are you currently using?

  • v1.71.7

    But if I will do an update, will my game still works, with everything I did?

  • edited February 2021

    Each release carries with it a set of "Upgrade notes" in the Changelog, that report any changes that you need to be aware of. So long as you carefully go through the notes for each version in between v1.71.7 and the latest, you should be fine.

    You should always back up your project before upgrading any AC version, however.

    Alternatively, you can just amend the script to work with the previous release. Try replacing:

    menu.SetCentre (MainCamera.ConvertRelativeScreenSpaceToUI (screenPosition));
    

    with:

    menu.SetCentre (KickStarter.mainCamera.ConvertRelativeScreenSpaceToUI (screenPosition));
    

    Or you can simply remove the line, if your Menu does not use Unity UI.

  • Well, you saved me :)
    Thank you very much!

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.