How to pass a variable by reference in C++ function called in Blueprints

By default, when a non-const reference is specified in a function, it will be treated by Blueprints as an output parameter: Show/hide content UFUNCTION(BlueprintCallable) static void RemoveDots(FString& String) { String.ReplaceInline(TEXT("."), TEXT(" ")); } There is a macro called UPARAM which is not widely used, but can control the behavior of parameters specified in UFUNCTIONs. In particular, it can change the behavior of passing non-const references by specifying a ref meta:...

August 14, 2022 · 1 min · Georgy Treshchev

How to async task in Unreal Engine

Unreal Engine has a nice feature called AsyncTask, which is used to execute a code asynchronously. It works by running certain code on a specified thread, and this functionality is mostly used when the task is heavy enough to be executed instantly without blocking the game thread. It also provides a solution to all issues arising from multithreading, in particular, accessing parameters from one thread that are supposed to be used and/or edited in another thread....

July 31, 2022 · 2 min · Georgy Treshchev

How to create a multi-threaded for loop in Unreal Engine

Unreal Engine has different approaches to parallelize your code and one of them is ParallelFor. It is used when it is necessary to execute code multiple times with different number-based inputs, basically what a regular for loop does. But unlike a regular for loop that executes sequentially, ParallelFor runs on different threads, with possible different order of execution. Let’s say our task is to simply sum the values from the TArray<int32> array....

July 23, 2022 · 2 min · Georgy Treshchev

Reducing build size of Android or iOS game in Unreal Engine

There are multiple ways to reduce the build size. But on mobile platforms, this issue is most acute. I will show you how I managed to reduce the size of my Android game from 150MB to 50MB. Project settings There are many switches in the project settings that will help reduce the build size. The first thing you can do is set “Build Configuration” to “Shipping” and enable “For distribution”:...

June 12, 2022 · 3 min · Georgy Treshchev
An illustrative example with a comparison

How to integrate third-party library into Unreal Engine

Concept There are two main types of libraries: Static and Dynamic (also called Shared). A static library is statically linked to a program and is available at compile time. A dynamic (or shared) library, on the other hand, is dynamically linked and available at runtime. Static linking assumes that the library code is built into the final block of code, unlike dynamic linking. But the process of dynamic linking takes some time....

May 27, 2022 · 7 min · Georgy Treshchev