Page 1 of 1

[SOLVED] Saving Spawns

Posted: Sat May 02, 2020 9:01 am
by mschoenhals
Hi,
Is there a simple way to save a spawn created by a quest giver? Right now, if an item spawns by a quest giver and the player changes scenes, the spawn will be gone when the player returns. The spawn item right now has a sphere collider (with trigger selected), a Trigger Event with Set Active and also Send To Message System, and a Quest Control script on it. The Quest Giver is using Control Spawner as an action.
Thanks in advance.

Re: [HELP] Saving Spawns

Posted: Sat May 02, 2020 11:39 am
by Tony Li
Hi,

Add a Spawned Object component to your spawn GameObject, and save it as a prefab. Configure the spawner to spawn this prefab. The Spawned Object component adds some saver info fields, but you can leave them blank.

Then add a Spawned Object Manager component to the scene. Make sure it's on a regular scene object, not one that is marked Don't Destroy On Load. Add your spawn prefab to the Spawned Object Prefabs list.

You can find more info about Spawned Object Manager in the Save System Manual, which is in Quest Machine's Documentation folder.

Re: [HELP] Saving Spawns

Posted: Sat May 02, 2020 3:06 pm
by mschoenhals
Yup, that worked. I see that in the save documentation that Save Across Scene wasn't selected, and I left mine unselected, and it still worked. Not sure what the purpose is for that option. Anyways, working fine now. Thanks so much for your help. :D

Re: [SOLVED] Saving Spawns

Posted: Sat May 02, 2020 11:27 pm
by Tony Li
Glad to help! :-)

Re: [SOLVED] Saving Spawns

Posted: Tue Jun 02, 2020 10:14 am
by mschoenhals
What if the spawned objects are related to a quest? After the quest has ended, the spawned objects should end. However, when using the Spawned Object Manager along with the Spawned Object component on the prefab(s), the objects continue to spawn. How do I end the spawning?

Also, is the Spawned Object Manager used for enemies who spawn for a specific quest (and therefore no longer spawn after the quest ends)?

Re: [SOLVED] Saving Spawns

Posted: Tue Jun 02, 2020 11:07 am
by Tony Li
Hi,

To stop spawning when the quest ends, use the Spawner Quest Action in your quest -- for example, in the quest's Success > Actions section. add a Spawner Quest Action set to Despawn. This will stop the spawner and despawn all spawned objects. If you only want to stop spawning new objects (or enemies) but leave the existing ones in the scene, set the Spawner Quest Action to Stop.

Re: [SOLVED] Saving Spawns

Posted: Wed Jul 08, 2020 4:20 am
by Tzirrit
Hello,

I have a simmilar problem:
A spawner in the scene spawns NPCs as soon as the game starts. I've added a SpawnedObject component to the NPC prefabs and a SpawnedObjectManager to an active GameObject in the scene (parent object to the spawner which spawns the NPCs). However, when laoding the game, previously spawned entities are gone.

Thanks in advance.

Re: [SOLVED] Saving Spawns

Posted: Wed Jul 08, 2020 5:37 am
by Tzirrit
I continued debugging and found that the extended spawner script I used changed the spawned object name, so the script could not find the correct prefab.

After fixing that, it got even more interesting/confusing: I created another simpler spawner for testing purposes. That spawner has one npc prefab (with SpawendObject attached). It correctly spawns 3 NPCs and also stores them in the SpawnedObjectManager.
When loading the game, the previously spawned 3 NPCs are created, BUT not registered with the spawner. It just starts spawning more NPCs.

Since SpawnedEntities are handled different than SpawnedObjects, do I need to create a special SpawnedEntitiesSaver that would then tell the spawner to spawn as many entites as were saved before? Or is there already a script for that which I am missing?

Re: [SOLVED] Saving Spawns

Posted: Wed Jul 08, 2020 8:30 am
by Tony Li
Hi,

I'll look into this. I believe I implemented it for the upcoming version 1.2.8 which is being released this week.

Re: [SOLVED] Saving Spawns

Posted: Wed Jul 08, 2020 8:40 am
by Tzirrit
Hi Tony,

thanks for looking into it!