Designing Deterministic Value Resolution for Competing Gameplay Systems in Unreal Engine
A practical Unreal Engine C++ case study on coordinating multiple gameplay systems that modify the same value through explicit ownership and ordering.
The Value Resolution System (VRS) emerged from the Development of Abilities and Systems (DAS) plugin for Unreal Engine, addressing the need to coordinate changes to values used by various gameplay systems. Recognizing its potential, VRS was developed as a separate plugin, focusing on the interaction between systems influencing the same gameplay value, such as a character's movement speed dependent on equipment, terrain, and scripted restrictions.
VRS defines a system where multiple gameplay systems provide inputs, with one resolver owning its calculation, and an object storing the value. The architecture separates responsibilities, with the object storing the value, the resolver handling calculation, and gameplay systems supplying inputs. This separation allows for distinct questions: who supplies an input and who decides the result.
Changes are organized into layers, with gameplay systems submitting changes through an explicit Flush() evaluation process. Layers have project-defined meanings, such as equipment, terrain, and control restrictions. Storage and calculation ownership are kept separate; the value advert identifies the field through typed C++ member pointers, allowing the gameplay object to retain its storage while VRS coordinates calculation.
One resolver claims a particular descriptor instance and target object, preventing multiple resolvers from independently calculating and overwriting the same registered value. When a second descriptor for the same physical member is declared, it creates a different identity, ensuring direct C++ writes are not intercepted. Callers must share the intended descriptor and avoid competing writes to the managed field.
Changes include an operation, operand, priority, retention flags, and context. Within each evaluation pass, VRS processes layers in index order, checking priority, operations, and ChangeNum. Higher-priority ordinary changes execute later within their layer, ensuring that the execution order becomes a visible rule rather than an implicit contract.
VRS distinguishes lasting changes from ongoing conditions, allowing for separate treatment of the base and contributions evaluated over it. The aggregator initializes its base from the object, class defaults, or supplied settings, while instant changes update the base and retire, and retained modifiers are evaluated over a fresh copy of it. Flags and value bounds are also defined, offering flexibility in how contributions are managed and applied.
Rewritten by urgent.news; may contain errors — check the original.
Source: hackernoon.com