Forum rules - please read before posting.

Any way to change the textbox position dynamicly?

Is there any way to make the dialogue textboxes appear above the characters head? I would like to recreate the dialogue style of "a short hike" and therefore I need to dynamicly change the textbox position to be above the characters head. Same goes for the UI for choosing a reply.

Is there any way to achieve this without having to program a new system?

Comments

  • A menu's "Position type" can be set to "Above Speaking Character", which can be used for Subtitle menus to have it render over the character's head. AC's 2D Demo makes use of this option.

    Alternatively, it's possible to update a menu's position through script. If the "Position type" is instead set to "Manual", a menu can be repositioned by calling its SetCentre function.

    To access a Menu, use PlayerMenus.GetMenuWithName:

    AC.Menu myMenu = AC.PlayerMenus.GetMenuWithName ("MyMenuName");
    myMenu.SetCentre (newPositionVector);
    
  • I did not see the "Above Speaking Character" option, but it works well enough.

    One problem I still have is the offset. It offset the subtitle with its origin in the middle and not on the left. This means that small ones appear way too far on the right when it works with long sentences. Is there a way to fix this?

    Also is there a way to have two 2 different types of textures which change depending on the situation? I want to have some speech bubbles which represent the characters' thoughts and I, therefore, need a different background Texture.

  • It offset the subtitle with its origin in the middle and not on the left. This means that small ones appear way too far on the right when it works with long sentences.

    Are you using Unity UI for the menu's Source? Switch to it if not, as it gives you much greater control in terms of the way the Text object aligns itself to the RectTransform boundary parent, and resizes itself based on the content.

    A tutorial on using Unity UI with AC menus can be found here, and each of the default interface's menus have a Unity UI counterpart.

    Also is there a way to have two 2 different types of textures which change depending on the situation?

    If you want subtitles to change appearance based on the situation, you can create a second Subtitles menu and lock/unlock the pair of them in turn to control which one gets shown. If a menu is locked using the Menu: Change state Action, it will not turn on when its "Appear type" condition is met.

    Alternatively, if you use Unity UI for your menu, you can animate the change in appearance using Unity's Animator system, and control playback with AC's Object: Animate Action.

  • I focused on a lot of different things and just came back to this. I got it working mostly and it looks good.

    I decided to go with the Unity UI "Object: Animate" approach and set up everything. The problem is that I can not figure out how to use the "Object: Animate" Action. Whatever I try, I don't seem to be able to access the animator of the UI Element from Action Lists.

    I also tried it with Parameters, but no luck accessing them either. What am I missing?

    Oh and thank you a lot for all the help!

  • Parameters are typically only necessary when you want to change Action field values dynamically - you should be able to do without them here.

    You'll need to first set the Object: Animate Action's Animation engine to Mecanim, which'll expose an Animator field you can assign the UI's Animator component to.

    When dealing with UI prefabs, however, it's actually the instance of the prefab you want to affect - i.e., the copy of it in the scene at runtime, rather than the original prefab itself.

    To have AC be able to locate the prefab's scene instance when the Action is run, the object with the Animator will need to have a Constant ID component, with Retain in prefab? checked, whose value matches that in the Action.

    If you're using an ActionList asset to call this from, though, this should be automatic.

    If you can share some screenshots of the ActionList and UI object you're trying to have it control, as well as the properties of the Menu it's a part of, I can try to spot where the issue lies.

  • edited December 2021

    Here are the requested screenshots.

    I changed it to be a "Unity Ui in Scene", but still no success, even though I had the possibility to access the animator through the Action List.

    https://imgur.com/a/aNX26S4

    I also tried setting the animation to Loop and changing Parameters also didn't work.

  • I'll need to see the menu's properties as they appear in the Menu Manager. Is your ActionList an asset file, or inside the scene?

    The issue shouldn't be dependent on whether the UI is "In Scene" or not - you can set it back to Prefab if that's what you intend it to be.

    What properties do the Thought/Speech animations actually control? If they affect the Menu's "RectTransform boundary" (i.e. the "Panel" GameObject), this will conflict with AC's control over the Menu depending on its Position field and if you have Fit within screen? checked.

    Once the Action has been run, check the Console for any relevant messages - and also open up the scene instance's Animator window. The best place to start debugging is to check if the Speech animation is running - but having no effect - or if it's not running at all.

  • My Action List is the usual Action List for dialogues, which is always located in the scene under _Interactions. The UI is also in the scene as recommended.

    I have set up 2 different Animations. Speech and Thought, which both just consist of 1 frame. So no transformation of any kind. Would this work?

    Here are the requested images:
    https://imgur.com/a/sGqPRpZ

  • It does look correct - the names match, you're not updating the position, so there won't be a conflict with the RectTransform boundary, and the Console message implies the Animator is being found.

    Clicking this message should "ping" the object in the Hierarchy - it's correctly highlighting the Panel object?

    Your Animator screenshot is cropped, but I'm assuming the states are all on the base layer. Does the issue occur in builds as well?

    If need be, you can PM me the relevant files (scene, prefab, animations, Menu Manager) as a .unitypackage and I'll take a look.

  • I've send the private message with all the relevant assets + answers to the questions

  • Recreated, thanks.

    The issue is that you're updating the Animator before the speech is played. Since the Menu is set to appear when speech plays, the UI is disabled at this moment, and Unity won't process the update call.

    There's two ways to go around it:

    1. Use an ActionList: Run in parallel Action followed by an Engine: Wait Action of -1 (to wait a single frame) to call the animation one frame after the speech is triggered - see this screenshot.
    2. Write a custom script that hooks into the OnStartSpeech event to update the animation automatically based on certain parameters (e.g. which character is speaking). A tutorial on this event can be found here, but I can assist with this if you wish.
  • I used option 1 and it worked perfectly, great! Thank you

    I do have another issue though :neutral:
    I am trying to separate the triangle of the speech bubble into its own sprite and then make it appear with the Panel. I don't want it to scale with the panel and that would be the way to go I think.
    After setting up the new sprites and making the triangle a child of the prefab, it won't appear. Whatever I try it's not appearing. Even when I make it a child of the panel itself.

    Any ideas on how to make it work?

  • Pause the game when it's not showing and check its Inspector - it may be down to the way its RectTransform scales based on its parent transforms.

    Since you mention the triangle, you may find useful the "UI Template: Speech Bubble" package over on the Downloads page. This makes use of a simple script to alter the position of such a triangle dynamically based on the width of the bubble.

  • After some messing around with the approach of option 1 I noticed that it just works once. By this, I mean that I can start the dialogue by switching to the Speech-Animation and afterward change it to the Thought-Animation, but after that, it stops working. I am using the same Actions as before in the same order, but the console will always say: "Cannot play clip Speech on Panel".

    Any ideas?
    I guess I still have the possibility to try out the approach with CustomScript, but I am wondering how to mark specific text to be thoughts and others to be speech.
    (Maybe it is possible to edit the Action Script for the Dialogues so I can just hit a checkmark if I want it to be a thought and then I could read this variable with the Custom Script)

  • I am using the same Actions as before in the same order, but the console will always say: "Cannot play clip Speech on Panel".

    Is this the exactly the same Action (as in, the same ActionList being re-run), or just the same Action type with similar settings? If the latter, check that any Constant ID values listed match.

    I guess I still have the possibility to try out the approach with CustomScript, but I am wondering how to mark specific text to be thoughts and others to be speech.

    There's a couple of ways: one would be to create a custom Action class that extends ActionSpeech, so that you can insert your own checkbox into the Action while still using the original "Dialogue: Play speech" Action as a basis.

    The other option would be to make use of a custom speech token, inserted into the speech text itself, to animate things through custom code. See the Manual's "Speech event tokens" chapter for details on this.

  • So, before trying to do anything with custom Actions and all that complicated stuff I went back to debugging the problem and I noticed something.

    It usually works. I can switch the animation usually whenever I want and it's not dependent on the character (as it should be), but the moment I introduce the "start conversation" Action, it's not possible anymore.
    And it does not matter if I put the "run in parallel" setup before the "start conversation" Action or after it. It won't work either way.
    If I put it before it will change the animation right before the conversation menu pops up, but resets it afterward. When I put it after the action it results in the error message "Cannot play clip Speech on Panel".

  • If the Animator involved has the correct animation state, this warning typically shows if its currently disabled.

    Please see my question above re: this being the same Action or not.

    If you click on the "Cannot play clip" warning in the Console, it will ping the relevant Animator. Does this highlight the correct object in the Hierarchy, and is it currently enabled?

  • It's not the same action that I use multiple times, just copying and pasting the structure and changing the name of the animation.

    But now after debuting it the way you recommended I noticed that by using the "Engine Wait (-1s)" Action under the "Run in parallel" Action it won't have enough time to change the animation state after using the "Start Conversation" Action right before that.

    I solve the issue by setting the wait duration to 0.01 and even though it's slightly noticeable, it finally works.

  • edited January 2022

    Thanks for the details.

    You may be able to remove the noticeable gap by instead using a pair of "Engine: Wait" Actions that both have a -1s wait time.

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.