m00nB33r
(m00nB33r)
November 24, 2023, 11:23pm
1
I know this should be easy, but I’m mentally fried and just… Drained…
I need to do this in C++, but in reality the algorithm should be the same in BP I suppose.
I need to allow for a config setting in DefaultGame.ini
This setting allows someone to specify how many times a second a timer will get fired off.
As an example if I have this in my config file.
queryPerSecond = “5”
This indicates that the user wants this to happen 5 times a second.
queryPerSecond=“18”
This indicates that the user wants this to happen 18 times a second.
At runtime I am pulling this setting, converting it to a float.
I know that there are 1000 milliseconds in 1 second.
What is the math to figure this out?? I’ve tried dividing by various numbers, multiplying by various numbers, but… It’s being painfully elusive!
I know… This should be super easy. Like I said. My brain is shot today. Been jamming on C++ code for days.
1 Like
Leomerya12
(Leomerya12)
November 24, 2023, 11:42pm
3
Do you want this in C++?
Or you’re okay with BP like EVERYNONE just showed you?
m00nB33r:
I need to do this in C++
Can you take a screenshot of your C++ if it is the case that it needs to be in C++?
I haven’t done Unreal in C++, so I’m not sure what the format is.
m00nB33r
(m00nB33r)
November 25, 2023, 3:42pm
4
Hi Everynone, Leymerya.
Thanks for chiming in, I really appreciate it! I got it… Sometimes you just have to walk away from it all and come back fresh the next day… For some reason I was fixated on dealing with milliseconds, and thinking to myself they needed to be calculated in somehow, making it more difficult than it was.
Here is what I came up with and it seems to be working the way I need…
float hertz = 5.0f;
float runRate = 1.0f / hertz;
_world->GetTimerManager().SetTimer( _timerHandle, this, &ThisClass::SomeFunc; runRate, 1.0f );
Hertz is actually stored in my DefaultGame.ini and using Unreal’s settings functionality to pull it out… But you get the drift.
3 Likes