0
Not a bug

Local variable on Player not selectable

eagleeyez 9 months ago in Game Creator updated 9 months ago 4

Local variable on Player not selectable


I have Local Variables directly on the Player. Player has player tag, player hook

But when I make an action and select the drop down to set a variable and select player no variables show, only those I saved in Global. I have tried many different ways and I am sure this use to work.


It is making me crazy.

Unity version:
2019.3.0f3
Game Creator version:
1.1.3
Not a bug

This is by design. Selecting a Local Variable and getting it from the Player can't show you a list of variable names because the player might not be present.

For example, if you're trying to get a local variable from a prefab, it can't reference the player in the scene. Another case is if the player is in another scene that's loaded additively.


Hope this makes sense.

Hi and thanks for your reply. Then why can I even select Player in the variables dropdown?

Please take a look at this video and you can see what I mean. 

https://streamable.com/c0qrx

I would make sense for this particular case. However, bear in mind we have to architecture Game Creator as a "generic" tool. Let's imagine you create a prefab out of this object you have selected and edit it in prefab mode. If we were to look at the Player's Local Variables from the prefab, because we're in prefab mode and not in the scene, the Player wouldn't be found and it would return an empty list of variables.

However, if you type the variable inside the text field when selecting the Player option, Game Creator understands that that name is a "promise". A promise that, when running the game, there will be a scene object identified as the Player that will contain a local variable called "localBool"

On the other hand, global variables can always be accessed, because they are that: global. So we can always go check which one exists at any given point, under any circumstance.

Sad......

Maybe V2 will solve this problem......I really hope