playMaker

Author Topic: Global game objects turn Null upon loading a new scene?  (Read 810 times)

agelvik

  • Beta Group
  • Playmaker Newbie
  • *
  • Posts: 46
Global game objects turn Null upon loading a new scene?
« on: June 10, 2022, 06:14:03 AM »
Hey,
for the past few months, I've been confused why some of my global game objects turn null. Some keep their value, while others don't.

It seems to be related loading scenes for some reason, I'm not sure?
Here's the frame the variables turn null. Player and Maincamera.
https://www.dropbox.com/s/qy9fboy2xan5eba/frame%20where%20gameobj%20turned%20null.png?dl=0

I use Set positions on both of the objects right before them turning null.
https://www.dropbox.com/s/yixrsag4xvy0wxe/values%20being%20set%20before%20null.png?dl=0

The values turn null exactly when a new scene gets loaded.
https://www.dropbox.com/s/uj6i2mfwvpni55q/scene%20additive.png?dl=0

But... I tried checking if this happened to other game objects too, without success.

I'm doing the same thing over and over, and am unable to get consistent results. Here, only the Maincamera turned null, while the Player keeps its value.
https://www.dropbox.com/s/t09omib3384jkpl/player-kept%20-%20but%20not%20maincam.png?dl=0

Sorry but it's very difficult to give accurate reproduction steps, since it feels kinda random. However it happens upon loading a new scene from what I can tell.
« Last Edit: June 10, 2022, 06:24:42 AM by agelvik »

agelvik

  • Beta Group
  • Playmaker Newbie
  • *
  • Posts: 46
Re: Global game objects turn Null upon loading a new scene?
« Reply #1 on: July 08, 2022, 06:55:15 PM »
My current workaround is to keep all global gameobj variable in one FSM. Originally, I designed this logic to only set the gameobj values once during runtime, but now I've made it so if some of these gameobjects value change to null, it just sets the value back again instantly. Though, It'd be nice to find some sort of explaination of why this is happening.
« Last Edit: July 09, 2022, 07:33:10 AM by agelvik »