Forum rules - please read before posting.

Running conversations in script issues

edited June 2017 in Technical Q&A
When running a conversation from a script, the conversation runs fine, but once it's over, I can't do anything. The cursor doesn't change over hotspots, can't interact with anything, can't walk, except I CAN bring up the pause menu. Once I do that, and close out of it, everything works again. To run the conversation I am using this code (The Conversation component is on the same object as the script running it):

AC.Conversation conv = gameObject.GetComponent<AC.Conversation>();
conv.Interact();

Any ideas?

Edit with more info: This seems to only happen when the conversation's interaction source is set to "custom script." I tried it set to Asset File and it worked perfectly well.

The custom script method that it calls just throws up a dialog box (but it also does the exact same thing when no script at all is called, like for the "bye" option):

AC.KickStarter.dialog.StartDialog(npc, "Testing");


Comments

  • edited June 2017
    Ok, well I fixed it for now by making the following change to Conversation.cs (addition in bold)

    149 else if (interactionSource == InteractionSource.CustomScript)
    150 {
    151   if (_option.customScriptObject != null && _option.customScriptFunction != "")
    152   {
    153     _option.customScriptObject.SendMessage (_option.customScriptFunction);
    154   }
    155   KickStarter.stateHandler.gameState = GameState.Normal;
    156 }

    This is not a perfect solution, though because if you set "Time before can skip (s):" to higher than 0, the dialog doesn't block action anymore, but works well enough for me for now.
  • Changing the gamestate manually is dangerous and should never be done.

    To end the active conversation, call EndConversation:

    AC.KickStarter.playerInput.EndConversation ();
  • Hi Chris

    Calling AC.KickStarter.playerInput.EndConversation (); is one of the first things I tried. It doesn't solve the problem.

    Whether called from my own method or from the same place in the above code where I set the gamestate, it makes no difference. Nothing can be done until I go to the pause menu and come back out again.
  • Apologies.  In addition to that, you must also call the SetCorrectGameState function, which is the "safe" way to set the game state:

    AC.KickStarter.actionListManager.SetCorrectGameState ();

    However, I'll see if this should be called automatically from within Conversation from now on.
  • How about this then? In the same place I changed the state before.

    KickStarter.actionListManager.SetCorrectGameState();

    It also solves the problem, but still doesn't work well if "Time before can skip (s):" is higher than 0:
  • This is a bug - the Conversation should end automatically when an option is chosen.  Make whatever change works for you in the meantime, but I'll add a proper fix in the next release.
  • The time before skip issue seems to be separate, because if all your script is doing is calling the line in your first post, then you aren't placing the game in a cutscene mode without marking the line as background speech.

    If you want the speech to put the game in a cutscene while it plays, you need to put it in a co-routine:

    public void OptionOne ()
    {
        StartCoroutine (OptionOneCoroutine ());
    }

    private IEnumerator OptionOneCoroutine ()
    {
        KickStarter.stateHandler.StartCutscene ();

        Speech speech = AC.KickStarter.dialog.StartDialog (KickStarter.player, "Testing");

        while (speech.isAlive)
        {
            yield return null;
        }

        KickStarter.stateHandler.EndCutscene ();
    }

  • Excellent. Along with the change in Conversation.cs, it is now working perfectly.

    Thanks so much for the exceptional support once again.
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.