Character save at save point

Announcements, support questions, and discussion for the Dialogue System.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Character save at save point

Post by supadupa64 »

Anything would be helpful at this point. I really appreciate the help Tony!!!!!!!!

Demo scenes have proven to be extremely helpful. Those are probably the most work, but it also works the best.
User avatar
Tony Li
Posts: 22100
Joined: Thu Jul 18, 2013 1:27 pm

Re: Character save at save point

Post by Tony Li »

Try this demo scene:

RuctionSaveExample_2016-11-11.unitypackage

The dialogue database has a Boolean variable named "Trigger setactive scene 2 start area cave". Its initial value is false.

The scene has an active GameObject named "Persistent Objects". It has two child GameObjects:
  • PLANTS ALL HERE and cliffs: Starts inactive.
  • Cliffs Trigger: Starts active. Has a Dialogue System Trigger that fires if a GameObject tagged "Player" enters its trigger collider. It sets "Trigger setactive scene 2 start area cave" true and runs this sequence:

    Code: Select all

    SetActive(PLANTS ALL HERE and cliffs);
    SetActive(Cliffs Trigger,false)
The "Persistent Objects" GameObject also has two Persistent Active Data components: one for PLANTS ALL HERE and cliffs, another for Cliffs Trigger.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Character save at save point

Post by supadupa64 »

I'm about to give this all a go.

In sequence trigger I am using SetActive(some example); SetVariable(name of trigger here, true) commands, but in yours I saw that you use SetActive(examplehere, false) where I would put my SetVariable command. I've never done that. I'll have to give these things a try.

I've also never placed the trigger in the Target area of the persistent active data component inside the persistent GameObject.

I just noticed you are using a Dialogue System Trigger instead of the Sequence Trigger I'm using. Should I be using the Dialogue System Trigger instead?
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Character save at save point

Post by supadupa64 »

Ok, so none of that worked. I even used the dialogue system trigger instead and set it up exactly how you have it. I realize there could be something else that is stopping it. You think there is a problem with the UI? I do have my UI in a separate scene then my game scene. Maybe it's not recognizing the scene change. Dunno. But, my quest system works great. Although

By the way, you have only one equal sign in the Dialogue System trigger in the run lua code variable. I found that if I just use one equal sign there, the trigger works once, then destroys itself, but if I use two it stays.
save component copy1.jpg
save component copy1.jpg (232.16 KiB) Viewed 2760 times
User avatar
Tony Li
Posts: 22100
Joined: Thu Jul 18, 2013 1:27 pm

Re: Character save at save point

Post by Tony Li »

I didn't type any Lua code manually. I used the wizards, since they know which equal sign to use. (A single equal sign assigns a value. For example, "x = 3" assigns the value 3 to x. A double equal sign tests for equality and returns true or false. For example, "x == 3" returns true if x's value is 3.)

If you quests are working, then the overall save/load process is working. That suggests it's just a logic problem with the way some of your Persistent Active Data components are configured.

First, did the example scene I sent you work? The SetActive(Cliffs Trigger,false) just turns off the cliffs trigger after the player has triggered it. I added it for completeness, but it's probably not necessary since it shouldn't really matter if the player retriggers it.

BTW, I used the Dialogue System Trigger because this allowed me to specify the Sequence and Lua Code separately. I used the Sequence to run SetActive() commands, and I used the Lua Code to set the variable using the wizard. You could use a Sequence Trigger and set the variable in the Sequence, but this means you have to type the variable name manually; I prefer point-and-click with the Lua wizard.

If the example scene works, do you want your scene to use the same kind of logic? To summarize that logic: When the player enters a trigger, it activates a GameObject and sets a variable to remember that the GameObject is active in saved games.

If you don't want your scene to use the same kind of logic, please describe what you want to happen.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Character save at save point

Post by supadupa64 »

Yeah I used the example scene and it works. I'll double check all my manual entries, maybe there is something missing.

Here's exactly what I'm doing in my game:

Player is currently in an area where a bunch of objects are active.
In this example I will use four triggers.

The player moves through the first trigger with Sequence Trigger component which says this:
SetActive(PLANTS ALL HERE and cliffs, false); SetVariable(Trigger setactive scene 2 start area cave off, true)
So it basically does nothing the first the player goes through it since the next area is already inactive.

But there is another trigger with Sequence Trigger component just next to it that actives the next area which says this:
SetActive(PLANTS ALL HERE and cliffs); SetVariable(Trigger setactive scene 2 start area cave, true)

So this way the player can move back and forth activating and deactivating the area with the two triggers. This is only for the new area moving into since the current area is active. So I place two more triggers with the same setup to activate and deactivate the previous area so there's only one active area at any given time.
User avatar
Tony Li
Posts: 22100
Joined: Thu Jul 18, 2013 1:27 pm

Re: Character save at save point

Post by Tony Li »

Kind of like this?
Image
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Character save at save point

Post by supadupa64 »

Yeah it's just like that. I would use that for something like a cave where there's only one way in and out.

Here's another example where you pass through areas. The concept is the same either way.
trigger_setup.jpg
trigger_setup.jpg (185.96 KiB) Viewed 2753 times
User avatar
Tony Li
Posts: 22100
Joined: Thu Jul 18, 2013 1:27 pm

Re: Character save at save point

Post by Tony Li »

Great! That's a very classic approach, often calling "airlocking" in level design. I'll post an example scene here in a few minutes.
User avatar
Tony Li
Posts: 22100
Joined: Thu Jul 18, 2013 1:27 pm

Re: Character save at save point

Post by Tony Li »

Here's an example scene:

RuctionAirlockExample_2016-11-12.unitypackage

Here's how the map is set up:

Image

The dialogue database has two Boolean variables, "Area 1 Visible" and "Area 2 Visible":

Image

The PersistentObjects GameObject contains these two Persistent Active Data components:

Image

Each of the four Dialogue System Triggers looks like this:

Image

The only difference between them is that each sets a different GameObject active or inactive and sets a different Lua variable true or false.
Post Reply