+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 (22 points)

2 Answers

+1 vote
Best answer

Now i can fix this problem

var player = GetNode<KinematicBody2d>("Player");
player.Call("gameStart");
by (22 points)
–1 vote

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

var player = GetNode<Player>("Player");
player.gameStart();
by (1,002 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 Frequently asked questions and 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 [email protected] with your username.