Object not being enabled

Announcements, support questions, and discussion for Quest Machine.
Post Reply
willij
Posts: 15
Joined: Sat Oct 27, 2018 5:35 pm

Object not being enabled

Post by willij »

So I have an action to enable a gameobject in the scene.
It works the first time but when I reload the scene, the object does not get enabled when it should.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Object not being enabled

Post by Tony Li »

Hi,

The Activate GameObject Quest Action just activates a GameObject. It doesn't record the GameObject's active/inactive state in the save system. (Quest Machine uses the save system to remember the states of objects when changing scenes.)

To record the GameObject's active/inactive state, add an Active Saver component to a GameObject that starts active in the scene, and assign your GameObject to it.
willij
Posts: 15
Joined: Sat Oct 27, 2018 5:35 pm

Re: Object not being enabled

Post by willij »

I don't want to record the gameobject's state nor am I using any saving system.
I'm just reloading the scene and I want the quest action to set it to active again like it does the first time I open the game.

The quest is activating - I know because I can see it pop up in the HUD - but it's not activating the gameobject.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Object not being enabled

Post by Tony Li »

If the quest is already active when you reload the scene, then it won't run the actions again that are associated with it going active, since it's already active. That's what components like ActiveSaver are for, although you can certainly use your own solution to keep track of the GameObject's active/inactive state after the quest sets it active.
willij
Posts: 15
Joined: Sat Oct 27, 2018 5:35 pm

Re: Object not being enabled

Post by willij »

I don't want the object to be active when the scene is loaded. I basically want to "restart" the quest sequence again so the gameobject gets activated when the quest is supposed to activate it so I won't be able to use the active saver.

I tried to set the current Quest's state to Waiting to Start through code so it wouldn't be active when the scene is reloaded but that didn't work.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Object not being enabled

Post by Tony Li »

Can you give me a concrete example please?

I think you want the quest to be reset to Waiting To Start whenever the player enters the scene, correct?

If so, reset to Waiting To Start if the quest is currently active, or player has completed the quest, or both?
willij
Posts: 15
Joined: Sat Oct 27, 2018 5:35 pm

Re: Object not being enabled

Post by willij »

Yes, I want all quests to revert to their state before the game started. Basically I'm trying to restart the game from the beginning.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Object not being enabled

Post by Tony Li »

Quests will start at their default states unless you're carrying the quest journal across scene changes. So to restart the game, just load the scene, getting rid of the old quest journal first if it normally survives scene changes.

If that doesn't help, please provide more information about your setup.

Typically a scene will be set up with a Quest Journal component on the player GameObject, and one or more Quest Giver components on NPCs. The Quest Journal component's Quests lists may be empty, or it may have some quests that can autostart under certain conditions.

If you carry your Quest Journal across scenes, either:

1. Don't do that. Use the save system to carry the data across to the separate Quest Journal component in the next scene.

2. Or, delete all of the quests out of the Quest Journal before restarting a new game by calling QuestJournal.ResetToOriginalState().
willij
Posts: 15
Joined: Sat Oct 27, 2018 5:35 pm

Re: Object not being enabled

Post by willij »

I don't carry the quest journal across scenes. The quests are reactivating just fine it's just the Activate GameObject action that won't run properly after I restart the scene.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Object not being enabled

Post by Tony Li »

The Activate GameObject action will run when the quest changes to the state whose Actions list contains the action. For example, if the quest's Active state's Actions list contains the Activate GameObject, then the action will run when the quest changes to the active state.

If the action isn't running, then this suggests that the quest is not changing to the active state. Can you provide reproduction steps or send a reproduction project to tony (at) pixelcrushers.com?
Post Reply