Forum rules - please read before posting.

Dialogue & Conversations - Regular gameplay is disabled after first conversation option

edited September 2018 in Technical Q&A
Hey there folks,

Unity Ver: 2018.2.2f1
AC Ver: 1.64.1

I'm starting to build out the opening narrative for my game but I've hit abit of a road block with conversations disabling gameplay.


Here's a GIF of the problem:



When dialogue is taking place, I want the player to retain control of movement. This is what you can see at the start of the GIF.

What happens though, is after the first conversation option is selected gameplay becomes frozen. The player cannot move subsequently after selecting a piece of conversation. 

How can I fix that?

What I want is the player to be frozen only at the point of needing to select a conversation option. At all other times they should have free movement and normal gameplay.

This is the Action List which is being used during the GIF. It is set to 'run in background'.:



It's almost like at the point of the green arrow, that's when things seem to change.

Enabling "Allow regular gameplay during Converations" in AC settings doesn't seem to help, because what that means is that the player can move around while conversation options are on screen which is also undesired in this case.

Grateful for any help.

Many thanks as always.

Comments

  • You must enable Allow regular gameplay during Conversations?, and then add ActionLists when turn on/off to your Conversation menu to lock/unlock player movement and interaction when it's displayed.

    This can be done with a pair of Engine: Manage systems Actions.
  • Hey there,

    Gotcha. I see what you're trying to do.

    I just quickly added the 'manage systems' action in like so:

    image

    If I set movement (or input) to be 'disabled' it stops WASD control (good) but it also seems to stop mouse input. My game is first person, and this prevents the player from using the mouse on the conversation menu to select conversation options. 

    In my case I want to freeze everything but the mouse pointer, so the player can still select conversation options. I don't see the above supporting that?


    Thanks.
  • Been playing around with this is a bit more. It seems 'Player: Constrain' is a better action in my case. I've managed to get it to freeze the player's movement and with 'free-aiming' set to disabled also wrestle mouse control to allow the player to select conversation options.

    Just need to disable some custom actions & controls at the same time.
  • Boom! Sorted. :)

      if (KickStarter.stateHandler.gameState == AC.GameState.DialogOptions) { return; }

  • edited September 2018
    Ok, I believe there might be a problem in AC's gameState. When the first dialog option appears on screen the game state changes from 'Normal' to 'DialogOptions' as expected. When the player has selected an option though, the game state doesn't revert back to 'Normal', it stays as 'DialogOptions'.

    Here's a GIF showing the behaviour (right-click 'view video' and watch the output in the console): 



    Is this correct? I'd expect the gameState to return to 'normal' after selecting a dialog option. Can I enforce this somehow?
  • What is it you're trying to achieve?  I don't want to classify that as the cause of your issue prematurely.  Please describe in more detail the core thing you're trying to achieve.

    Separately, know that the GameState can be displayed at any time in the Game window via the "AC Status" box option in the Settings Manager.
  • edited September 2018
    Sure thing Chris.

    My apologies, this is going to be a long one, but hopefully it'll explain everything from the start.

    So ultimately, this is all about wanting, that when dialog options are displayed player movement, camera movement, and custom behaviour is disabled. And at all other times, when normal dialog / gameplay is happening, all those things are enabled.

    I managed to achieve sorting the player's movement and camera by using 'Player: Constrain' actions via Action Lists attached to the 'turn on' and 'turn off' events of the Conversation menu:



     


    Works great!


    This is where it gets more tricky:

    My game doesn't just have standard first person player movement and mouse camera control though. I also have custom behaviours on the left mouse button that fire things, and also the scroll wheel changes the thing you fire. This is all done via scripts attached to the player object. For instance, here's a snippet of the fire script:

    void Update() { //Check for firing FireProjectile(); } void FireProjectile() { //On left mouse button pressed if (Input.GetMouseButtonDown(0)) { //Create the linked prefab of the active inventory slot as a gameobject activeProjectile = Instantiate(AC.KickStarter.runtimeInventory.GetItem(InventorySelection.activeInventorySlot).linkedPrefab, projectileSpawn.position, projectileSpawn.rotation) as GameObject; //Access it's rigid body component getRigidBody = activeProjectile.GetComponent(); //Apply a force to the rigid body getRigidBody.AddForce(projectileSpawn.forward * projectileForce); } } }

    I need to somehow disable this functionality while dialog options are on screen. If I don't, when the player goes to left click a dialog option it also triggers all the firing behaviour. 

    In the past I used...

    if(!KickStarter.stateHandler.IsInGameplay()) { return; }

    In the update method which solved this problem. If the game wasn't in normal gameplay then it would return early and not process anything to do with firing. But, remember, we've now gone and enabled 'allow regular gameplay during Conversations' and now this check in script cannot be relied upon.

  • I need a new way, in script, of ensuring that custom behaviour is disabled while dialog options are on screen. And, as soon as a dialog option has been selected, enable the custom behaviours again.

    Because IsInGameplay() cannot be used anymore, I thought I could be clever and instead check the active gamestate via:

    AC.StateHandler.gameState


    Initally this looked promoising. The game starts with the gamestate being 'normal' and, when dialog options appear on screen the state suddenly changes to 'dialogOptions'.

    Great!

    That means when I do this in my custom firing script:

    void Update() { //Return if we're showing dialog options. If so we don't want to process firing if (KickStarter.stateHandler.gameState == AC.GameState.DialogOptions) { return; } //Check for firing FireProjectile(); }


    I can prevent firing.

    Just as I thought I'd solved all this though the problem exists which is after the dialog options have disappeared (and normal, linear dialog resumes) the gamestate doesn't go back to 'normal'. It seems to stay as 'dialogOptions'. This means that all my custom firing behavious are now permanently disabled.


  • edited September 2018
    I can confirm I get the same results with the AC Status box:


    Didn't know about that. Useful.


    The core problem here is after a dialog option is selected, the gamestate doesn't change back to 'normal'.

  • You want to hook into the OnMenuTurnOn / OnMenuTurnOff custom events, which are fired when any menu turns on and off respectively.  The events incorporate the Menu as a parameter, meaning you can read it's title field to determine if it's the "Conversation" menu that's being affected.

    For more, see the "Menu scripting" and "Custom events" chapters of the Manual.
  • Thanks Chris. Excellent, I'll try and go about it that way.

    Out of curiosity though, is the gameState behaving as you'd expect? I'm really curious about why it doesn't revert back to 'normal' in this instance.
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.