Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: turritom on January 13, 2015, 04:30:43 AM

Title: [SOLVED] Global Game Object Variable
Post 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
Title: Re: Global Game Object Variable
Post by: Lane on January 13, 2015, 07:04:39 AM
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.
Title: Re: Global Game Object Variable
Post by: turritom on January 13, 2015, 07:52:27 AM
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
Title: Re: Global Game Object Variable
Post by: Lane on January 13, 2015, 08:02:33 AM
Hmm, a bit hard to follow in German(?). How are you actually maintaining that variable across scenes? Playerprefs or a singleton?
Title: Re: Global Game Object Variable
Post by: turritom on January 13, 2015, 08:12:34 AM
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 ..
Title: Re: Global Game Object Variable
Post by: Lane on January 13, 2015, 08:16:47 AM
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.
Title: Re: Global Game Object Variable
Post by: turritom on January 13, 2015, 09:29:52 AM
but how can i link a prefab gameobject at runtime to a global variable ?  then i think that is my problem :)

Title: Re: Global Game Object Variable
Post by: Lane on January 13, 2015, 09:38:49 AM
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.
Title: Re: Global Game Object Variable
Post by: turritom on January 13, 2015, 11:48:49 AM
yeah, dont destroy on load works fine :) thank you very much ! :D