Destroy an object with a tag from another scene?
hey, I've been trying to make it so when the player collides with an object from scene1, an object is destroyed in scene2, is it possible in Unity?
Answer by Hellium · Sep 11, 2016 at 08:06 AM
If you don't have both of your scenes loaded, you won't be able to do this immediately.
Instead :
When the collision occurs, save the information into PlayerPrefs or a file
Add a script to the objects which must be destroyed in the scene 2
In this script, inside the
Awake
function, check if the object must be destroyed by retrieving the saved information from PlayerPrefs or the file
Take a look at this tutorial to know how to keep your data between scenes: https://unity3d.com/learn/tutorials/topics/scripting/persistence-saving-and-loading-data
Answer by angelx3 · Sep 11, 2016 at 06:56 PM
You can create script for save list objects
and if some object not have in the List you can destroy the object
List need for save names objects between scene's (use static)