Switching Scenes Using Sequence

Announcements, support questions, and discussion for the Dialogue System.
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Switching Scenes Using Sequence

Post by harumin »

Is there a possibility for a dialogue choice to move to another scene?
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Switching Scenes Using Sequence

Post by Tony Li »

Yes:

1. Add a Level Manager component to your Dialogue Manager.

2. Use the LoadLevel() sequencer command. For example:
  • Dialogue Text: "Let's take this outside."
  • Sequence: LoadLevel(City)
If the player has a Persistent Position Data component and you want it to spawn at the location of a specific GameObject in the new scene, you can specify that GameObject in the LoadLevel() command. For example:
  • Dialogue Text: "Let's take this outside."
  • Sequence: LoadLevel(City, Pub Door Spawnpoint)
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Switching Scenes Using Sequence

Post by harumin »

Thanks Tony :)
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Switching Scenes Using Sequence

Post by Tony Li »

Happy to help! If you get stuck on any of it, just let me know.
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Switching Scenes Using Sequence

Post by harumin »

Alright, I implemented S-Inventory to the game and I made a vendor. My game doesn't have controls because It's a visual novel and I couldn't trigger the vendor UI. I had the Usable script component on the vendor object and the triggers and I can't seem to open the UI. I also have the interact button set up on the Player
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Switching Scenes Using Sequence

Post by Tony Li »

Hi,

How would you like the player to open the vendor UI? By selecting a response in a conversation? By clicking on a UI button?

If it's a UI button, I suggest this:

1. Set the SInventory Vendor Trigger's Trigger dropdown to OnUse.

2. Inspect the UI button. In the OnClick() event, click "+" to add a new event handler slot. Assign the vendor GameObject to the slot, and from the dropdown select SInventoryVendorTrigger.OnUse(Transform). Assign the player to the Transform field.
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Switching Scenes Using Sequence

Post by harumin »

Thanks for the reply and sorry for being vague. I would like to open the vendor's UI by the player's dialogue response
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Switching Scenes Using Sequence

Post by Tony Li »

Hi,

No worries! Use this sequence:

Code: Select all

SendMessage(OnUse,,vendor)
where vendor is the name of your vendor GameObject.

For example, to test this in the example scene, I moved Sergeant Graves (a vendor) very close to the Dead Guard. Then I set the Sequence field of one of the Dead Guard's conversation entries to:

Code: Select all

SendMessage(OnUse,,Sergeant Graves)
I moved Sergeant Graves close to the Dead Guard because he's configured to automatically close the vendor panel if the player is too far. If you're making a visual novel, you can probably just set all the vendors and the player to location (0,0,0).
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Switching Scenes Using Sequence

Post by harumin »

Thanks Tony, another question how do I properly create a condition using S-Inventory on dialogue nodes? For example, if the player bought a center Item, it will close the vendor window or will be taken to another conversation. How do I do it?
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Switching Scenes Using Sequence

Post by Tony Li »

This requires a little bit of scripting.

S-Inventory has a script named InventoryEvents with a number of C# events (such as "OnPlayerBoughtItem") that your script can subscribe to. If your script subscribes to OnPlayerBoughtItem, it can check if the player bought the required item. If so, it can close the vendor window and start another conversation. Or it can set a variable and then send a sequencer message; with this approach, you could stay in the same conversation and make it wait until your script sends the sequencer message.

I can help if you get stuck. Let me know if you need an example.
Post Reply