Can i use lambda with timers?

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.