Page 9 of 10
Re: Character save at save point
Posted: Fri Nov 11, 2016 5:30 pm
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.
Re: Character save at save point
Posted: Fri Nov 11, 2016 7:54 pm
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.
Re: Character save at save point
Posted: Sat Nov 12, 2016 12:36 am
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?
Re: Character save at save point
Posted: Sat Nov 12, 2016 5:19 am
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 (232.16 KiB) Viewed 2763 times
Re: Character save at save point
Posted: Sat Nov 12, 2016 9:11 am
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.
Re: Character save at save point
Posted: Sat Nov 12, 2016 3:25 pm
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.
Re: Character save at save point
Posted: Sat Nov 12, 2016 4:11 pm
by Tony Li
Kind of like this?
Re: Character save at save point
Posted: Sat Nov 12, 2016 4:57 pm
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 (185.96 KiB) Viewed 2756 times
Re: Character save at save point
Posted: Sat Nov 12, 2016 6:37 pm
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.
Re: Character save at save point
Posted: Sat Nov 12, 2016 7:24 pm
by Tony Li
Here's an example scene:
RuctionAirlockExample_2016-11-12.unitypackage
Here's how the map is set up:
The dialogue database has two Boolean variables, "Area 1 Visible" and "Area 2 Visible":
The PersistentObjects GameObject contains these two Persistent Active Data components:
Each of the four Dialogue System Triggers looks like this:
The only difference between them is that each sets a different GameObject active or inactive and sets a different Lua variable true or false.