I’m having a strange issue working with timers. I have a function set up which when called on its own, works perfectly. I can even call it using delays from within blueprint and it also works fine. As soon as I use a timer, whether it be in C++ or Blueprints, however, my function becomes buggy. The function itself does nothing special, but it does have a timer within it, which calls another function that also has a timer within it. Both functions are using the same ***FTimerHandle ***(declared in the .h), and I have them set up as follows:
First function (MyFunction_1):
GetWorld()->GetTimerManager().SetTimer(MyHandle, this, &ABaseCharacter::MyFunction_2, 0.1f, false);
Second function (MyFunction_2):
GetWorld()->GetTimerManager().SetTimer(MyHandle, this, &ABaseCharacter::MyFunction_3, 0.2f, false);
There’s some more code in it and if you think it’s useful I’ll share it, but all it does is change some settings to the character mesh and play an animation. What I mean by “buggy” is that when I use a timer to call the first function, the mesh rotates weirdly in one direction and then snaps back a couple of frames later. I am 100% sure there’s something wrong with how I’m using timers and it’s not the other code in the function. It happens if I use a timer in blueprint as well, and all I did in blueprint was use the “set timer” node attached to a custom event which just calls the first function. The weird part is that the function works perfectly fine if I call it without a timer, or if I use a delay instead. Unfortunately there aren’t delays in C++ so that’s not really an option. Since the issue is related to timers I thought it had to do with the TimerManager not being cleared so I called the clear function on it pretty much everywhere in my code to see if it changed anything but it did not. Please note that every timer *is being called; *I had it print a message during each part of the function and it succeeded, so they are definitely being called. They are just causing the function to behave strangely for some reason. Any suggestions?
Thank you for your time!