Object not being enabled
Object not being enabled
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.
It works the first time but when I reload the scene, the object does not get enabled when it should.
Re: Object not being enabled
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.
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.
Re: Object not being enabled
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.
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.
Re: Object not being enabled
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.
Re: Object not being enabled
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.
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.
Re: Object not being enabled
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?
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?
Re: Object not being enabled
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.
Re: Object not being enabled
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().
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().
Re: Object not being enabled
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.
Re: Object not being enabled
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?
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?