x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

How to show FPS ingame?

Hi, I know how to show FPS in the editor, but how to show them while playing?

Product Version: Not Selected
Tags:
more ▼

asked Mar 23 '14 at 09:09 PM in Using UE4

avatar image

Albert Espín
967 80 98 358

avatar image Midsoft Games Sep 07 '16 at 09:37 PM

1) In the level blueprint, create an Event BeginPlay. 2) Add an Execute Console Command. 3) The command will be "Stats FPS". 4) Connect the Event BeginPlay with the Execute Console Command.

In the toolbar, hit "Launch" to test it, because if you will play it in the editor, you won't be able to see the FPS.

avatar image robotnicbw Oct 18 '16 at 01:34 PM

the command should be "stat fps", not "stats fps".

(comments are locked)
10|2000 characters needed characters left

5 answers: sort voted first

It's possible to show FPS on mobile iOS/Android?

Updated:

1) Open Level Blueprint from toolbar

2) Add function 'Execute Console Command'

3) Enter 'stat FPS' in 'Command' field

4) Attach 'Event Begin Play' to 'Execute Console Command'

5) Click 'Compile' in toolbar

6) Run on device

more ▼

answered Mar 24 '14 at 03:25 PM

avatar image

megahard
196 12 17 30

avatar image NeroViper Nov 26 '14 at 03:23 PM

old thread but in case anyone was wondering: you can also access the console commands in mobile with 4 finger tap

avatar image Craftiernemesis Mar 29 '16 at 01:28 AM

How did you know that ? :D , It works.

avatar image gnuchev Sep 07 '16 at 09:11 PM

Thank you, it's very helpful!

avatar image sws_s4 Aug 19 '18 at 07:31 PM

Can I suck u ? xD

Thanks

(comments are locked)
10|2000 characters needed characters left

Console Command

press ~

type

 stat fps

As a Console Command At Level Start

https://answers.unrealengine.com/questions/16340/executing-console-commands-at-game-start.html

Rama

more ▼

answered Mar 23 '14 at 09:10 PM

avatar image

Rama
10.6k 446 343 1085

avatar image Albert Espín Mar 23 '14 at 09:16 PM

Thanks, Rama, you're everywhere! Apparently in some keyboards it's the ^ key. Is there a way to make it also show when playing in "Selected Viewport"?

avatar image Rama Mar 23 '14 at 09:18 PM

you're welcome!

please check mark my reply above if it answered your question, and try to comment on my answer to keep everything in one place :)

avatar image Albert Espín Mar 23 '14 at 09:58 PM

Checked. The console command works great, done just as in Kismet.

(comments are locked)
10|2000 characters needed characters left

'stat unit' may be also useful. This will show game and render thread times.

more ▼

answered Mar 24 '14 at 03:49 PM

(comments are locked)
10|2000 characters needed characters left

I did not find the standard function to get the frame rate in C++ so I get them this way:

Tick execute in second so many times how many frames per second is displayed, so you can count how many times was called tick per second using a timer.

alt text

 void AGameCharacter::BeginPlay()
     {
         Super::BeginPlay();
         
         FTimerHandle FPSTimerHandle;
         GetWorld()->GetTimerManager().SetTimer(FPSTimerHandle, this, &AGameCharacter::ShowFrameRate, 1.f, true);
     
     }
 
     int FPS = 0;
     
     void AGameCharacter::Tick( float DeltaTime )
     {
         Super::Tick(DeltaTime);
     
         FPS++;
     }
 
     void AGameCharacter::ShowFrameRate()
     {
         GEngine->AddOnScreenDebugMessage(0, 1.f, FColor::Yellow, "FPS: " + FString::FromInt(FPS) + " ms: " + FString::SanitizeFloat(FApp::GetDeltaTime() * 1000));
         FPS = 0;
     }
 
 
 


more ▼

answered Jul 02 '15 at 03:51 PM

avatar image

Syntopia
222 22 27 45

avatar image Asad_kaleem Sep 30 '16 at 09:57 AM

Hi Syntopia! Can you tell me how to stop this timer after 30 seconds in showframerate() function.

avatar image Syntopia Sep 30 '16 at 03:58 PM

As a variant, you can create another timer, so that he called 1 time after 30 seconds launch.

GetWorld()->GetTimerManager().SetTimer(SomeTimerHandle, this, &AGameCharacter::StopShowFrameRate, 30.f, false);

StopShowFrameRate() { GetWorld()->GetTimerManager().ClearTimer(FPSTimerHandle); }

(comments are locked)
10|2000 characters needed characters left

You can get stat fps data directly from engine. It stores in global engine variables GAverageFPS and GAverageMS (defined in UnrealEngine.cpp for use with extern). It calculates every engine tick by the next algorithm:

 // Calculate the average frame time via continued averaging.
 static double LastTime    = 0;
 double CurrentTime        = FPlatformTime::Seconds();
 float FrameTime            = (CurrentTime - LastTime) * 1000;
 // A 3/4, 1/4 split gets close to a simple 10 frame moving average
 GAverageMS                = GAverageMS * 0.75f + FrameTime * 0.25f;
 LastTime                = CurrentTime;
 // Calculate average framerate.
 GAverageFPS = 1000.f / GAverageMS;

I'm looking now for a stock functionality to get it in blueprint, but if there is no such, you can create yours. Example:

 float UMyFunctionLibrary::GetAverageFPS()
 {
     extern ENGINE_API float GAverageFPS;
     return GAverageFPS;
 }

more ▼

answered Apr 05 '18 at 11:43 AM

avatar image

polterageist
6 2 4 5

avatar image Thunderreed Jul 10 '18 at 03:32 AM

I am wondering if I need to get GAverageFPS from a plugin, then how should I do to get this variable?

avatar image polterageist Jul 10 '18 at 04:44 PM

Exactly the same way as I showed above. Type "extern ENGINE_API float GAverageFPS;" inside the plugin's function. Here is no difference.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question