Godot Version
4.2.1 (mono)
Question
How can this piece of code be translated from GDScript to C#?
The problem lies in “await”, I can’t find a way to implement it in its translation to C#.
var state: int = 0:
set(value):
match value:
0:
voidFunction0()
1:
voidFunction1a()
state = value
await get_tree().create_timer(5).timeout
state = 0
voidFunction1b()
return
state = value
I tried, but I can’t.
This is my try, just in case:
private int _state=0;
public int State
{
set
{
switch (value)
{
case 0:
voidFunction0();
break;
case 1:
voidFunction1a();
_state = value;
System.Threading.Tasks.Task.Run(async () =>
{
await ToSignal(GetTree().CreateTimer(5), "Timeout");
}).Wait();
_state = 0;
voidFunction1b();
return;
}
_state = value;
}
get{ return _state; }
}