From blueprint beginner to marketplace release - my personal experience

Thanks! One important thing I learned about blueprints is that what works best in other scripting languages isn't necessarily what works best in blueprints.

One reason for this is that you often don't know exactly what is going on under the hood, and things that you feel should be fast are sometimes slower than you'd think. I felt using recommendations for other scripting languages a good starting point, however, but made sure to check the speed of the blueprint whenever I added something new.

I did this by creating a custom macro that recorded the current time. I'd fire this before a piece of code and then substract this number from the current time after the code. This helped me find what parts of the blueprint were causing the biggest slowdown.

As an example of something that would be more efficient in C++, but turned out to be less efficient in blueprint I created a binary heap to organize candidate nodes during pathfinding. Binary heaps are pretty complicated to set up, and required a large network of nodes. For C++, which is lightning fast, going through these extra calculations takes very little time, and so the benefits of using a binary heap outweighs the extra time spent iterating through the code.

For blueprints I found it to be reverse. Therefore another general rule is to try and keep the blueprint as small and simple as you are able. I also structured in a way so that I would do as few checks as possible when running a pathfinding loop. For instance, initially I designed the pathfinding so that it would query if paths were allowed to cross corners or not every time I searched a new step.

Later I optimized this by having a branch node before the pathfinding itself that asked whether crossing corners was allowed and then ran one of two separate functions based on that.

I also discarded using A* and instead used the simpler Dijkstra algorithm, which turned out to be both faster and superior for all turn based strategy puroses.

Also, when working with large arrays try to find a way to use Get-functions whenever possible and try avoiding Find-functions.

/r/unrealengine Thread