I’m new at godot and i’m using c# for coding. Just recently following its step-by-step guide, I stumbled upon the topic “Connect signal via code” where they teach how you can manually connect a button and its function to the sprite or any other node.
The problem starts here, as i’m coding on vscode it shows red sqiggly lines under “timer” which details out as “it is an ambiguous reference between godot. Timer and system.timers.timer” but using either of them isn’t helping either.
Thanks ,but my question is only about this line of code :
public override void _Ready()
{
var timer = GetNode(<)Timer(>)(“Timer”);
}
How do i define “Timer” (the middle one) in c# ? Because everytime i write this code, red squiggly lines appear underneath “Timer” saying "it has ambiguious meaning between godot.timer and system.timers.timer. How do i solve that?
You were right, i used godot.timer and it helped. But now another problem arises. It do not recognize the timeout function. I have written in capital and small but nothing worked
I have edited your original post. Please in the future when posting, replace the full lines saying “<!-- replace this line -->”, including the <!-- and --> parts. Those are HTML comments, so anything between that is not visible.
in first post you was trying connect with += i don’t have much experience with 3.X.
try something like this,
public override void _Ready()
{
var timer = new Timer();
AddChild(timer);
timer.Start(3f);
timer.Connect(Timer.SignalName.Timeout,Callable.From(MyMethod));
}
public void MyMethod()
{
GD.Print("Test");
}
@zakeflame100
I found some short tutorial with 3.4.5