Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: turritom on January 13, 2015, 04:30:43 AM
-
Hi,
i have a problem with a global game variable .. i want to save the sword object what the player takes for the next level to load from the variable.
but if i save the object in the global variable in runtime ..it saves a clone object ..
see the screenshot
https://dl.dropboxusercontent.com/u/514672/playmaker1.jpg (https://dl.dropboxusercontent.com/u/514672/playmaker1.jpg)
if i load the next level ... the global game object variable is none
see the next screenshot
https://dl.dropboxusercontent.com/u/514672/playmaker2.jpg (https://dl.dropboxusercontent.com/u/514672/playmaker2.jpg)
so how can i fix this problem :)
thank you very much for help
-
You need to store the reference to the Prefab, not the Scene's GameObject sword. In the same way you Create the sword and target the prefab, you need to store the reference to it and create it on the next level.
-
it looks like it linked to the cloned object
but i store the prefab in the Set Game Object ..the Set Game Object is linked to the Prefab ..
you can see it in the next screenshot ..i have click on the Set Game Object - and you see the link
https://dl.dropboxusercontent.com/u/514672/playmaker3.JPG (https://dl.dropboxusercontent.com/u/514672/playmaker3.JPG)
hmmm can you explain me a solution
-
Hmm, a bit hard to follow in German(?). How are you actually maintaining that variable across scenes? Playerprefs or a singleton?
-
hmmm that the question .. other variables are not change across the scenery i think so i figured that the global variables not changed across scenes .. so i dont save the variable in any way ..
yes its german ;) and sorry for my english ..
-
You can use a Manager GameObject that maintains the variables you need to pass across the scene, then use Dont Destroy On Load Action to keep it between scene changes.
-
but how can i link a prefab gameobject at runtime to a global variable ? then i think that is my problem :)
-
If you have an object that lives from scene to scene, just store those values in that object and retrieve them in the next scene. You could have that same object define the necessary globals when it wakes up, if you wanted to.
-
yeah, dont destroy on load works fine :) thank you very much ! :D