0 votes

I have a game for android which i was creating using only GDscript .
When i heard that Godot 3.2 Mono supporting Android Export , i moved the project to Godot 3.2 Mono actually rc2 .

In my game i have defined a Gdscript global_variables.gd as a Singleton that contain shared variables across all my game .

MY QUESTION IS : is there is a way or How can i use and get data from this file in a C# script file class ?

asked Jan 23 in Projects by Zakaria Guenna (27 points)

1 Answer

+1 vote
Best answer
public class Globals : Node
{
    private Node Globals;

    public override void _Ready()
    {
        Globals = GetNode("/root/global_variables");
        GD.Print(Globals.Get("player_score"));
    }

}

this is a example of how to get player_score stored in global_variables.gd

there are other methods to get functions and set variables values like Globals.Call("function_name",properties); and Globals.Set("variable_name", value);

answered Jan 23 by Zakaria Guenna (27 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.