Forum rules - please read before posting.

Check which character a dialogue line is showing text of

I've knocked together a system for a speech bubble to use with background, non-blocking speech. It can follow the player around quite happily, thanks to AC, but I've also given it a dynamic "tail", that will point to whoever's talking. That's the idea, at least - right now it can only do it for the player.

Is there any way to check which character's speech is assigned to a UI that's been instatiated for this line?

Comments

  • I'm not sure what information you have, but here's a hacky way to get started from no information.

    This gets a list of all active speech, then gets all the menus assigned to that speech, and then the character that is speaking from the speech object attached to the menu.

    `List list = KickStarter.dialog.speechList;

    foreach(Speech item in list)
    {
    Menu[] menus = KickStarter.playerMenus.GetMenusAssignedToSpeech(item);
    foreach(Menu menu in menus)
    {
    Speech _speech = menu.speech;
    Debug.Log(_speech.speaker);
    }
    }`

  • That's along the right lines, but if you know which Canvas is being used, you can use that to find the Menu class and then the Speech class:

    Menu myMenu = KickStarter.playerMenus.GetMenuWithCanvas (myCanvas);
    Speech mySpeech = myMenu.speech;
    Char myChar = mySpeech.GetSpeakingCharacter ();
    
  • It's working, fantastic! I've gotten it to look for a marker on the characters' chests, otherwise the arrow seems to think their feet are talking.

    Thanks for your support!

  • Hi everyone! I find myself facing a similar issue, hence why I am bringing this thread back to life. I have implemented the Speech Bubble UI, but I need it to do two things:

    1. The arrow should indicate the speaking character. I'm unsure how to modify the script linked to the Speech Bubble object as per Chris' suggestion mentioned earlier in this discussion.
    2. Despite setting the position type to "Above speaking character," the arrow currently points downward below the character (image).

    Can I ask how Technocrat solved both of these? Thanks!

  • If you haven't seen it already, check out the Speech Bubble UI template over on the Downloads page - that should give you a better starting point to work from.

  • Hi Chris, I should have mentioned that I've implemented this very UI template. I've followed all the steps in the ReadMe file, but it gives me the troubles I mentioned (the arrow doesn't point to the speaking character and the bubble doesn't appear above it, but somewhat below).

  • Regarding the arrow - could you share a screenshot showing the behaviour you're getting, along with a mockup of what you're looking for?

    For the positioning issue, Menus set to position "Above Speaking Character" will use the character's Collider height as an automatic reference. If that's not giving desired results, you can assign an empty child object in the character's Speech placement child field to have the Menu reference that instead.

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.