playMaker

Author Topic: [SOLVED] Global Game Object Variable  (Read 2112 times)

turritom

  • Playmaker Newbie
  • *
  • Posts: 21
    • View Profile
[SOLVED] Global Game Object Variable
« on: January 13, 2015, 02: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

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

so how can i fix this problem :)

thank you very much for help
« Last Edit: January 13, 2015, 10:08:37 AM by Lane »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Global Game Object Variable
« Reply #1 on: January 13, 2015, 05: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.

turritom

  • Playmaker Newbie
  • *
  • Posts: 21
    • View Profile
Re: Global Game Object Variable
« Reply #2 on: January 13, 2015, 05: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

hmmm can you explain me a solution

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Global Game Object Variable
« Reply #3 on: January 13, 2015, 06:02:33 AM »
Hmm, a bit hard to follow in German(?). How are you actually maintaining that variable across scenes? Playerprefs or a singleton?

turritom

  • Playmaker Newbie
  • *
  • Posts: 21
    • View Profile
Re: Global Game Object Variable
« Reply #4 on: January 13, 2015, 06: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 ..

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Global Game Object Variable
« Reply #5 on: January 13, 2015, 06: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.

turritom

  • Playmaker Newbie
  • *
  • Posts: 21
    • View Profile
Re: Global Game Object Variable
« Reply #6 on: January 13, 2015, 07:29:52 AM »
but how can i link a prefab gameobject at runtime to a global variable ?  then i think that is my problem :)


Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Global Game Object Variable
« Reply #7 on: January 13, 2015, 07: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.

turritom

  • Playmaker Newbie
  • *
  • Posts: 21
    • View Profile
Re: Global Game Object Variable
« Reply #8 on: January 13, 2015, 09:48:49 AM »
yeah, dont destroy on load works fine :) thank you very much ! :D