playMaker

Author Topic: Is Global Variables not working?  (Read 63458 times)

alexsecl

  • Playmaker Newbie
  • *
  • Posts: 11
Is Global Variables not working?
« on: June 09, 2025, 09:27:42 AM »
Hey, everybody,

In my project I am using just two global variables to pass from between scenes .
But the global variable works with only one FSM. I don't understand why only one object can see the global variable. Shouldn't global variables act on all objects in the scene? ???
Maybe I'm missing something.
English is not my native language, so I can't express my thoughts more clearly. I have recorded a video showing the problem and uploaded it to Google Drive.

https://drive.google.com/file/d/1sGmxQs5vBp95HrWxt_j6l45UBeEkdR0D/view?usp=sharing

alexsecl

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Is Global Variables not working?
« Reply #1 on: June 11, 2025, 05:44:21 AM »
Are there any Playmaker developers on this forum who could explain the problem?

hyperbeamart

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Is Global Variables not working?
« Reply #2 on: June 11, 2025, 09:09:45 PM »
Hey there, while I don't have an answer to your exact question, I will say that I personally have not had good luck with global variables. For me they always tend to break at one point or another. Rather I try to keep a game manager that has references to whatever gameobject or fsm I want to communicate with. It's more work than global variables but also more reliable, for me at least.
 I like to have a gameobject (like an item, enemy or so on) use find gameobject with tag to find my game manager, then it can set variables, send evets and so on.  Anyway I hope this helps, good luck with your project!

alexsecl

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Is Global Variables not working?
« Reply #3 on: June 12, 2025, 06:16:46 PM »
Hey there, while I don't have an answer to your exact question, I will say that I personally have not had good luck with global variables. For me they always tend to break at one point or another. Rather I try to keep a game manager that has references to whatever gameobject or fsm I want to communicate with. It's more work than global variables but also more reliable, for me at least.
 I like to have a gameobject (like an item, enemy or so on) use find gameobject with tag to find my game manager, then it can set variables, send evets and so on.  Anyway I hope this helps, good luck with your project!
Hi, Are you using DontDestroyOnLoad for your game manager to transfer it between scenes?

hyperbeamart

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Is Global Variables not working?
« Reply #4 on: June 12, 2025, 09:59:55 PM »
Yes, and a singleton manager from the ecosystem to make sure you don't get duplicates of the same object.

Thembleavelf

  • Playmaker Newbie
  • *
  • Posts: 1
Re: Is Global Variables not working?
« Reply #5 on: June 18, 2025, 09:29:41 PM »
Hi,
Global variables should work across all FSMs. If only one sees it, maybe others are using a local copy or not referencing it correctly. Double-check the name and type. Feel free to share your video link—happy to take a look!