Forum rules - please read before posting.

Conversation text hangs when changing scene

In one of my scenes I have an NPC who talks randomly. He's close to a door that takes you to another scene. The problem I'm having is that if I change scenes right when the NPC is saying something, whatever he was saying stays in the screen now forever.

Could this be a bug?

I'm using:

  • Unity 2017.4.2f2
  • AC 1.62.2

Thank you

Comments

  • It could be - but without more detail I won't be able to recreate it.

    Please share screenshots showing everything involved - your ActionList for the NPC speaking, ActionList for the scene changing, Settings Manager, and Menu Manager for the Subtitles menu.

  • Hi @ChrisIceBox - sorry for the delay. Here it goes:

    1. First, I have a custom Script attached to this particular NPC and others, which randomises either an animation or a speech, depending on the option chosen from the Editor:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    using AC;
    
    public class RandomActionController : MonoBehaviour {
    
        public ActionListAsset action;
        public ActionListType actionType;
        public float randomness;
    
        private Animator animator;
    
        // Use this for initialization
        void Start () {
            animator = GetComponent<Animator>();
        }
    
        // Update is called once per frame
        void Update () {
            switch (actionType) {
            case ActionListType.ANIMATION:
                tryAnimation();
                break;
            case ActionListType.SPEECH:
                trySpeech();
                break;
            }
        }
    
        private void tryAnimation() {
            if (animator.GetCurrentAnimatorStateInfo(0).IsName("Idle")) {
                tryRun();
            }
        }
    
        private void trySpeech() {
            if (animator.GetBool("isTalking")) {
                return;
            }
    
            tryRun();
        }
    
        private void tryRun() {
            if (Random.Range(0.0f, 100.0f) > randomness) {
                action.RunFromIndex(0);
            }
        }
    
    }
    
    public enum ActionListType {
        ANIMATION,
        SPEECH
    }
    

    You basically choose either ANIMATION or SPEECH and it runs an assigned Action. The Action is also injected in the Editor.

    1. Then, I have the particular Action which is attached to the script. You can check it out here: https://imgur.com/a/0lPOJQ6
    2. Regarding the scene change, the player basically goes through a door. In order not to animate the player character grabbing the knob and so on, it just starts walking towards the door and a fade out starts. When the fade out ends, the scene changes. This is the bit involved: https://imgur.com/a/Yg1BkkC
    3. Settings manager: https://imgur.com/a/iHX6hGk
    4. Menu manager for the subtitles menu: https://imgur.com/a/r0EA9KI

    Thank you, and please tell me if you need anything else.

  • edited December 2018

    Is the script's purpose to have the character sometimes speak when they're either idle or not speaking?

    I don't recommend relying on Animator checks for this, because there may be a slight delay between the state of the character and the state of his Animator.

    If you expose a public variable for the NPC:

    public NPC myNPC;
    

    You can then check if he's idle or talking with:

    if (myNPC.charState == CharState.Idle) { // Idle }
    if (myNPC.isTalking) { // Talking }
    

    Try also the latest release of AC. If you make the above changes and it's still occuring in the latest release, we can look into further code changes.

  • edited December 2018

    Hi @ChrisIceBox , thanks again for your quick answer. I did both things and it's still happening.

    Furthermore, now I have an additional issue with subtitles, because of which, subtitles that offscreen characters are going to say briefly appear on the center of the screen, only to be quickly repositioned on top of their Transforms. It also happens to these NPCs if they are not offscreen. I guess there's a quick fix for this in any case, or maybe it's just some misconfiguration on my part. Also, this happened after updating AC.

  • Please open up a new thread for the second problem, as it's unrelated to the first - and will be easier for us to discuss/manage. I'll need to see screenshots of your Menu's properties and Unity UI Canvas (if applicable).

    I will attempt a recreation of the first issue - what do you have set as your "randomness" value?

  • Okay @ChrisIceBox , I will create another thread for the other issue later on today.

    Regarding your question, I have "99.5", so it should only happen from time to time.

  • Can't recreate this. Let's see those Menu screenshots, as well as your updated script.

  • Okay:

    1. Updated script:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    using AC;
    
    public class RandomActionController : MonoBehaviour {
    
        public ActionListAsset action;
        public ActionListType actionType;
        public float randomness;
    
        private NPC npc;
    
        // Use this for initialization
        void Start () {
            npc = GetComponentInParent<NPC>();
        }
    
        // Update is called once per frame
        void Update () {
            switch (actionType) {
            case ActionListType.ANIMATION:
                tryAnimation();
                break;
            case ActionListType.SPEECH:
                trySpeech();
                break;
            }
        }
    
        private void tryAnimation() {
            if (npc.charState == CharState.Idle) {
                tryRun();
            }
        }
    
        private void trySpeech() {
            if (npc.isTalking) {
                return;
            }
    
            tryRun();
        }
    
        private void tryRun() {
            if (Random.Range(0.0f, 100.0f) > randomness) {
                action.RunFromIndex(0);
            }
        }
    
    }
    
    public enum ActionListType {
        ANIMATION,
        SPEECH
    }
    

    The script is attached to a NPC's child object, not the parent wrapper that AC creates via the wizard.

    1. The Subtitle menu's properties are point 5 of one of my previous posts, if I understood you correctly. Here you can find the Subtitle canvas: https://imgur.com/a/q4QVC1Q
  • edited December 2018

    I'm afraid I still cannot recreate this. If you send me a .unitypackage file that includes all files necessary for me to experience the issue, with steps on what to do, I'll take a look.

  • edited December 2018

    @ChrisIceBox I'll send you a slice of the project itself containing the area where the problem happens. But before that, could you try something? The character that talks, and whose text gets stuck on the screen forever when I change scene, has all his texts as two-liners. I have AC set so that I can create a single Action when I want the speech to be divided into several paragraphs, instead of having to create several speech Actions. So this guy always says one line of speech, and then another one. Then shuts up for a while. I've just thought that it could be related?

    If that still doesn't reproduce it I'll send you the mini-project.

    Thanks

  • In fact if I change all the text to be only one paragraph per Action I can't reproduce.

  • Very well, I'll give it a go.

  • No dice, I'm afraid. You'll have to PM the project over.

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.