[C#] Tick (each frame function) on script

Hi there,

I am still learning C# and I am trying to make a script. But my compiler (visual studio) state me an error on the ‘Tick’ function. Does anyone can help me?

The error message is:
"CS0123 C# No overload for matches delegate ‘Func’

error

Thanks for your help

Shouldn’t the onTick function be defined as

public async Task onTick(){
    // Code here
}
2 Likes

@Havoc is correct, the proper way to set this up is this.

public Class1()
{
    Tick += OnTick;
}

public async Task OnTick()
{
    // ... Code ...
}
1 Like

Love you guys! It works! :grinning:

1 Like

However, I get an annoying warning when I don’t use await in it.
I tried returning an empty task but the game freezes.
Is there a workaround or should I just suppress the warning?