# ShowFPS Problems! (How to make ShowFPS NOT FLIPFLOP???)

**URL:** <https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918>\
**Category:** UI\
**Tags:** toggle, fps, unreal-engine, question, UMG\
**Created:** [August 13, 2017, 9:16pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918 "2017-08-13T21:16:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_0746fae6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0746fae6](https://forums.unrealengine.com/u/anonymous_user_0746fae6)\
**Post date:** [August 13, 2017, 9:16pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/1 "2017-08-13T21:16:52Z")

</div>

I’m trying to set up a bool which loads and saves. This bool will set “Show FPS” to true or false.

The problem I run into is:  
Trying to use the same console command “showFPS” makes it flip flop.

When I load, whether or not the bool is true or false, “showFPS” will just flip flop.

Basically I want to be able to set “showFPS 1” or “showFPS 0”

Is this possible? Or is there another way I can allow the FPS to be seen or unseen in UMG?

---

<div class="post-metadata">

**Author:** ![TornadoTwins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TornadoTwins](https://forums.unrealengine.com/u/TornadoTwins)\
**Post date:** [August 13, 2017, 9:56pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/2 "2017-08-13T21:56:02Z")

</div>

Instead of calling the console command on Begin Play, use a function that adds some logic before calling the command.Then, when the function is called, flip a boolean var to 1 so that you know it’s on.  
Next time the function is called, flip it to 0.

It’s not exactly the answer you are looking for, but if you keep track of every call, it should solve your problem. You can simply read out the boolean to see if the FPS is visible or not.

Additionally, you can do your own calculation of event tick and delta time to create your own FPS counter in a BluePrint Widget… although it would be just a touch slower than the engine one.

---

<div class="post-metadata">

**Author:** ![TornadoTwins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TornadoTwins](https://forums.unrealengine.com/u/TornadoTwins)\
**Post date:** [August 13, 2017, 9:57pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/3 "2017-08-13T21:57:19Z")

</div>

As for the second point, here’s a custom FPS counter you could use:

> **[Simple custom FPS counter with a frame buffer](https://forums.unrealengine.com/showthread.php?137596-Simple-custom-FPS-counter-with-a-frame-buffer)**
>
> Here is a custom FPS counter that I built in about five minutes, and while I expect most of you can easily do this on your own I thought it might be helpful for some beginners. This is probably not the most efficient way, but it does it’s job. You...

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0746fae6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0746fae6](https://forums.unrealengine.com/u/anonymous_user_0746fae6)\
**Post date:** [August 13, 2017, 10:01pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/4 "2017-08-13T22:01:58Z")

</div>

I’ve been trying for some days now and I don’t want to suffice with anything other than showFPS 🙂

---

<div class="post-metadata">

**Author:** ![TornadoTwins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TornadoTwins](https://forums.unrealengine.com/u/TornadoTwins)\
**Post date:** [August 13, 2017, 10:12pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/5 "2017-08-13T22:12:20Z")

</div>

Ok, in this example I’m using the 3rpderson template.

Open the ThirdPersonCharacter blueprint.

Create a new function (hit the plus sign next to functions)  
Call it “toggleFPS”  
Add this logic:

 ![193573-capture1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/3/b/e3b259ab782583064adf5c59005a0932cd9da493.png)

Now, go to the Event Graph of this blueprint.  
Add “key F” as an event (to make sure the FPS toggles when we press F) and wire the “pressed” action to your ToggleFPS function, like so:

 ![193575-capture2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/2/6/726d3edbc124b105461973d3fcebec75459bf42e.png)

---

<div class="post-metadata">

**Author:** ![TornadoTwins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TornadoTwins](https://forums.unrealengine.com/u/TornadoTwins)\
**Post date:** [August 13, 2017, 10:13pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/6 "2017-08-13T22:13:56Z")

</div>

I forgot to say, when adding the logic, that you need to add a boolean variable. I’ve called it “FPSIsVisible” in this example.

Now all you need to do to figure out if the FPS counter is visible, is check if the boolean is true.

---

<div class="post-metadata">

**Author:** ![TornadoTwins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TornadoTwins](https://forums.unrealengine.com/u/TornadoTwins)\
**Post date:** [August 13, 2017, 10:22pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/7 "2017-08-13T22:22:59Z")

</div>

Ah ok, so you want to do it in the widget. It’s pretty much the same. Instead of creating this function and boolean on the player, add it on the widget. And, instead of calling it with the F key, call it when the checkbox changes.

That’s the logic for in-game. Now the logic when the game starts:  
I’m assuming you are already saving the value of the checkbox (using SaveGame node, or whatever) when the game starts up again. Then, on Begin Play, check that variable, set it to the checkbox (true/false), and call the function again.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0746fae6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0746fae6](https://forums.unrealengine.com/u/anonymous_user_0746fae6)\
**Post date:** [August 13, 2017, 10:25pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/8 "2017-08-13T22:25:32Z")

</div>

Right-o. This actually makes more sense for me right now.  
BUT I did mention that I want to use an Apply button in my first comment to you.

OnValueChanged would be so easy, but how can I detect if the value has changed before I hit apply?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0746fae6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0746fae6](https://forums.unrealengine.com/u/anonymous_user_0746fae6)\
**Post date:** [August 13, 2017, 10:32pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/9 "2017-08-13T22:32:51Z")

</div>

I have logic for Load, Apply, Save.  
But when I hit Apply button I have to make sure the checkbox value has changed. Otherwise, it will fire again possibly making it show/disappear when it should have done the opposite.

---

<div class="post-metadata">

**Author:** ![TornadoTwins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TornadoTwins](https://forums.unrealengine.com/u/TornadoTwins)\
**Post date:** [August 13, 2017, 10:40pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/10 "2017-08-13T22:40:26Z")

</div>

The apply button doesn’t really have to check if any values have changed. You just check if the value of the checkbox (after hitting apply) is the same as the boolean you use when flipping the FPS on or off. If it’s not the same, call the function. Else, don’t do anything.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0746fae6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0746fae6](https://forums.unrealengine.com/u/anonymous_user_0746fae6)\
**Post date:** [August 13, 2017, 11:15pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/11 "2017-08-13T23:15:07Z")

</div>

So this is what I did:  
Create Function  
Load, Apply, Save  
But on Apply button it always flip flops

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0746fae6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0746fae6](https://forums.unrealengine.com/u/anonymous_user_0746fae6)\
**Post date:** [August 13, 2017, 11:15pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/12 "2017-08-13T23:15:34Z")

</div>

It doesn’t matter what the value of the bool is lol…it will ALWAYS do the SAME console command which just flips it… what a bummer man  
It doesn’t even load properly because this bool doesn’t mean anything

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0746fae6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0746fae6](https://forums.unrealengine.com/u/anonymous_user_0746fae6)\
**Post date:** [August 13, 2017, 11:26pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/13 "2017-08-13T23:26:27Z")

</div>

I don’t get your logic. You don’t need the bool. You need a flip flop. And it doesn’t do anything except on load → not do what checkbox says.  
On apply → not do what checkbox says

---

<div class="post-metadata">

**Author:** ![TornadoTwins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TornadoTwins](https://forums.unrealengine.com/u/TornadoTwins)\
**Post date:** [August 13, 2017, 11:56pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/14 "2017-08-13T23:56:49Z")

</div>

Sorry I wasn’t behind a computer for a while.

Correct, the checkbox is a bool itself. However, the “show fps” command doesn’t have an on/off switch, so you have to keep track of it being toggled yourself. That’s why I recommend wrapping it in a function and using a boolean (as shown in my screenshots) to see if the FPS counter is on or off.

Now, when your UI changes and you press Apply, you can check this boolean to see if the UI is on or off and flip it accordingly to what the user put into the UI.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0746fae6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0746fae6](https://forums.unrealengine.com/u/anonymous_user_0746fae6)\
**Post date:** [August 13, 2017, 11:58pm UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/15 "2017-08-13T23:58:34Z")

</div>

I tried but I have failed. Can you show me directly with a checkbox in UMG?  
I assume it would work with “on startup, load saved bool” (since the function makes the check??)  
Just let me know which bool to save! Is it your bool or the UMG checkbox bool?

Thx if you can

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0746fae6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0746fae6](https://forums.unrealengine.com/u/anonymous_user_0746fae6)\
**Post date:** [August 14, 2017, 12:04am UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/16 "2017-08-14T00:04:52Z")

</div>

A BIG thing is the Apply button. I’m able to check the box before I hit Apply. So my logic there didn’t work out. Idk how you managed to do it. I edited the comment before this if it makes sense, lmk?

---

<div class="post-metadata">

**Author:** ![TornadoTwins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TornadoTwins](https://forums.unrealengine.com/u/TornadoTwins)\
**Post date:** [August 14, 2017, 12:05am UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/17 "2017-08-14T00:05:09Z")

</div>

You would save the UMG checkbox bool - because you only want to know what the users’ preference is.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0746fae6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0746fae6](https://forums.unrealengine.com/u/anonymous_user_0746fae6)\
**Post date:** [August 14, 2017, 12:05am UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/18 "2017-08-14T00:05:58Z")

</div>

I save and load it just fine. But your function uses a totally separate bool.  
Also I can change the checkbox to true/false before I hit Apply, which messes things up.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0746fae6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0746fae6](https://forums.unrealengine.com/u/anonymous_user_0746fae6)\
**Post date:** [August 14, 2017, 12:06am UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/19 "2017-08-14T00:06:59Z")

</div>

Have you tested with a custom button, instead of doing it “OnValueChanged”?  
You might see the error I’m running into.

---

<div class="post-metadata">

**Author:** ![TornadoTwins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TornadoTwins](https://forums.unrealengine.com/u/TornadoTwins)\
**Post date:** [August 14, 2017, 12:16am UTC](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918/20 "2017-08-14T00:16:16Z")

</div>

I didn’t test this code, but here’s how I would do it. This blueprint is a widget with a checkbox and apply button.  
I’ve added two functions: saveVariableToDisk() and loadVariableFromDisk() where you would do your saving and loading.

the toggleFPSVisibility() function is the same as above, but in the widget this time.

The rest should explain itself. Let me know if it’s unclear?

 ![193578-capture3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/5/8/958ef4f7c3ffb74c97cee60e9152541c5caaa80f.png)

[Next page](https://forums.unrealengine.com/t/showfps-problems-how-to-make-showfps-not-flipflop/401918.md?page=2)
