playMaker

Author Topic: "Get Owner" creates a "Null" on restart.  (Read 1129 times)

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
"Get Owner" creates a "Null" on restart.
« on: September 18, 2020, 06:38:38 AM »
Hi,

I have a prefab called "GameEssentials" that I have all my game systems on that I use in every scene in the game. It has a Don't destroy on load and a singelton manager on it. There is also a FSM on the "GameEssential" which only has one state. The state is a Get owner and then stores the gameobject as a Global variabel. Everything works fine the first time, but when the game restarts (when the player dies) the get owner returns null.

How is it possible that the Get Owner returns null? It is literary the game object that the FSM is on!

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: "Get Owner" creates a "Null" on restart.
« Reply #1 on: September 18, 2020, 09:30:49 AM »
After some testing to try and find the issue I find that it seems like the issue is that it is not possible to save the owner as a global variable. If I save it locally it works.
This seems like bug or that I am missing something fundamental about playmaker and global variables.

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: "Get Owner" creates a "Null" on restart.
« Reply #2 on: September 18, 2020, 10:02:09 AM »
This monologue continue lol.

So right now the work around that I found was to broadcast a global event after the level restart to make the "Get Owner" run again every time the game restarts. Would be nice if anyone knows why this happening

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: "Get Owner" creates a "Null" on restart.
« Reply #3 on: September 18, 2020, 02:23:28 PM »
Hi.
Are you doing get owner before the singleton or after?

you should probably have the singleton 1st and the don't destroy then do get owner in the next state

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: "Get Owner" creates a "Null" on restart.
« Reply #4 on: September 19, 2020, 02:42:49 AM »
Hi.
Are you doing get owner before the singleton or after?

you should probably have the singleton 1st and the don't destroy then do get owner in the next state

I thanks for the help!

I had 2 different FSMs with only one state each. One with just the singelson and don't destroy on load, and one with Get owner.

I tested to change them into 1 FSM as ju said: 1 start state with the singelton next state with the Don't destroy on load and the next state get owner. But the same issue remains.

However I changed the logic som my last solution to your tip about Game object is null so If the global is null then the FSM just run the Get owner state one more time. Seems to work pretty well, thanks