Implementation Method of a Lightweight Interaction Framework Based on the UE5 Engine
By providing a lightweight interaction framework based on Vue.js and an optimized WebSocket communication protocol in Unreal Engine 5 (UE5), the problems of low interaction efficiency, insufficient real-time and poor reusability in UE5 development are solved, and efficient development and cross-project reuse are achieved, meeting the needs of low-latency communication.
Patent Information
- Application Number
- CN202510541863.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2045-04-28
AI Technical Summary
In the development of the existing Unreal Engine 5 (UE5), the interaction efficiency between the front-end and the engine is low, the real-time performance is insufficient, the instructions and business logic are strongly coupled, making it difficult to reuse across projects, and the HTTP protocol has high latency in high concurrency scenarios, making it difficult to meet the needs of real-time 3D visualization.
It provides a lightweight interactive framework based on UE5 engine, provides a global object this.$ue5 through the Vue.js plug-in, and encapsulates the API call interface for UE5 engine functions, and supports the front-end to call UE5 functions through standardized instruction sets. The WebSocket protocol is used to build a communication protocol layer, optimize transmission efficiency, and realize low-latency data transmission. At the same time, the instructions are hot updated through the yaml configuration file, decoupled instructions and business logic, and supported cross-project reuse.
It significantly improves development efficiency, reduces the workload of repeated coding of interfaces by 80%, shortens the development iteration cycle by 60%, realizes efficient cross-project code reuse, meets the needs of low-latency communication, and optimizes resource utilization and bandwidth usage.
Smart Images

Figure CN120066471B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a framework implementation method in the UE5 engine, and particularly to a lightweight interaction framework implementation method based on the UE5 engine. Background Art
[0002] In the existing Unreal Engine 5 (UE5) development, the interaction between the front end and the engine usually relies on traditional HTTP polling or communication schemes based on blueprint scripts. At the same time, the following methods are mainly used for function calls:
[0003] C++ / Blueprint development mode: Native functions in UE5 need to be developed through C++ code or blueprint scripts. Developers need to be familiar with the underlying architecture of the engine, and the technical threshold is high. At the same time, in the scenario of front-end and back-end separation, an independent HTTP / REST or WebSocket service needs to be built for communication, and the development cycle is long and the maintenance is complex.
[0004] REST API solution: After the back-end service receives the front-end request, it calls UE5 instructions, and the interface and parameter parsing logic need to be developed repeatedly, with high coupling. The real-time performance is poor, and it is difficult to support interaction scenarios that require low latency (such as real-time object control).
[0005] WebSocket communication framework: Although two-way communication can be achieved, it lacks deep integration with front-end frameworks (such as Vue.js), and developers need to manually manage the connection status and data parsing.
[0006] Therefore, the following defects exist:
[0007] Low development efficiency. The front end and the back end need to synchronously develop communication protocols and functional logics, and repeated coding is required for function expansion. Poor reusability. The instructions and business logics are strongly coupled, and it is difficult to reuse across projects. Insufficient real-time performance. The HTTP protocol is difficult to meet the real-time interaction requirements and requires additional optimization.
[0008] At the same time, there is a high-latency bottleneck. The latency of the HTTP protocol generally exceeds 100ms in high-concurrency scenarios, and it is difficult to meet the real-time 3D visualization requirements. Moreover, the dynamic expansion ability is insufficient. The instruction set expansion requires recompiling the engine or relying on static configuration files, and runtime hot updates cannot be achieved. In addition, the front-end integration complexity is high. Traditional solutions need to encapsulate interfaces through C++ plugins, with low development efficiency and difficult cross-project reuse.
[0009] In view of the above defects, the inventor actively conducts research and innovation in order to create a lightweight interaction framework implementation method based on the UE5 engine, making it more valuable in the industry. Summary of the Invention
[0010] To solve the above technical problems, the purpose of the present invention is to provide a method for implementing a lightweight interaction framework based on the UE5 engine.
[0011] The method for implementing a lightweight interaction framework based on the UE5 engine of the present invention, wherein:
[0012] Provide a global object this.$ue5 through the Vue.js plugin, encapsulate the API call interface for the functions of the UE5 engine, and support the front-end to call UE5 functions through a standardized instruction set.
[0013] The standardized instruction set includes instruction types for scene loading, object control, and animation triggering. Each instruction needs to include a command_type field and a params parameter object. Through the SHA-256 method, a unique command_id field is generated, which can ensure global uniqueness and avoid instruction conflicts caused by counter overflow or reset. Specifically, after serializing the command_type field and the params parameter object in the instruction, calculate the SHA-256 hash value to generate a 32-byte hexadecimal string as the command_id, which effectively prevents malicious tampering and supports instruction deduplication verification.
[0014] Build a communication protocol layer based on the WebSocket protocol to enable low-latency data transmission between the front-end and the UE5 engine. The low latency means that the communication latency in a local area network environment is ≤50ms.
[0015] Specifically, the following optimization measures are adopted for the communication protocol layer:
[0016] (1) Disable the ACK frame: Close the confirmation frame by configuring the permessage-deflate extension of the WebSocket protocol to reduce the handshake overhead.
[0017] (2) Enable TCP_NODELAY: Disable the Nagle algorithm to reduce the transmission latency of small data packets.
[0018] (3) Data frame compression: Enable the LZ4 compression algorithm for JSON instructions, with a compression rate ≥70%.
[0019] (4) Heartbeat mechanism: Set the heartbeat packet interval to 5 seconds to prevent the connection from timing out and disconnecting.
[0020] Set up an instruction parsing layer on the UE5 side to map the JSON-format instructions sent by the front-end to the internal functions or blueprint nodes of the UE5 engine.
[0021] The mapping logic includes: after parsing the command_type field, call the pre-registered C++ function. The parameter name matching rule is full-word matching. Convert the JSON format instruction into the FFloatProperty or FIntProperty of UE5 through a type converter;
[0022] Dynamically register a new instruction set through a configuration file or a hot update mechanism.
[0023] Furthermore, in the above method for implementing a lightweight interaction framework based on the UE5 engine, the global object this.$ue5 supports calling functions for scene loading, object control, and animation triggering.
[0024] The object control function includes: passing a three-dimensional coordinate displacement vector through the position field. The vector precision is retained to 4 decimal places and the value range is [-1000.0, 1000.0];
[0025] Pass the quaternion rotation parameter through the rotation field. The range of the quaternion components is limited to [-1.0, 1.0] and the normalization error ≤ 0.001;
[0026] Modify the object material texture path and transparency value through the material field. The transparency value range is [0.0, 1.0] and the step precision is 0.01.
[0027] Even further, in the above method for implementing a lightweight interaction framework based on the UE5 engine, the communication protocol layer uses a binary and JSON hybrid transmission mode. The key names corresponding to the JSON format adopt the Snake Case naming convention, and the key-value nesting depth ≤ 3 layers. Specifically, the following three modes are included for hybridization:
[0028] 1. Binary mode: When the data volume ≥ 10MB (such as a scene resource package), enable binary sharding transmission. The shard size is 1MB, and the header contains the chunk_index (0 - 9999) and total_chunks fields.
[0029] 2. JSON mode: The key names adopt snake case naming (such as object_id), and the nesting depth ≤ 3 layers to avoid the degradation of parsing performance caused by multi-layer nesting.
[0030] 3. Hybrid verification: After the sharding transmission is completed, verify the file integrity through SHA-256. When it fails, trigger an automatic retransmission (up to three times).
[0031] Even further, in the above method for implementing a lightweight interaction framework based on the UE5 engine, the instruction parsing layer performs the following operations.
[0032] Parse the front-end instructions and execute the corresponding engine operations, including object rotation, position adjustment, and scene status query.
[0033] The response mechanism for the scene status query is to collect scene data through the UE5's every 100ms Tick event, and through the differential algorithm, only transmit fields with a change amount ≥ 5%.
[0034] Push the UE5 engine status to the front-end through the timer mechanism. The trigger interval of the timer is set to 200ms ± 10ms, and the front-end dynamically adjusts it in 50ms steps through the set_interval instruction.
[0035] Furthermore, in the above method for implementing the lightweight interaction framework based on the UE5 engine, the push format of the status is {"event":"Scene.LoadProgress","value":progress value}. If a network interruption occurs, an exception push will be made, and the content of the exception push is {"event":"Error","code":500,"retry_interval":3}. During implementation, the front-end can start the retry mechanism after receiving it.
[0036] Furthermore, in the above method for implementing the lightweight interaction framework based on the UE5 engine, the configuration file is in yaml format, and the save path conforms to the / Config / Commands / *.yaml directory specification. Listen to the file descriptor through epoll for millisecond-level update responses, and verify the yaml syntax before loading; the configuration file realizes hot update by listening to the IN_MODIFY event through inotify, with a response delay ≤ 10ms, and verify the file MD5 hash value before loading to ensure integrity.
[0037] Furthermore, in the above method for implementing the lightweight interaction framework based on the UE5 engine, set an instruction priority queue, assign high priorities to object position synchronization instructions and user interaction events, and when high-priority instructions cut in the queue, it is required to pass the command_id hash verification; the priority flag is priority=high; the cut-in position is limited to the 0th or 1st position backward from the head of the queue.
[0038] Furthermore, in the above method for implementing the lightweight interaction framework based on the UE5 engine, utilize the virtual reality scene to integrate the head-mounted display device's pose data through the OpenXR protocol. The synchronization frequency of the pose data is 90Hz ± 5Hz, and it is processed using the quaternion compression algorithm. The pose data can include position, rotation state, etc., which is convenient for tracking the head movement state.
[0039] Further, in the above method for implementing a lightweight interaction framework based on the UE5 engine, the UE5 side enables the WebSocket plugin and sets the communication port. When the default port 8000 is occupied, the ports are switched in the following order, preferentially selecting 8001, 8003, 8005, 8007, 8009; if there is still a conflict, try 8002, 8004, 8006, 8008, 8010. Simply put, the ports are switched in the order of odd numbers first, and if there is still a conflict, try the even ports. After three consecutive conflicts, an exception code PORT_CONFLICT is triggered and the service is terminated, and the list of conflicting ports is recorded in the log.
[0040] Still further, in the above method for implementing a lightweight interaction framework based on the UE5 engine, the framework realizes cross-project reuse through modular plugins and business logic; the modular plugins are composed of independent Vue.js plugins encapsulated with UE5 functions, and the business logic is injected into the Vue.js plugins through configuration.
[0041] By means of the above solution, the present invention has at least the following advantages:
[0042] 1. The development efficiency is significantly improved, and the front-end framework is deeply integrated: The global object this.$ue5 is provided through the Vue.js plugin, and the API call interfaces for encapsulating the functions of the UE5 engine are realized, so as to automatically generate the front-end and back-end protocols, reducing the workload of interface duplicate coding by 80%. Through the dynamic instruction extension mechanism, the instruction hot update is realized based on the yaml configuration file. When adding new functions, there is no need to recompile the engine, and the development iteration cycle is shortened by 60%.
[0043] 2. The cross-project reusability is broken through. The instructions and business logic are decoupled: Through the standardized instruction set and modular plugin design, the code reuse rate is ≥90% during cross-project migration.
[0044] 3. The real-time interaction performance is optimized, meeting low-latency communication, and a hybrid transmission mode can be realized.
[0045] 4. The resource utilization rate is high, the bandwidth occupancy is reduced, and the processing delay of key instructions can be reduced.
[0046] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly and implement it according to the content of the specification, the following describes in detail with the preferred embodiments of the present invention and in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 It is a schematic diagram of the construction of a lightweight interaction framework based on the UE5 engine.
[0048] Figure 2It is a schematic diagram of the instruction call process of a lightweight interaction framework based on the UE5 engine.
[0049] Figure 3 It is a schematic diagram of the selection process of communication ports in a lightweight interaction framework based on the UE5 engine. Specific implementation manners
[0050] The following combines the accompanying drawings and embodiments to further describe in detail the specific implementation manners of the present invention. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention.
[0051] Such as Figures 1 to 3 The method for implementing a lightweight interaction framework based on the UE5 engine is different in that: a global object this.$ue5 is provided through a Vue.js plugin, and an API call interface for encapsulating the functions of the UE5 engine is used to support the front end to call UE5 functions through a standardized instruction set. Specifically, the adopted standardized instruction set includes instruction types for scene loading, object control, and animation triggering. Each instruction needs to include a command_type field and a params parameter object. The unique command_id field can be generated through the SHA-256 hash algorithm, which can ensure global uniqueness and avoid instruction conflicts caused by counter overflow or reset. At the same time, a communication protocol layer is built based on the WebSocket protocol to enable low-latency data transmission between the front end and the UE5 engine. The low latency is that the communication latency in a local area network environment ≤ 50ms. During implementation, a 12-byte header structure can be built, which is a combination of 4-byte message type + 8-byte timestamp. And the transmission efficiency can be improved by disabling algorithms such as ACK frames and TCP_NODELAY.
[0052] Next, an instruction parsing layer is set on the UE5 side to map the JSON-format instructions sent by the front end to the internal functions or blueprint nodes of the UE5 engine. During implementation, the mapping logic includes: calling a pre-registered C++ function after parsing the command_type field. The parameter name matching rule is full-word matching, and the JSON-format instruction is converted into the FFloatProperty or FIntProperty of UE5 through a type converter. Then, a new instruction set is dynamically registered through a configuration file or a hot update mechanism.
[0053] In view of a preferred embodiment of the present invention, the global object this.$ue5 is adopted to support the functions of scene loading, object control, and animation triggering. Specifically, the object control function includes transmitting a three-dimensional coordinate displacement vector through the position field. The vector precision is reserved to 4 decimal places and the value range is [-1000.0, 1000.0]. At the same time, an error code 301 can be returned when the measured value exceeds the range, or it can be other codes for easy intervention and troubleshooting. At the same time, the quaternion rotation parameter is transmitted through the rotation field. The range of the quaternion components adopted is limited to [-1.0, 1.0] and the normalization error ≤ 0.001. During implementation, it can be processed through Gram-Schmidt orthogonalization correction. After that, the object material texture path and transparency value are modified through the material field. The transparency value range is [0.0, 1.0]. And the step precision adopted is 0.01.
[0054] Furthermore, the communication protocol layer adopted by the present invention uses a mixed transmission mode of binary and JSON. When the transmitted file size ≥ 10MB, binary encoding is enabled and the file is transmitted in fragments. Specifically, the adopted fragmentation rule is: the fragment size is fixed at 1MB, and the fragment sequence number is written into the chunk_index field in the JSON header, and its value range is 0 - 9999. After that, the file integrity is verified through SHA-256 after the fragment transmission is completed. When the verification fails, the retransmission mechanism is triggered. To improve the data integrity, the maximum number of retransmissions can be set to three times. Otherwise, the complete instruction is transmitted in JSON format, and the key names corresponding to the JSON format adopt the Snake Case naming specification, and the key value nesting depth ≤ 3 levels.
[0055] In view of the actual implementation, the adopted instruction parsing layer performs the following operations: parsing the front-end instructions and executing the corresponding engine operations, including object rotation, position adjustment, and scene state query. Specifically, the response mechanism for scene state query is to collect scene data through the 100ms Tick event of UE5, and through the conventional differential algorithm, only transmit the fields with a change amount ≥ 5%. In this way, the bandwidth occupancy can be reduced. Specifically, the scene state query adopts the differential algorithm based on Euclidean distance, and obtains the position, rotation and other attributes of the scene object through the Tick event of UE5 every 100ms to complete data collection. At the same time, it can calculate the Euclidean distance difference between the current value and the previous value. If the difference ≥ 5% (such as the position change ≥ 0.05 unit), it is marked as the field to be transmitted. Thus, change detection is realized. And it only sends the changed fields, and the bandwidth occupancy can be reduced by 80%. During the implementation, the UE5 engine status can be pushed to the front-end through the timer mechanism. The trigger interval of the timer is set to 200ms ± 10ms, and the front-end dynamically adjusts it in 50ms steps through the set_interval instruction. In this way, the CPU occupancy rate can be effectively reduced, and after optimization, the CPU occupancy rate ≤ 5%.
[0056] Considering the convenience of implementation, the push format of the status is:
[0057] {"event":"Scene.LoadProgress","value":progress value}.
[0058] If a network interruption occurs, an exception push will be made, and the content of the exception push is:
[0059] {"event":"Error","code":500,"retry_interval":3}.
[0060] During this period, a 3-second countdown can be started after the front-end receives it, and an automatic reconnection attempt can be made to meet the retry logic. At the same time, the error code definition can be realized, and the code field follows the HTTP standard. For example, 500 is a server error, and 404 is an instruction not found.
[0061] Looking further, in order to meet the requirements of being easy to identify and having a suitable and standardized configuration format, the configuration file adopted by the present invention is in yaml format. Its storage path conforms to the directory specification of / Config / Commands / *.yaml. In this way, the epoll can be used to monitor the file descriptors to achieve millisecond-level update responses. Moreover, the yaml syntax can be verified before loading to avoid format errors. At the same time, the configuration file realizes hot update by listening to the IN_MODIFY event through inotify, with a response delay ≤ 10ms, and the MD5 hash value of the file is verified before loading. Thus, integrity can be ensured to prevent data corruption caused by partial writing.
[0062] During the implementation of the present invention, an instruction priority queue can be set. In this way, high priorities can be assigned to object position synchronization instructions and user interaction events. Considering the stability of queue jumping, when a high-priority instruction jumps the queue, it is required that the hash verification of command_id passes, and the calculation result by SHA-256 is exactly the same as the hash field in the instruction. At the same time, the priority can be marked as priority=high. Furthermore, the queue-jumping position is limited to the 0th or 1st position backward from the head of the queue.
[0063] Meanwhile, in order to meet the visual data framework, the present invention can utilize a virtual reality scenario to integrate the attitude data of the head-mounted display device through the OpenXR protocol. The attitude data synchronization frequency is 90Hz ± 5Hz and is processed using a quaternion compression algorithm. Moreover, in order to optimize and select the communication port, the WebSocket plugin is enabled on the UE5 side and the communication port is set. In this way, when the default port 8000 is occupied, the following order can be tried:
[0064] 1. Odd ports are preferred: 8001 → 8003 → 8005 → 8007 → 8009.
[0065] 2. Even ports are less optimal: 8002 → 8004 → 8006 → 8008 → 8010.
[0066] 3. Conflict handling: After three consecutive conflicts, the PORT_CONFLICT exception code is triggered and the service is terminated, and the list of conflicting ports is logged. In the log, it can be expressed as, [ERROR] PORT_CONFLICT: All ports 8000-8010 are occupied.
[0067] Furthermore, the framework adopted by the present invention uses modular plugins to achieve cross-project reuse with business logic. Specifically, the implementation method of cross-project reuse is as follows: Through the design of modular plugins, the UE5 functions are encapsulated as independent Vue.js plugins (this.$ue5), and the business logic can be injected through configuration. At the same time, it can meet the use of standardized instruction sets, decouple instructions from business, and new projects only need to modify the instruction mapping relationship in the yaml configuration file. Moreover, it can support hot updates. During implementation, instructions are dynamically loaded through / Config / Commands / *.yaml without modifying the core code. Furthermore, an interface abstraction layer can be established, which can provide the ICommandHandler interface, and the business logic only needs to implement the interface to adapt to the requirements of different projects.
[0068] The working principle of the present invention is as follows. Combining the lightweight interaction framework disclosed by the present invention with software includes the following content.
[0069] For front-end instruction generation and transmission:
[0070] Scenario, the front end needs to control the position, rotation, and material of an object in the UE5 scenario.
[0071] The logical process includes
[0072] (1) Instruction construction: The front end calls the sendCommand method through the global object this.$ue5 to construct an instruction object containing the following fields. The parameters involved include command_type, which is used to specify the operation type (such as object_control). Params, which is used to pass specific parameters. Include: object_id: The unique identifier of the target object (such as cube_001). Position, which is used for the three-dimensional coordinate displacement vector (the precision is reserved to 4 decimal places, and the range is limited to [-1000.0, 1000.0]). Rotation, which is used for the quaternion rotation parameter (the component range is limited to [-1.0, 1.0], and the normalization error ≤ 0.001). material, which is used for the material parameter, including the texture path (such as / Game / Textures / Metal_01). Transparency value (step precision 0.01, range [0.0, 1.0]).
[0073] (2) Generation of unique instruction identifier: Serialize command_type and params into a JSON string. The SHA-256 algorithm can be used to generate the hash value of this string as the unique command_id (a 32-byte hexadecimal string) to prevent instruction tampering and duplicate submissions.
[0074] (3)WebSocket Transmission Optimization: Disable ACK frames, turn off the permessage-deflate extension of the WebSocket protocol, and reduce handshake overhead. Enable TCP_NODELAY, disable the Nagle algorithm, and reduce the transmission latency of small data packets. Use LZ4 compression to compress JSON instructions with a compression ratio of ≥70%. Adopt a heartbeat mechanism to send heartbeat packets every 5 seconds to maintain the stability of long connections.
[0075] The processing of UE5-side instruction parsing and execution is as follows.
[0076] (1)Instruction Reception and Parsing. Receive JSON-format instructions through WebSocket on the UE5 side and extract the command_type and params fields. Among them, the parameter verification process is as follows: check whether each component of position is within the range of [-1000.0, 1000.0], and return error code 301 if it exceeds, to implement position verification. Correct the rotation parameters by calling FQuat::Normalize() to ensure that the error ≤ 0.001, meeting the requirements of quaternion normalization. The material path conversion can be realized by converting the string path to the FSoftObjectPath type resource reference of UE5.
[0077] (2)Instruction Mapping and Execution. Match the pre-registered C++ functions or blueprint nodes according to command_type to implement function calls. The JSON key names and C++ function parameter names need to be exactly matched word by word, and the numerical types are processed through a type converter (such as converting JSON's number to FFloatProperty) to complete the customization of parameter matching rules.
[0078] The process of status feedback and exception handling is as follows.
[0079] (1)Differential Status Push. Collect the properties of scene objects (position, rotation, etc.) every 100ms through the Tick event of UE5 to complete data collection. Calculate the Euclidean distance difference between the current value and the previous value. If the change amount ≥ 5% (such as the position change ≥ 0.05 units), mark it as a field to be transmitted to implement change detection. Only the changed fields are sent throughout the process, reducing the bandwidth occupancy by 80% to meet the needs of incremental transmission.
[0080] (2)Timed Status Push. Push the scene status to the front end through WebSocket every 200ms (±10ms).
[0081] (3)The exception handling mechanism includes network interruption and front-end retry. Specifically, when a network interruption occurs, an error code is immediately pushed. After receiving the error code, a 3-second countdown is started to automatically attempt to reconnect to implement front-end retry.
[0082] During the implementation period, the following hot update process can be adopted: Listen for the IN_MODIFY event through inotify, and the response latency ≤ 10 ms. Thus, it can meet the monitoring of file changes. At the same time, after verifying the yaml syntax and MD5 hash value, new instructions are dynamically registered and the configuration is loaded.
[0083] From the above textual description and in combination with the attached drawings, it can be seen that after adopting the present invention, the following advantages are obtained:
[0084] 1. The development efficiency is significantly improved, and the front-end framework is deeply integrated: By providing the global object this.$ue5 through the Vue.js plugin, encapsulating the API call interface of the UE5 engine functions, realizing the automatic generation of the front-end and back-end protocols, reducing the workload of interface duplicate coding by 80%. Through the dynamic instruction extension mechanism, based on the yaml configuration file, instruction hot update is realized. When adding new functions, there is no need to recompile the engine, and the development iteration cycle is shortened by 60%.
[0085] 2. The cross-project reusability is broken through. The instructions are decoupled from the business logic: Through the standardized instruction set and modular plug-in design, the code reuse rate ≥ 90% during cross-project migration.
[0086] 3. The real-time interaction performance is optimized, meeting low-latency communication, and a hybrid transmission mode can be realized.
[0087] 4. The resource utilization rate is high, the bandwidth occupation is reduced, and the processing delay of key instructions can be reduced.
[0088] The above is only the preferred implementation manner of the present invention and is not used to limit the present invention. It should be noted that for those of ordinary skill in the art in this technical field, without departing from the technical principle of the present invention, several improvements and modifications can still be made, and these improvements and modifications should also be regarded as the protection scope of the present invention.
Claims
1. A lightweight interactive framework implementation method based on UE5 engine, characterized by: The Vue.js plug-in provides a global object this.$ue5, which encapsulates the API calling interface of the UE5 engine function, and is used to support the front-end to call the UE5 function through a standardized instruction set. The standardized instruction set includes instruction types for scene loading, object control, and animation triggering. Each instruction must include a command_type field and a params parameter object. A unique command_id field is generated through SHA-256. Building a communication protocol layer based on the WebSocket protocol enables low-latency data transmission between the front end and the UE5 engine. The low latency is that the communication delay in a local area network environment is ≤50ms. Set up the command parsing layer on the UE5 side to map the JSON format commands sent by the front end to the internal functions or blueprint nodes of the UE5 engine. The mapping logic includes: parsing the command_type field and calling the pre-registered C++ function, the parameter name matching rule is full word matching, and the JSON format command is converted into UE5's FFloatProperty or FIntProperty through a type converter; Dynamically register new instruction sets through configuration files or hot update mechanisms.
2. The method for implementing a lightweight interactive framework based on the UE5 engine according to claim 1, characterized in that: The global object this.$ue5 supports calling scene loading, object control and animation triggering functions. The object control function includes transmitting the three-dimensional coordinate displacement vector through the position field, with the vector precision retained to 4 decimal places and the value range being [-1000.0, 1000.0]; The quaternion rotation parameters are passed through the rotation field. The quaternion component range is limited to [-1.0, 1.0] and the normalized error is ≤ 0.
001. Modify the object material texture path and transparency value through the material field. The transparency value range is [0.0, 1.0] and the step precision is 0.
01.
3. The method for implementing a lightweight interactive framework based on the UE5 engine according to claim 1, characterized in that: The communication protocol layer adopts a binary and JSON mixed transmission mode, the key name corresponding to the JSON format adopts the Snake Case naming specification, and the key value nesting depth is ≤3 layers.
4. The method for implementing a lightweight interactive framework based on the UE5 engine according to claim 1, characterized in that: The instruction parsing layer performs the following operations: Parse front-end instructions and execute corresponding engine operations, including object rotation, position adjustment, and scene status query. The response mechanism of the scene status query is to collect scene data through the UE5's Tick event every 100ms, and transmit only the fields with a change of ≥5% through a differential algorithm; The UE5 engine status is pushed to the front end through a timer mechanism. The trigger interval of the timer is set to 200ms±10ms, and the front end dynamically adjusts it in 50ms steps through the set_interval instruction.
5. The method for implementing a lightweight interactive framework based on the UE5 engine according to claim 4, characterized in that: The push format of the status is {"event":"Scene.LoadProgress","value":progress value}. If a network interruption occurs, an abnormal push is performed, and the content of the abnormal push is {"event":"Error","code":500,"retry_interval":3}.
6. The method for implementing a lightweight interactive framework based on the UE5 engine according to claim 1, characterized in that: The configuration file is in yaml format, the saving path complies with the / Config / Commands / *.yaml directory specification, the file descriptor is listened to by epoll for update response, and the yaml syntax is verified before loading; the configuration file is listened to by inotify for IN_MODIFY events to achieve hot update, the response delay is ≤10ms, and the file MD5 hash value is verified before loading.
7. The method for implementing a lightweight interactive framework based on the UE5 engine according to claim 1, characterized in that: Set the command priority queue, assign high priority to object position synchronization commands and user interaction events, and high priority commands must pass the command_id hash check when they are queued; the priority mark is priority=high; the queue insertion position is limited to the 0th or 1st position backward from the head of the queue.
8. The method for implementing a lightweight interactive framework based on the UE5 engine according to claim 1, characterized in that: Utilizing the virtual reality scene, the head display device posture data is integrated through the OpenXR protocol. The posture data synchronization frequency is 90Hz±5Hz and is processed using a quaternion compression algorithm.
9. The method for implementing a lightweight interactive framework based on the UE5 engine according to claim 1, characterized in that: The UE5 enables the WebSocket plug-in and sets the communication port. When the default port 8000 is occupied, the port is switched in the following order, with 8001, 8003, 8005, 8007, and 8009 being given priority; if there is still a conflict, try 8002, 8004, 8006, 8008, and 8010; after three consecutive conflicts, the exception code PORT_CONFLICT is triggered and the service is terminated.
10. The method for implementing a lightweight interactive framework based on the UE5 engine according to claim 1, characterized in that: The framework achieves cross-project reuse through modular plug-ins and business logic; The modular plug-in is composed of an independent Vue.js plug-in encapsulated with UE5 functions, and the business logic is injected into the Vue.js plug-in through configuration.
Citation Information
Patent Citations
Network communication encoding and decoding engine method for satellite receiving system based on XML and JSON
CN112612535A
Digital twin application interaction system and method based on instruction protocol
CN117033034A