skip to Main Content

Static Keyword Explanation

The static keyword meaning can differ between functions and variables:

  1. A static function in a class means that you don’t need to create an actual instance of a class to access a specific function which is marked as static
  2. A static variable inside a class means tha exactly same thing. However, sometimes you can declare a static variable inside of a specific function. This means that the specific variable is going to get initialized only the first time the function is executed, and every time after that it’s going to hold on its value even if we change it.

Creating a Static variable

To demonstrate the use of a static variable I created an Actor and in the Tick function I typed in the following code:

Create a Blueprint which inherits from TickingActor and place it into your level. Your output log should now contain:


Note:In this case, if you execute your code again the variable x is going to start from the value it had the moment you stopped playing.

Avatar photo

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top