Codementor Events

How and why I built A standard function library for Unreal Engine 4 to be used in all my projects

Published Nov 02, 2020Last updated Nov 11, 2020

About me

I'm a programmer, artist and director, but often have to take on even more roles in my solo work.

The problem I wanted to solve

I don't like to use UE4 C++; there API bothers me, and on top of that the people in my dev team aren't programmers so it's easier to just use UE4 Blueprints. The issue with these though is that sometimes simple operations such as incrementing an integer by a certain amount can be more convoluted in the BP.

What is normally written as x += 2 in UE4 BP has to be written as Get X > Add (2) > Set X. Written in Nodes thats much longer. A worse example is getting the X value from the Vector of a Transform. In C# that would be myTransform.Vector.X += 2 but in UE4 it would Get MyTransform > Break Transform > Get Vector > Break Vector > Get X > Add (2) > Make Vector (New X, OldY, OldZ) > Make Transform (New Vector, Old Position, Old Rotation. And again this is written using nodes and wires so it can really slow down the coding process. Ideally the time it takes for me to think what to do it and it be typed is very short and succint.

What is A standard function library for Unreal Engine 4 to be used in all my projects?

I developed a wide function library that's always being added on to as needed that dramatically shortens many functions commonly used. This also includes macros, so I can easily do a nested loop or even a double nested loop, something that is normally messy. There's also a lot of casting add, added functionality to certain types; for example now I can add two colors together, something that was never an option for some reason.

Tech stack

The process of building A standard function library for Unreal Engine 4 to be used in all my projects

As I work, I basically go, "I'm really tired of typing this exact thing again and again so many types," and that's always a que in programming to consolidate that functionality into a function for reusability.

Challenges I faced

The hardest thing about the library is that these functions have to work 100% of the time, because when I'm working on something else and that isn't working, I need to trust that it's not the library functions that's failing me. I would much rather it be something I am doing on currently that's messing up, otherwise I have to look into what's supposed to just be a black box, remember what's going on in that function and then fix it, and it can be confusing having to switch back and forth. Luckily this rarely ever happens.

Key learnings

It really amazed me how often I'm repeating the same functions. I feel like at this point I'm hardly even using the original API because every BP script I'm using at least one of my library functions.

Tips and advice

If you want to do this yourself, be consistent in your naming and organization conventions. Also, you can change the nodes icon to any ASCII code name which makes it look more like an operator so reading the code is more succinct. Instead of having a wall of text that the nodes normally are, you can see the one character or two and know what it is.

Final thoughts and next steps

This project is really a beavers dam for me in the sense it'll never be done, which excites me. I wonder what this will look like in ten years.

Discover and read more posts from Austin Bryan
get started
post commentsBe the first to share your opinion
Show more replies