consider using this way, not best but enough to do your work
float time = 0;
float timer(float delta, float a){
return a += 1 * delta;
}
public override void _Process(float delta){
time = timer(delta, time);
if (time > 5.0f){
//do whatever you want to do
}
}
Are there any function in C# that does exactly like yield(get_tree().create_timer(1.0), "timeout")? Because I just want a delay between specific pieces of code, not an overall timer.
KDX^2 | 2021-02-26 03:28
consider visiting [this page] [1] of godot document, not sure if this what you want
and btw what you want to delay code execution if you can tell me I can further assist you
Looking to do things through program rather than nodes. c#
Made a float variable, set an if statement to check if it’s working.
public class maketimer : Node2D
{
// Declare member variables here. Examples:
// private int a = 2;
// private string b = “text”;
public float myTime = 0.0f;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
System.Console.WriteLine("confirm script");
hello();
}
// // Called every frame. ‘delta’ is the elapsed time since the previous frame.
public override void _Process(float delta)
{
myTime += delta;
System.Console.WriteLine(myTime.ToString());
if(myTime > 3){
System.Console.WriteLine(“tick”);
myTime = 0;
}
}
public void hello(){
System.Console.WriteLine(“from timer”);
}
}