Forum rules - please read before posting.

Reset player character's expression before conversation options appear on screen?

edited March 2021 in Technical Q&A

Hi everyone.

So as the title says, I have a case where the player character engages in a conversation with an NPC, is presented with 3 conversation options (during which he has Expression 1), of which one (in this case the third conversation option) makes him change his expression to Expression 2, and he comments in an internal dialogue line that he should ask the NPC about that some other time, and then is, again, presented with the same conversation options - herein lies the problem - I'm trying to get him to revert to Expression 1 again. I've tried ticking "Reset character expression with each line", but it doesn't reset it on this last line (just before the conversation options appear). I was tackling the forums, and the manual, and what little clues I've managed to find have something to do with OnStopSpeech event, but I just can't seem to wrap my head around it.
I've linked an image below of what I'm trying to accomplish here.

https://ibb.co/Km2QSkN

Comments

  • The Reset character expression with each line? option takes effect when a character begins a new line - so if the portrait is lingering after a line, it won't have a visible effect.

    The OnStopSpeech event should indeed be what you want. Try this script, ResetExpression.cs. Like this, it'll affect all characters, but can be adapted if you only want to affect the Player character:

    using UnityEngine;
    using AC;
    
    public class ResetExpression : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnStopSpeech += OnStopSpeech; }
        private void OnDisable () { EventManager.OnStopSpeech -= OnStopSpeech; }
    
        private void OnStopSpeech (AC.Char character)
        {
            if (character) character.ClearExpression ();
        }
    
    }
    
  • Thank you Chris, that's exactly what I needed.

  • edited March 2021

    One more thing - I've noticed that the dialogue portraits are flickering when changing now. Much like in the video in this thread https://adventurecreator.org/forum/discussion/11002/profile-pictures-flickering
    I think this script is somehow interfering with the one you wrote in another thread (the one that changes player's expression while an npc speaks and vice-versa)?
    When I run the game only with the CustomExpressions.cs it runs smooth, but as soon as I attach the ResetExpression.cs to the scene, the flickering happens on almost every dialogue portrait change. Is there some kind of a workaround for this?
    AC v1.73.2
    Unity 2019.4.19f1

  • Try this alternative, which will reset things to the first expression listed in your character's "Expressions" panel. You can replace "0" with the ID number of the default expression you want them to have:

    using UnityEngine;
    using AC;
    
    public class ResetExpression : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnStopSpeech += OnStopSpeech; }
        private void OnDisable () { EventManager.OnStopSpeech -= OnStopSpeech; }
    
        private void OnStopSpeech (AC.Char character)
        {
            if (character) character.SetExpression (0);
        }
    
    }
    
  • I'm afraid that change didn't affect the flickering at all, it's still happening in exactly the same way.

  • I can't reproduce such an issue using the "Gabriel Knight conversations" template you mentioned you were using. Does the issue still occur if you switch back to that, i.e. set your Menu Manager asset back to the one used by that package?

    Does your own Menu rely on Unity UI or AC as its Source? If Unity UI, try replacing your portrait Image components with Raw Image components. You'll need to update your portrait elements with the change in the Menu Manager for this to take effect.

  • I did what you said, the flickering is the same. Just so we're on the same page - I changed the Menu manager's Asset file to GKConversation_MenuManager. Under the Menus it only had GK_conversation, so I just pasted in the "Interaction" menu from my default Menu manager's Asset file (just so I could click on the NPC in the scene and start a conversation).
    Every menu is AC, I've yet to dabble in making menus in Unity UI.
    I've recorded a video in hopes that it may shed some light on this.

    https://youtu.be/KA2k7pJX6nY

  • The GK_conversation menu comes with a Unity UI counterpart - try switching its Source to Unity UI Prefab, and see if that makes a difference.

    Otherwise, I'll need you to send me the files via PM - I can't recreate any issue.

  • Did you mean the GKConversationUI.prefab file? I switched the Menu to Unity Ui Prefab, and attached this file, ran the game, same flickering. What files do you want me to send?
    And again, many thanks for taking the time to help me with this issue.

  • I would need your Manager assets, character graphics and prefabs, UI graphics, and a sample scene that shows the issue.

    If unsure, create a .zip of the whole project and PM me e.g. a Google Drive link. PMs can be sent from the Message button on my profile page.

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.