This will allow us to access the current manager from within our conversation class. We can now add a new variable to the dialogue manager which will allow it to store the dialogue manager currently being used by the player. The script works as expected when using scriptable objects for conversations instead of storing them locally. We can then set up our button to load the conversation before loading the next dialogue, and we will test the changes below. We will also need to change the end dialogue method to invoke the dialogue end event on the conversation instead of this object since it has been moved. It will then loop through the new conversation and add it to the dialogue queue. We can then add a new method which will be used for changing the conversation, this will take in a conversation and replace the old one. We can alter the dialogue manager script now to incorporate these changes, we start by changing the “conversation” variable to hold a single conversation class (our scriptable object) instead of an array of dialogue. (Note, the corresponding variables in the DialogueManager script must be removed to avoid conflict) We also move over a couple of variables from the Dialogue Manager class such as the “conversation” variable which is now named “allDialogue” as to not clash with the “Conversation” class name, as well as a Unity Event which will be invoked when this conversation comes to an end. We can now create a new scriptable-object derived class, we use the “CreateAssetMenu” attribute to allow us to create them from within the Unity Asset Menu as well as using the “UnityEngine.Events” namespace to allow us to call an event when this dialogue ends. Making it public would have sufficed, but we would have had to access it through dialogue manager which can get tedious. The first thing we’re going to do is move the dialogue class outside of the dialogue manager and make it public, this will allow the scriptable objects to access it. For this I need some kind of container to keep track of different conversations that an NPC can have and I feel that Scriptable Objects are excellent for this since they can be stored within the Assets folder and have a very small file size. For my dialogue system, I don’t want to have NPCs be limited to a single short set of dialogue, I want the dialogue to be interactable with the player and to be able to branch off depending on the player’s choices.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |