system
1
|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
ThaksinCCC |
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()
system
2
|
|
|
 |
Reply From: |
davidoc |
You need to get a reference to the node and cast it to the proper type:
var player = GetNode<Player>("Player");
player.gameStart();
I already tried this before it not work but now i can fix this problem .
ThaksinCCC | 2021-07-21 05:26
system
3
|
|
|
 |
Reply From: |
ThaksinCCC |
Now i can fix this problem
var player = GetNode<KinematicBody2d>("Player");
player.Call("gameStart");