It just that i have to write a long line and then declare a function in the header and implement it in the cpp file only to make a simple delay.
In javascript for example you can do something like that:
setTimeout(function()
{
...
},300);
But when i tried to use lambda within the timer function it says it couldn’t convert what he needs to lambda.
Is it really have to be such a mess only to make a simple delay ?
I’d like to emphasize the need of being extra careful when using that method. I’ve used the following:
Callback.(&] {
IsHit = false;
});
Looks quite harmless, right? Well it’s not because when loading a new level with ‘OpenLevel’ it ‘sometimes’ (randomly) happens to have that ‘&]{}’ reference to the ‘this’ (this being an anim instance) object that was destroyed, and the timer manager attempts to call the ‘this->IsHit = false’ causing a crash, since not binding it to a certain objects the timer still lives even after the object was destroyed.
If you use that method and require a reference to an object that might get destroyed, make sure to clear the timer when loading a new level or to clear the timer when fit.