Elapsed time between two functions
Hi all, I set up a system that takes FPS into account when measuring time, so 10 fps lads don't get an advantage over 600 fps lads. Now, I need to check if it works properly so I need to have a timer that starts counting after a certain function, and stops counting after a certain function then gives me the time in seconds. The two functions are Setters, they are to set the enum state of a mechanical gate in the game:They have a height from which they are open, they move and after a height they are closed. They player has to enter just the right time, and as I gave heights, and use the Tick event to move the gates, needless to say that the FPS plays a huge role in the game. So, these gates have a couple of states, but I care about two now: "CanEnter" and "TooLate". All the game logic is set, I just need to start a timer right after the state is changed to "CanEnter" and I need to stop it, and display the time right after the state is "TooLate". I saw timers on the net that count backwards. I need one to count forward and tell me the time. How to do this?
asked Jul 12 '16 at 09:57 AM in Blueprint Scripting
Thanks yet again for the help, I will have to start paying you tuition fee :D Now, In the meantime I got it solved myself. I wanted to measure the time that the game takes to switch the two states, not the whole gaming time. I got it by incrementing the delta seconds from tick event in a variable and setting it back to 0 after printing it just after the other state. The main goal is a success now: No matter the game's frame rate, the player's reaction time has to be exactly the same. So if I demand a 0.15, (it will be 0.150004 anyway, processor speed), so 0.15 both on 60 fps, 20 fps and 600 fps. I spent half a day setting this up because of the diversity of Android devices, and this system actually takes the FPS drops into account as well, as soon as they appear. Simple physics, really, wonder why it took me this long. I mentioned those gates. The gate's speed is got by this: I have a max distance that it has to travel. I calculate it, easy as ABC. Then I divide it by the time I want the gate to go from bottom to top. I multiply the answer with the frame's delta seconds (= i divide by the FPS) and I have the gate speed, measurement in units/frame. Then I have the distance, multiply it by the reaction time required (in secs), and divide by the secs needed to go from bottom to top (this last step to get a unit). and this will be the height difference that the gate can travel while it is open. I sent this post so I can check if it works, and yes, it does. After all, a reaction time based game has to be accurate.
Follow this question
Once you sign in you will be able to subscribe for any updates here