playMaker

Author Topic: GameManager Global Variable challenges  (Read 14642 times)

jkaczmar

  • Playmaker Newbie
  • *
  • Posts: 2
GameManager Global Variable challenges
« on: December 28, 2024, 04:13:19 PM »
For some reason, I can't get the GameManager variable approach to work in my games.  I can drag and drop the GameManager itself in as a reference to get to its local variables, but I can't reference the GameManager global variable (also called GameManager.)  I've watched all the videos and done the following:
1.  Added a game object called GameManager.
2.  Added an FSM to it.
3.  Used Get Owner to drop the Game Manager itself into the global GameManager variable.

Like I said, I can reference the Game Manager and all its locals using GetFSM, SetFSM, etc. I just can't reference the global.  It works fine in the current scene, but it's going to cause problems for me when I start trying to reference the Global in prefabs that are instantiated during gameplay or when I do scene changes.

Please LMK if there are any obvious steps I might be missing.

glorylifejacket

  • Playmaker Newbie
  • *
  • Posts: 1
    • bitlife
Re: GameManager Global Variable challenges
« Reply #1 on: January 01, 2025, 10:03:54 PM »
Use DontDestroyOnLoad to make the GameManager persistent across scenes.
For prefabs, fetch the GameManager dynamically via the global variable after instantiation.
Check timing to ensure the GameManager is assigned early in the game flow.