Set Active Save System

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
bakershah
Posts: 32
Joined: Sun Oct 19, 2014 10:26 am

Set Active Save System

Post by bakershah »

Hi,

I have some quest objects in my scene whose "set active" I turn on and off. To test it, I saved the game before the quest. finished it then tried to load back. My objects however did not turn back on from the beginning. I tried using the persistent position data as well as the persistent active data but no luck. Anyway to track those with the save/load system?
User avatar
Tony Li
Posts: 22106
Joined: Thu Jul 18, 2013 1:27 pm

Re: Set Active Save System

Post by Tony Li »

Hi,

Persistent Active Data only runs on active game objects.

If your quest object starts inactive, you'll need to put Persistent Active Data on a separate, active game object and assign your quest object as the target to activate/deactivate. I often use an empty game object for this purpose.
bakershah
Posts: 32
Joined: Sun Oct 19, 2014 10:26 am

Re: Set Active Save System

Post by bakershah »

ahhh ok. But if I have an active object in the scene with the persistent active component and I turn it off at some point will that be affected as well even though it starts active when the scene loads?
User avatar
Tony Li
Posts: 22106
Joined: Thu Jul 18, 2013 1:27 pm

Re: Set Active Save System

Post by Tony Li »

Generally speaking, if the object starts active then it's fine. The problem is when the object starts inactive, in which case the persistent data script will never receive a Start message to do its thing.
bakershah
Posts: 32
Joined: Sun Oct 19, 2014 10:26 am

Re: Set Active Save System

Post by bakershah »

i still seem to be having issues with it... Mainly its objects that are turned on via script... when I reload the scene it doesn't turn them off even with the component attached and the objects being referenced from another object like you suggested.


Update: yea its both way now. So I started from the beginning. As an example:

I have a guard game object that starts active in the scene. He has a persistent active component on him. I go to him for a quest. Towards the end of the quest I have a separate script use Set Active () and turn him off. Keep in mind I saved before I started the quest. When I get to where he is and he's turned off as expected. I load the game again and it doesn't turn him back on. :O

Extra: After getting it to work successfully in a test scene with the guard, theres on issue bugging me. I have a 3d text object hovering above the guard. same deal referencing a persistent active component from another game object and saving/loading it. the 3d text starts off in the scene but doesn't turn off when i reload it :(
Last edited by bakershah on Sun Mar 20, 2016 3:37 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22106
Joined: Thu Jul 18, 2013 1:27 pm

Re: Set Active Save System

Post by Tony Li »

When you activate or deactivate an object via script, you should also record something in the Dialogue System, such as a Lua variable or quest state, that the Persistent Active Data component can check.

For example, let's say the guard should only be active when the quest is unassigned or active. If the quest is successful, the guard should be inactive.

In this case, I would only have one Persistent Active Data component, and I would put it on an empty, active GameObject. The Target would be the guard. The Condition would require that the quest is unassigned or active.
bakershah
Posts: 32
Joined: Sun Oct 19, 2014 10:26 am

Re: Set Active Save System

Post by bakershah »

Update: that fixed the issue. I added some conditions in the lua variables like you said and few of the quest objects do reload. some objects would not load back even with those conditions added until I referenced them in the set active on dialogue event component. Thanks!

Do the lua conditions only get called when the game is saving and reloading?
User avatar
Tony Li
Posts: 22106
Joined: Thu Jul 18, 2013 1:27 pm

Re: Set Active Save System

Post by Tony Li »

bakershah wrote:Do the lua conditions only get called when the game is saving and reloading?
Persistent data components only apply when you:
Post Reply