+1 vote

Let's say i have Player scene with a Player.c# script

In player.c#

public void gameStart()
{

    Gd.Print("gamestart");
} 

How i call gameStart() in main scene with main.c#

main.c#

public override void _Ready()
    {
        //Call gameStart() from Player.c#
    } 

I only know at GDscript

func _ready():
 $Player.gameStart()
in Engine by (20 points)

2 Answers

0 votes
Best answer

Now i can fix this problem

var player = GetNode<KinematicBody2d>("Player");
player.Call("gameStart");
by (20 points)
0 votes

You need to get a reference to the node and cast it to the proper type:

var player = GetNode<Player>("Player");
player.gameStart();
by (988 points)

I already tried this before it not work but now i can fix this problem .

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.