- Home /
Instatiate to the next scene prefabs from an array
Hello guys. I am working in a ar project with vuforia and i need your help for a tricky question. I have some image targets and i want when the player scan them to load a new scene with some prefabs. But i want to instatiete some spesific prefabs based to the specific image target that the player scan. For example if player scan an image target with the picture of Hercules i want in the next scene to instatiate hercules. If the picture is Jason then load scene 2 instatiate Jason etc. I believe that i must create an array with prefabs (and maybe an array of image targets (not sure about that)) and then connected with the script that load a new scene. Any Ideas??
Also i must create it with Vuforia and i must change scene when an image target is scanned...
Thanks for your time
Answer by Arano · Jun 02, 2021 at 11:28 AM
are u familliar with the "DontDestroyOnLoad" functions?
https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html
you could add this to the scanner script to keep it alive when entering a new scene, and wait for the scene to load and than spawn in your object.
be mindfull that u dont end up having multiple of the same objects in a scene like this.
Your answer
Follow this Question
Related Questions
Make a game object in a scene into a prefab with script 1 Answer
Script inside instantiated prefab run lag behind 1 Answer
How to Instantiate a GameObject from a ScriptableObject piece of script? 0 Answers
.As u can see in the image it loads ThemeSelection scenes but doesnot show anything 0 Answers
How prefab the instance works? 1 Answer