GlobalVariable referencing an objectvariable (Solved)

Hi there!

I have a GlobalVariable I use for keyboard condition: GlobalVariableString(P1_b)
I also have a player_body object with an object variable: player_Id = number e.g. player_body.player_Id=3

Is there a way to write it so that the number in the GlobalVariable can equal to the player_Id?

I’ve tried a couple of ways but none seems to work:

Sorry if this was hard to understand, it’s a hard to one to explain! Thank you!

What you’re asking is not possible with the standard events and a string variables.

However, if you make the string variable the name of a structure variable child, then you can access it that way. For example, if your structure variable was:

then you could access it like:


You can refer to a number variable with VariableString() because GDevelop has weakly types variables.

1 Like

Thank you so much!!! It worked :slight_smile: