ModularFeature:为UE4集成ZSTD压缩算法

UE uses Zlib by default as the compression algorithm for packaging resources, but it is not the best choice in terms of compression ratio and decompression speed. The efficiency comparison of various compression algorithms can be seen from the Squash Compression Benchmark. I chose the Facebook open-source ZStandard to replace Zlib, as ZSTD provides a good compression ratio while also having decent decompression speed. This article will not only explain how to integrate a compression algorithm into UE but will also briefly introduce a modular organization method for some features in UE—ModularFeature. Using this method makes it easy to replace certain functionalities, and the replacement compression algorithm in this article serves as a practical example.

I integrated ZSTD into UE by writing a plugin. The source code is available on GitHub: hxhb/ue-zstd, which supports Android, Windows, iOS, and macOS. Feel free to give it a star.

Read more »

UE热更新:基于UnLua的Lua编程指南

UE uses C++ as a compiled language, which means it becomes binary after compilation, and players can only update the game by reinstalling it. However, in game development, there’s often an urgent need for requirement adjustments and bug fixes, and frequently prompting players to update the app is unacceptable. Generally, game projects use Lua as the scripting language to transform the immutable C++ code at runtime into updatable Lua code.

Although UE does not officially support Lua, Tencent has open-sourced UnLua, which is being used in my current project. Over the past few days, I’ve organized some materials on UnLua (mainly the official documentation, issues, and presentation PPT) and combined it with my own experience from testing UnLua while writing a small demo, resulting in this programming guide for UE combined with UnLua. This article summarizes some basic methods and pitfalls for using UnLua to write business logic and will be updated continuously.

Additionally, Lua files can be packaged into Pak using my previously open-sourced tool: hxhb/HotPatcher. I’ve also modified a version based on UnLua, adding some extra optimizations. The source code integrates the Luasocket/Luapanda/lpeg/Sproto/Luacrypt libraries, and you can use LuaPanda for debugging. The GitHub address is: hxhb/debugable-unlua.

Read more »

UEC++与标准C++的区别与联系

Due to the impact of COVID-19, I’ve been confined at home throughout the Spring Festival, and I haven’t returned to work yet. I can only read books and organize my notes, hoping the pandemic ends soon and that my friends stay healthy.
The main content of this article is to analyze the differences in syntax between the C++ used in UE development and standard C++. UEC++ is essentially a superset of C++, supporting and utilizing all features of C++, but it has built its own syntax on top of the standard features. Many compilation issues during development can only be quickly and accurately identified at different stages by understanding the boundaries between the two. For those who learned C++ before using UE, this isn’t a problem, but for students who first encounter UE and then gradually learn C++, this can be quite a significant issue.

Standard C++ is based on the language standard ISO/IEC 14882 (C++98/03/11/14/17, etc.), while UEC++ is Epic’s extended usage built on standard C++. This article will not cover topics like GC or reflection or various libraries in UE, focusing instead on the core syntax level.

Read more »

UE源码分析:修改游戏默认的数据存储路径

By default, after packaging a game with UE and installing the Apk on a phone, launching the game will create the game’s data directory under /storage/emulated/0/UE4Game/ (which is at the root of the internal storage). According to Google’s rules, it is best for each app’s data files to be placed in their own private directory. Therefore, I want to put all the game’s data packaged by UE into the directory /storage/emulated/0/Android/data/PACKAGE_NAME (regardless of whether it’s log, ini, or crash information).
This seemingly simple requirement has several different approaches involving UE4’s path management, JNI, Android Manifest, and analysis of UBT code.

Read more »

UE资源热更打包工具HotPatcher

Important Notice: The author has no platforms or channels to record paid courses, and does not endorse any third-party commercial activities. Please be vigilant and beware of being deceived.
The open-source agreement for this software: It allows free use of functions in commercial projects, but does not permit any third party to charge for any form of secondary compensation based on this plugin, including but not limited to recording paid courses, redistributing the plugin and code, etc.

HotPatcher is a tool for managing hotfix versions and resource packaging, used to track changes in the original resources of the project version to create patches. It supports one-click cooking for multiple platforms, one-click packaging for multiple platform patches, and the editor supports Windows and MacOS. Writing a set of processes to download patches from the server completes a comprehensive game hotfix solution. HotPatcher has been used in many UE projects and will continue to update to support new engine versions. Issues are welcome.

HotPatcher differs from the Patch mechanism in UnrealFrontEnd, as there are some issues with UE’s Patch management project: based on the original project version, it is challenging to create exactly the same patch on different computers, and it is not possible to generate another patch based on the patch version. Additionally, the contents of the patch cannot be previewed intuitively. It is also inconvenient to package external files into pak (such as lua files, db, and other non-assets, which often reside outside the Content directory) and to manage project and patch versions easily.

This plugin aims to solve such problems, using the project’s original resources as version references, managing only the project itself without worrying about other files generated by UE. Moreover, it facilitates operations such as Cooking/generating Pak/extracting resource information from basic packages/version diffs/Patch splitting, etc. It features abundant configuration options and Commandlet support, making it easy to implement automated hot update packaging processes.

Currently supported engine versions are UE4.21-UE5, and it supports the IoStore mechanism! Many friends have privately messaged me with questions about the plugin, so I created a group to discuss UE hot updates and HotPatcher plugin issues (QQ group 958363331). You are welcome to join and exchange technical information related to UE.

To conveniently collect and manage common questions and solutions regarding hot updates and HotPatcher, I have created an article to document and organize them: UE4 Hot Update: Questions & Answers. If you encounter problems, you can check this FAQ page first. Regarding the feedback from many users about inconsistencies between the plugin configuration parameters and the previous recorded videos, it is because the plugin has undergone many updates and iterations. For details on each version’s changes, see the Update Log.

Read more »

UE项目的设计规范和代码标准

Recently, a new project has been initiated, summarizing some issues from previous projects and listing design specifications and code standards for UE development projects (the term “code standards” seems too strict; coding habits are quite subjective, and “coding conventions” would be a better term, but strict execution is necessary for promotion within the team). This article will be continuously updated and organized, and feedback and discussions are welcome.

Read more »

The latest version supports UE5, see the UE5.0 branch on github: ue4-export-nav-data/tree/UE5.0.

Recast Navigation is an open-source game navigation/pathfinding engine that provides pathfinding calculations for AI in games. Both UE and Unity integrate RecastNavigation to provide navigation and pathfinding calculations for games (of course, in modified versions). The UE modules NavigationSystem and NavMesh contain relevant code implementations. Recently, there was a requirement to export the client’s map information to a server with a non-UE network architecture, for verifying player locations on the server. It occurred to me that the navigation data generated by the client could be exported as a map of the client world, so I tinkered and wrote a UE plugin (open-sourced on Github: ue4-export-nav-data) that implements directly exporting the navigation data generated by UE. If interested, you can directly view the specific code. Based on the exported navigation data, pathfinding calculations based on Recast Navigation can be fully implemented on the server with a non-UE network architecture, seamlessly integrated with UE.

2019.12.04 Update: This plugin has been listed on the Unreal Marketplace, purchase link ExportNavigation. In support of programmer sentiment for open-source, this project’s repository on Github will not be closed, but it is unlikely to be updated. If this plugin is useful to you, feel free to purchase it on the marketplace to support the author.

Read more »

Oculus Quest is the new generation of all-in-one VR headset released by Oculus, supporting 6DoF, with no need for a PC connection or additional positioning base stations. It also supports Guardian; when the user walks out of the positioning boundary while wearing the headset, real-world visuals will immediately display in the headset to prevent accidental mishaps.

The Oculus Quest features two Pentile OLED screens, with a single-eye resolution of 1440x1600 and a refresh rate of 72Hz, powered by a Qualcomm Snapdragon 835 processor based on the arm architecture, which is the same as the flagship processors from two years ago (such as Xiaomi 6, Samsung S8).

Quest employs the Oculus Insight (inside-out tracking) positioning solution, using four cameras located at the four corners of the headset panel for positional tracking.
The introduction of Oculus Insight during the release event: Oculus Insight VR Positional Tracking System (Sep 2018)

And a video of a user’s test of Quest’s tracking range abroad: Quest Distance Test.

The 64G storage version of Oculus Quest is priced at $399, while the 128G version costs $499, with tax-excluded prices roughly around 3500; compared to HTC’s similar new product (HTC Vive Focus), it is significantly cheaper, and it offers even greater advantages over PC-Based VR since it does not require a high-performance host. I believe that 6DoF all-in-one VR devices must be the trend of the future!

Before the National Day holiday at OC6, Oculus announced two technologies: Oculus Link and finger tracking, both are impressive and promising.

The entire Quest device is about the same size as a 10.5 inch iPad, making it easy to carry in a small bag:

There’s no need to elaborate on the specifications of the Quest device; the main content of this article will focus on the environment setup, development documentation, debugging tools, and additional considerations when using UE to develop Quest projects, which will be updated continuously.

Read more »

Module is the basic element that constitutes Unreal. Each Module encapsulates and implements a set of functions, which can be used by other Modules. The entire Unreal Engine is driven by the combination of various Modules, and even the game project that we create is a separate Module.

So how does UE create and build these Modules? This is the main purpose of writing this article, to study Unreal’s build system and the various properties they support (Target and Module).

It is recommended to read my previous article before looking at this one: Build flow of the Unreal Engine4 project, which mainly outlines the build process of UE; this article is merely one part of the UE build system.

Read more »