If I want to call my main function in 2 sec, I can use Utility.Wait(2) in a while loop, or RegisterForSingleUpdate(2.0) for OnUpdate(), which one is better?
Thank you for your help!
If I want to call my main function in 2 sec, I can use Utility.Wait(2) in a while loop, or RegisterForSingleUpdate(2.0) for OnUpdate(), which one is better?
Thank you for your help!
Do you want to call your main function every two seconds, or call it once after a delay of two seconds?
For the first, use RegisterForSingleUpdate(2.0) once in your initialising function, with another RegisterForSingleUpdate(2.0) in your OnUpdate block.
For the second just use Wait(2.0) in your initialising function - no need to have it in a while loop.
If at all possible, avoid using RegisterForUpdate unless you absolutely must have your OnUpdate called at precisely 2 second intervals, and you know there will be enough CPU time to handle every call, and you know people will never uninstal your mod and then try to carry on with the same savegame. Ok, that last one isn't such a major point, I understand, but it's still best practice to avoid using RegisterForUpdate if you can avoid it.