AutoSave conversation/conversation state, for Mobile build

Announcements, support questions, and discussion for the Dialogue System.
bhavinsavajiyani
Posts: 42
Joined: Sun Jul 26, 2020 3:51 pm

Re: AutoSave conversation/conversation state, for Mobile build

Post by bhavinsavajiyani »

Thank You very much for providing valuable suggestions!
I would surely try and implement what you suggested!
Would give an update, after I make changes as suggested!
bhavinsavajiyani
Posts: 42
Joined: Sun Jul 26, 2020 3:51 pm

Re: AutoSave conversation/conversation state, for Mobile build

Post by bhavinsavajiyani »

Hello!
Apologies for the trouble, and Noob Alert Ahead!

So, as suggested earlier, I have been using Auto Save component for saving the states of conversation and player position.
In the current workflow, I have "Dialogue System Trigger" and "Usable" components, on one of my NPC, which is configured to start the conversation "OnUse". The player has a "Proximity Selector" component on it.
I have checked the "Enable Touch" component, as my target platform is Mobile.
I have a third-person character controller, which is controlled by on-screen joystick and the player can rotate the camera by scrolling anywhere on the right half of screen. When player is running, and reaches the range of Dialogue System Trigger of NPC mentioned above, while running action still being played, and at that instance if player touches anywhere of screen, the conversation gets started, and it results into very odd behaviour, where player running animation is stuck in a loop and camera keeps on rotating, when conversation is started. The same issue happens at all instances, where Dialogue System Triggers are encountered, where the conversation gets started, when any player movement is already being conducted and when screen is touched, in parallel to movement for camera rotation, it results into weird state, where player movement animation is stuck, camera keeps on rotating, with conversation progressing in background.
I'm not able to figure out what could possibly be causing the issue, but I suppose it might be due to overlapping of touch inputs from proximity selector and third person controller. I am using Default GUI on Proximity Selector, but I'm unaware about how to edit Touch Area, as I'm not able to find any parallel reference of it, where I could edit Touch Area and see the changes. That got me thinking that maybe, as an alternative to trigger the conversation using touch, I could provide a button, which would be activated, when Player's Proximity Selector detects Dialogue System Trigger, and which when clicked, would start the conversation, and then get deactivated, after player moves out of the range of tigger. There's already a list of available keys which could be mapped for triggering the conversation. But my target platform is mobile, and I'm not able to figure out a way of mapping a custom button, to trigger the conversation.
Is there any way by which I could do that?

Also, when an ongoing conversation is interrupted, and stopped, the Auto Save component does store the states. But, if the game is stopped or quit, in midway of an ongoing conversation, when player's proximity selector is in range of NPC's Dialogue System Trigger (which obviously would be the case, as conversation could be started only when that condition is fulfilled), and when the game is loaded again, the conversation gets started automatically, in the background, without even it being triggered manually.
Like usually, the player has to manually trigger the conversation, depending upon configuration of Proximity Selector, in order to start the conversation.
But, in this case, when I start the game again after stopping (Auto Save being conducted), the player spawns at the position, which is already in range of NPC's Dialogue System Trigger (as a result of an ongoing conversation being interrupted or game being stopped, while player was in range of NPC trigger), and the conversation gets started automatically.
Is the any possible way of fixing that?

Kind Regards,
Bhavin.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: AutoSave conversation/conversation state, for Mobile build

Post by Tony Li »

Hi Bhavin,

Add a Dialogue System Events component to the player. Configure its OnConversationStart() event to disable the Proximity Selector and the player controller, and to stop the player's animation. Configure OnConversationEnd() to re-enable the Proximity Selector and player controller. To stop the animation, you may need to do more. See the bottom part of the Interaction Tutorial for an example.

Does your Dialogue Manager have a Conversation State Saver component? If so, then this component will remember if the player saved/quit while a conversation was active. When the player resumes, it will resume the conversation at that point. If you don't want that to happen, remove the Conversation State Saver.
bhavinsavajiyani
Posts: 42
Joined: Sun Jul 26, 2020 3:51 pm

Re: AutoSave conversation/conversation state, for Mobile build

Post by bhavinsavajiyani »

Hello Sir.
Tony Li wrote: Mon Nov 02, 2020 9:00 pm Add a Dialogue System Events component to the player. Configure its OnConversationStart() event to disable the Proximity Selector and the player controller, and to stop the player's animation. Configure OnConversationEnd() to re-enable the Proximity Selector and player controller.
I have already done that. Currently, those components are attached and configured as mentioned below, on the Player. Yet, the issue still persists. As suggested, I would also try to adjust animation states.


Tony Li wrote: Mon Nov 02, 2020 9:00 pm Does your Dialogue Manager have a Conversation State Saver component? If so, then this component will remember if the player saved/quit while a conversation was active. When the player resumes, it will resume the conversation at that point. If you don't want that to happen, remove the Conversation State Saver.
My Dialogue Manager does have a State Saver component on it, along with the Auto Save Component. If I remove the Conversation State Saver, then would I be able to store the states of conversation?
Currently, the conversation starts immediately, when game is loaded. What I want, is that player must trigger the conversation again, manually, after game has been loaded again (after conversation being interrupted midway or game being stopped/quit).



Apart from that Sir, is there any way by which this could be done?
bhavinsavajiyani wrote: Mon Nov 02, 2020 2:09 pm That got me thinking that maybe, as an alternative to trigger the conversation using touch, I could provide a button, which would be activated, when Player's Proximity Selector detects Dialogue System Trigger, and which when clicked, would start the conversation, and then get deactivated, after player moves out of the range of tigger. There's already a list of available keys which could be mapped for triggering the conversation. But my target platform is mobile, and I'm not able to figure out a way of mapping a custom button, to trigger the conversation.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: AutoSave conversation/conversation state, for Mobile build

Post by Tony Li »

bhavinsavajiyani wrote: Tue Nov 03, 2020 1:52 amAs suggested, I would also try to adjust animation states.
Sounds good. The tutorial has screenshots that show how to do it with the player controller that's used in the tutorial. The actual settings for your controller may be slightly different.
bhavinsavajiyani wrote: Tue Nov 03, 2020 1:52 amMy Dialogue Manager does have a State Saver component on it, along with the Auto Save Component. If I remove the Conversation State Saver, then would I be able to store the states of conversation?
If you stop the game while a conversation is active, then when you play the game again the Conversation State Saver will resume the conversation where it left off. If you don't want this to happen, you must remove the Conversation State Saver.

You can still use variables to jump to certain places in the conversation when the player triggers the conversation again. This post has an example of jumping to different places in a conversation: https://pixelcrushers.com/phpbb/viewtop ... 710#p20661
bhavinsavajiyani wrote: Mon Nov 02, 2020 2:09 pm That got me thinking that maybe, as an alternative to trigger the conversation using touch, I could provide a button, which would be activated, when Player's Proximity Selector detects Dialogue System Trigger, and which when clicked, would start the conversation, and then get deactivated, after player moves out of the range of tigger. There's already a list of available keys which could be mapped for triggering the conversation. But my target platform is mobile, and I'm not able to figure out a way of mapping a custom button, to trigger the conversation.
You could add a world space canvas to the NPC. Example:
  • Add a world space canvas to the NPC.
  • Add a UI Button to the canvas.
  • Configure the UI Button to call the Dialogue System Trigger's OnUse method.
  • Set the canvas inactive.
  • Configure the NPC's Usable component's OnSelected() UnityEvent to activate the canvas.
  • Configure the NPC's Usable component's OnDeselected() UnityEvent to deactivate the canvas.
  • Set the NPC's Dialogue System Events > OnConversationStart() UnityEvent to deactivate the canvas.
bhavinsavajiyani
Posts: 42
Joined: Sun Jul 26, 2020 3:51 pm

Re: AutoSave conversation/conversation state, for Mobile build

Post by bhavinsavajiyani »

Hello Sir.

As suggested earlier, a remedy to avoid weird looping of camera/player animations, is to tune the Animator States and conditions manually. That definitely did solve the issue and now, there are no more weird states when conversation starts!
That works like a charm!

Tony Li wrote: Tue Nov 03, 2020 8:45 am You could add a world space canvas to the NPC. Example:
  • Add a world space canvas to the NPC.
  • Add a UI Button to the canvas.
  • Configure the UI Button to call the Dialogue System Trigger's OnUse method.
  • Set the canvas inactive.
  • Configure the NPC's Usable component's OnSelected() UnityEvent to activate the canvas.
  • Configure the NPC's Usable component's OnDeselected() UnityEvent to deactivate the canvas.
  • Set the NPC's Dialogue System Events > OnConversationStart() UnityEvent to deactivate the canvas.
Thank You very much for providing the steps! Your help is much appreciated Sir! I would surely try that out.



Tony Li wrote: Tue Nov 03, 2020 8:45 am If you stop the game while a conversation is active, then when you play the game again the Conversation State Saver will resume the conversation where it left off. If you don't want this to happen, you must remove the Conversation State Saver.
Ummm.. I have some doubts here. Apologies for the trouble!
First, would Auto Save Component itself keep a track of conversation states?
(If not, then I suppose Conversation State Saver would be required.)
Now, as per my workflow, I do require conversation states to be saved.
But based upon what you said above, are you intending to say that if Conversation State Saver component would be used, it would "automatically resume the conversation where it left off", on game being loaded after stopping?
Currently, my NPC's Dialogue System Trigger is configured to "OnUse", which has a an action of Starting the conversation.
Though, Conversation State Save component does start conversation from where it left off, when game is loaded again.
But is there any way by which automatic starting of conversation, from where it left off, could either be delayed or be configured, to start from where it left off, "OnUse", and not automatic (start conversation no matter whether player has chose to converse or not)?

Next, I also have some instances, where I trigger some Scene Events, when certain node in conversation is reached.
In my conversation, at a desired node in my conversation in Dialogue Editor, I have set up a Scene Event, where I pass the "Dialogue Manager" object and set it's "DialogueSystemController.Pause" method.
Actually, I am triggering some UI components which are set up in external, world canvas. And what I want, is the conversation to NOT proceed, unless certain action from those UI components are conducted. So, what I do is, when the desired node in conversation is reached, I have a Scene Event created in the Dialogue System Editor itself, which contains one event to Pause the Dialogue System Controller as mentioned above, and another event, which would activate the target UI component. The target UI component, which would be activated using that Scene Event, has a button whose "OnClick()" is configured to "DialogueSystemController.Unpause".
Every single thing till here, is working as intended, when game is run for the FIRST time (never ever been saved, fresh 1st start).
Now, if that particular node (where Pause and Unpause events are set up) is NOT yet reached, when game is running in it's first instance and the game is stopped, then those events configured earlier (which involve Pause & Unpause and triggering of UI components) are skipped entirely, when the game is loaded again!
Ideally, if that particular node of conversation has not yet been reached in first instance, and game is stopped, then, when the game is loaded again, it should be traversed.
In this case, desired node is reached, but the events associated to it, do NOT take place, and are skipped completely, when game is loaded again.
Please note that when I test this above mentioned scenario, my Dialogue Manager has Auto Save Load and Conversation State Components, attached to it.

If I'm doing anything wrong above, and If there is any alternative approach of doing what I require, I would surely be open to try that out.

Your help is much appreciated Sir. Can't thank you enough!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: AutoSave conversation/conversation state, for Mobile build

Post by Tony Li »

Hi Bhavin,
bhavinsavajiyani wrote: Wed Nov 04, 2020 3:41 amFirst, would Auto Save Component itself keep a track of conversation states?
The Auto Save Load component just saves and loads games. But if you use variables in the Dialogue Editor to keep track of where the conversation should be, then those variables will be included in saved games. See this post for a description of how you can use variables to jump back into conversations at specific points when the player "uses" the trigger.

I recommend using the technique above instead of trying to delay the resumption of the conversation using Conversation State Saver.
bhavinsavajiyani wrote: Wed Nov 04, 2020 3:41 amNext, I also have some instances, where I trigger some Scene Events, when certain node in conversation is reached.
In my conversation, at a desired node in my conversation in Dialogue Editor, I have set up a Scene Event, where I pass the "Dialogue Manager" object and set it's "DialogueSystemController.Pause" method.
Instead of pausing the DialogueSystemController, configure the dialogue entry node to wait for a message. Set the node's Sequence field to something like:

Code: Select all

WaitForMessage(ActionComplete)
When the player completes the action, run this C# code:

Code: Select all

PixelCrushers.DialogueSystem.Sequencer.Message("ActionComplete");
When you set up a scene for the save system, you must specify everything that needs to be included in the saved game data. For example, if you activate a UI GameObject during a conversation and then save the game, the save system must be told that it should save the active/inactive state of the UI GameObject. To do this, add an ActiveSaver component (or MultiActiveSaver for multiple GameObjects) to a GameObject that is active in the scene. It can be an empty GameObject. Then assign your UI GameObject to its Target field.
bhavinsavajiyani
Posts: 42
Joined: Sun Jul 26, 2020 3:51 pm

Re: AutoSave conversation/conversation state, for Mobile build

Post by bhavinsavajiyani »

Hello Sir.
Tony Li wrote: Wed Nov 04, 2020 8:07 am The Auto Save Load component just saves and loads games. But if you use variables in the Dialogue Editor to keep track of where the conversation should be, then those variables will be included in saved games. See this post for a description of how you can use variables to jump back into conversations at specific points when the player "uses" the trigger.
I recommend using the technique above instead of trying to delay the resumption of the conversation using Conversation State Saver.
Pardon me, but I am still confused and unclear, whether to use Conversation State Saver component.
Based upon what you're suggesting above, I should construct my conversation in such a way, where multiple conditions and sub-branches are involved. I already have taken that approach and have multiple branches from START node itself, where each node has some conditions. Even if I try and amend the conversation again, by adding more conditions, would I still require Conversation State Saver component?
Because, I tried "NOT using" the Conversation State Saver component earlier, while I was testing. And without it, the entire conversation would start from first, when game is loaded again.
And, if I use Conversation State Saver component, which I already am using in current workflow, I end up in a situation, where the conversation would automatically start by itself, when game is loaded again, no matter what!
What should I do?


Tony Li wrote: Wed Nov 04, 2020 8:07 am Instead of pausing the DialogueSystemController, configure the dialogue entry node to wait for a message. Set the node's Sequence field to something like:

Code: Select all

WaitForMessage(ActionComplete)
When the player completes the action, run this C# code:

Code: Select all

PixelCrushers.DialogueSystem.Sequencer.Message("ActionComplete");
When you set up a scene for the save system, you must specify everything that needs to be included in the saved game data. For example, if you activate a UI GameObject during a conversation and then save the game, the save system must be told that it should save the active/inactive state of the UI GameObject. To do this, add an ActiveSaver component (or MultiActiveSaver for multiple GameObjects) to a GameObject that is active in the scene. It can be an empty GameObject. Then assign your UI GameObject to its Target field.
Thank You very much for suggesting this. I would surely try to implement it that way, using the approach you suggested!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: AutoSave conversation/conversation state, for Mobile build

Post by Tony Li »

If you use Conversation State Saver and you save a game while a conversation is active, then when you load the game the conversation will always automatically resume. If you don't want this to happen, you must remove Conversation State Saver.

Instead, set up several links from <START>. Assign Conditions to each linked node. If that isn't working, then check your Conditions.
bhavinsavajiyani
Posts: 42
Joined: Sun Jul 26, 2020 3:51 pm

Re: AutoSave conversation/conversation state, for Mobile build

Post by bhavinsavajiyani »

That sums it up!
Thank You very much for making things clear.
Your help is much appreciated Sir.
Post Reply