Behavior state synchronization method and apparatus, and electronic device
By loading the same behavior graph on the client and synchronizing branch node identification and running status, it solves the cumbersome development and performance overhead problems of virtual character behavior status synchronization in 3D games, and achieves efficient action and position synchronization.
Patent Information
- Application Number
- PCT/CN2023/117554
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-11
- Filing Date
- 2023-09-07
- Publication Date
- 2024-10-17
AI Technical Summary
In 3D games, the existing technology requires writing a large amount of script code to synchronize the behavior status of virtual characters, resulting in a cumbersome development process and high performance overhead. Especially when synchronizing the position and behavior status of virtual characters in real time in online games, there is a time difference and performance bottleneck.
By loading the same behavior graph on the client, the activated branch node identification and running status are determined and sent to other clients to synchronize the behavioral status of the virtual character, avoiding the process of writing scripts and traversing nodes top-down. , directly controlling the action of the target virtual character based on the network synchronization results.
It simplifies the development process, reduces the development workload, reduces game performance overhead, ensures the time consistency of action and position synchronization, and improves the synchronization efficiency and accuracy of behavioral states.
Smart Images

Figure CN2023117554_17102024_PF_FP_ABST
Abstract
Description
Behavior state synchronization method, device and electronic device
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to a Chinese patent application filed on April 11, 2023, with application number 202310387414.3, entitled “Method, device and electronic device for synchronizing behavioral states,” the entire contents of which are incorporated herein by reference. Technical Field
[0003] The present disclosure relates to the field of computer technology, and in particular to a method, device, and electronic device for synchronizing behavior states. Background Art
[0004] In three-dimensional games, the behavior state of game characters is usually controlled by nodes in the behavior graph. In online games, the position and behavior state of the target virtual character controlled by the player needs to be synchronized to other clients in real time so that the position and behavior state of the target virtual character seen by other players remain consistent. In related technologies, when the behavior state of the target virtual character controlled by the player changes, it is necessary to forward the notification of the server to other clients to update the behavior graph through remote calls based on the pre-configured script, so that other clients can control the action state of the target virtual character according to the updated behavior graph, thereby ensuring that the behavior state of the target virtual character remains consistent in each client. The above method requires writing a large amount of script code, and the development process is tedious and labor-intensive. In addition, the internal logic of the behavior graph is actually unrelated to the script. However, in the above method, whether it is the internal logic of the behavior graph or the external script logic that controls the behavior state of the virtual character, it is necessary to achieve state synchronization through a preset script, resulting in a large performance overhead for the game.
[0005] Summary of the Invention
[0006] The present disclosure provides a method, device and electronic device for synchronizing behavior states.
[0007] According to a first aspect of the present disclosure, a method for synchronizing a behavior state is provided, which is applied to a first client, and the method comprises: in response to a game start instruction, loading a first behavior graph of a target virtual character; wherein the first behavior graph comprises a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; the target virtual character is controlled by the first client; in response to a change in the behavior state of the target virtual character, determining the node identifier of the first branch node that affects the behavior state of the target virtual character and the running state of the first branch node from the first behavior graph; sending the node identifier of the first branch node and the running state of the first branch node to a second client, and controlling the behavior state of the target virtual character through the second client according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph.
[0008] According to a second aspect of the present disclosure, a method for synchronizing a behavior state is provided, which is applied to a second client, and the method includes: in response to a game start instruction, loading a second behavior graph of a target virtual character; wherein the target virtual character is controlled by a first client; the first behavior graph of the target virtual character is loaded in the first client; the first behavior graph includes a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; in response to receiving the node identifier of the first branch node and the running state of the first branch node sent by the first client, controlling the behavior state of the target virtual character according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph.
[0009] According to a third aspect of the present disclosure, a device for synchronizing a behavior state is provided, which is arranged on a first client and includes: a first loading module, configured to load a first behavior graph of a target virtual character in response to a game start instruction; wherein the first behavior graph includes multiple branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; the target virtual character is controlled by the first client; a determination module, configured to determine, in response to a change in the behavior state of the target virtual character, the node identifier of the first branch node that affects the behavior state of the target virtual character and the running state of the first branch node from the first behavior graph; a sending module, configured to send the node identifier of the first branch node and the running state of the first branch node to a second client, and through the second client, control the behavior state of the target virtual character according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph.
[0010] According to a fourth aspect of the present disclosure, a device for synchronizing a behavior state is provided, which is arranged on a second client and includes: a second loading module, configured to load a second behavior graph of a target virtual character in response to a game start instruction; the target virtual character is controlled by a first client; the first behavior graph of the target virtual character is loaded in the first client; wherein the first behavior graph includes a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; a state synchronization module, configured to control the behavior state of the target virtual character in response to receiving the node identifier of the first branch node and the running state of the first branch node sent by the first client, according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph.
[0011] According to a fifth aspect of the present disclosure, an electronic device is provided, comprising a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the method for synchronizing the behavioral state of any one of the first aspect, or to implement the method for synchronizing the behavioral state of any one of the second aspect.
[0012] According to the sixth aspect of the present disclosure, a computer-readable storage medium is provided, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method for synchronizing the behavioral state of any one of the first aspect, or to implement the method for synchronizing the behavioral state of any one of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] FIG1 is a flowchart of a method for synchronizing behavior states provided in an embodiment of the present disclosure;
[0014] FIG2 is a flowchart of a method for synchronizing a behavior state according to an embodiment of the present disclosure;
[0015] FIG3 is a schematic structural diagram of a synchronization device in one behavior state provided by an embodiment of the present disclosure;
[0016] FIG4 is a schematic structural diagram of a synchronization device in one behavior state provided by an embodiment of the present disclosure;
[0017] FIG5 is a schematic structural diagram of one of the electronic devices provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0018] To make the purpose, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only part of the embodiments of the present disclosure, not all of them. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making any creative efforts shall fall within the scope of protection of the present disclosure.
[0019] In current 3D games, the behavior of game characters is typically controlled by nodes in a behavior graph. This graph contains numerous state machines and branch selection nodes. These nodes determine which branch to activate based on the specific game logic (such as player input using the keyboard or mouse, or perceived results in the game scene). Based on this activated branch, the virtual character is controlled to perform the corresponding behavior. During actual game execution, the game engine traverses the behavior graph from top to bottom for each frame to determine which branch to activate.
[0020] In online games, the position and behavior of a player's virtual character must be synchronized in real time with other clients to ensure that other players see the same position and behavior as the target virtual character. For example, the virtual character's position, direction, and movements must be accurately synchronized with other clients in real time to ensure that the behavior of the virtual character displayed on other clients is consistent with the behavior of the virtual character in the client controlling the virtual character. However, as the combination of virtual character actions becomes richer and the game logic becomes more complex, the quality and performance requirements for synchronizing the virtual character's behavior will also become increasingly stringent.
[0021] In related technologies, when the behavior state of the target virtual character controlled by the player changes, it is necessary to forward the notification to other clients through remote calls based on a pre-configured script to update the behavior graph, so that other clients can control the action state of the target virtual character according to the updated behavior graph, thereby ensuring that the behavior state of the target virtual character remains consistent across all clients. The above method requires writing a large amount of script code, and the development process is tedious and labor-intensive. In addition, the internal logic of the behavior graph is actually unrelated to the script. However, in the above method, whether it is the internal logic of the behavior graph or the external script logic that controls the behavior state of the virtual character, both need to be synchronized through the preset script, resulting in a large performance overhead for the game.
[0022] Based on this, the embodiments of the present disclosure provide a method, apparatus, and electronic device for synchronizing behavior states. This technology can be applied to devices such as mobile phones, computers, and notebooks.
[0023] To facilitate understanding of this embodiment, a method for synchronizing behavior states disclosed in this embodiment is first introduced in detail. As shown in FIG1 , the method includes the following steps S102 to S106:
[0024] Step S102: In response to a game start instruction, a first behavior graph of a target virtual character is loaded; wherein the first behavior graph includes a plurality of branch nodes, each of which is pre-assigned with a node identifier; the branch nodes are used to control the behavior state of the target virtual character; and the target virtual character is controlled by the first client.
[0025] The first behavior graph of the target avatar is a tree structure composed of multiple functional nodes. It typically includes five categories of nodes: animation playback nodes, procedural post-processing nodes, branch selection nodes, triggers, and mathematical operation nodes. Animation playback nodes sample animation resources and modify the character skeleton's transform (primarily rotation and translation). They support action blending or action superposition. If multiple action nodes are active within a frame, the blending ratios will typically differ. Procedural post-processing nodes programmatically modify the character skeleton's transform based on forward kinematics (FK) or inverse kinematics (IK). These nodes are typically used to control the avatar's hands grasping objects or its feet conforming to uneven terrain. Branch selection nodes: Within the tree structure, these nodes have multiple sub-branches, activating one or a few branches based on actual needs. Within the tree structure, state machines also belong to branch selection nodes. Triggers: Use the node's internal logic to change the active branch of a branch selection node. Mathematical operation nodes: Some states within these types of nodes can be calculated and inputted via mathematical operation nodes.
[0026] The above-mentioned node identifiers can be numerical identifiers or letter representations, and of course, string identifiers can also be tried. In actual implementation, the same or different behavior graphs are usually prepared in advance for different virtual characters. When the game is opened in the first client, or the behavior state of the target virtual character is controlled, the first behavior graph is loaded first, and during the loading process, each branch node in the first behavior graph is assigned a corresponding node identifier. Specifically, when loading the first behavior graph, each branch node in the first behavior graph is first searched through deep optimization, and a node identifier (or ID) is set for each branch node in sequence.
[0027] Step S104, in response to a change in the behavior state of the target virtual character, determining, from the first behavior graph, a node identifier of a first branch node that affects the behavior state of the target virtual character and an operating state of the first branch node;
[0028] The operating status of the above-mentioned first branch node usually includes the specific action, the duration of the action execution, and the fusion ratio between multiple actions, etc. For example, action A with a fusion ratio of 0.6 is played to the 2nd second, action B with a fusion ratio of 0.4 is played to the 0.5th second, the waist bones need to rotate 10 degrees, and the feet need to adapt to the height of the scene terrain. The above-mentioned first branch node usually refers to an activated branch node. The above-mentioned node identifier can be a numerical identifier such as "001", "002", or an alphabetic identifier such as "a", "b", or an encoded string identifier. In addition, the above-mentioned first branch node can be one or more branch nodes.
[0029] Specifically, the first behavior graph can be traversed, the active branch can be determined through the branch selection node, and then the activated first branch node can be found. The first branch node generally includes an animation playback node and a programmatic post-processing node. Alternatively, the player can change the behavior state of the target virtual character by controlling an external device or terminal device, or the target virtual character can trigger a certain behavior action in the game scene, thereby changing the behavior state of the target virtual character.
[0030] A possible implementation method is as follows: in response to a change in the behavior state of the target virtual character, traverse the branch nodes in the first behavior graph, and determine the activated branch node in the branch nodes as the first branch node; wherein the first branch node includes an animation playback node and a programmed processing node; obtain the node identifier of the first branch node and the running state of the first branch node.
[0031] Step S106: Send the node identifier of the first branch node and the operating status of the first branch node to the second client. Through the second client, based on the node identifier of the first branch node, the operating status of the first branch node, and the second behavior graph of the target virtual character, control the behavior state of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph.
[0032] The above-mentioned second client includes one or more. The second behavior graph of the above-mentioned target virtual character is the same as the first behavior graph, that is, the behavior graph of the target virtual character loaded by the second client is the above-mentioned first behavior graph. During the loading process, node identifiers will be set for the branch nodes of the second behavior graph, and the node identifiers in the second behavior graph are the same as the node identifiers in the first behavior graph. That is, the branch nodes included in the above-mentioned second behavior graph are preset with node identifiers; the node identifiers preset for the branch nodes in the second behavior graph are the same as the node identifiers preset for the branch nodes in the first behavior graph;
[0033] Specifically, the node identifier of the first branch node and the running state of the first branch node are first sent to the server, and then forwarded to the second client by the server. After the second client receives the node identifier and running state of the first branch node, it can determine the second branch node that affects the behavior state of the target virtual character from the second behavior graph based on the node identifier of the first branch node, and then determine the running state of the second branch node based on the running state of the first branch node. Finally, the behavior state of the target virtual character is directly controlled by the running state of the second branch node. For example, if the running state of the first branch node is "the waist bone needs to rotate 10 degrees", the running state of "the waist bone needs to rotate 10 degrees" is applied to the second branch node, and the target virtual character is controlled to perform the action according to the running state of the second branch node "the waist bone needs to rotate 10 degrees" to synchronize the behavior state of the target virtual character, thereby synchronizing the behavior state of the target virtual character in the first client with the behavior state of the target virtual character in the second client.
[0034] An embodiment of the present disclosure provides a method for synchronizing a behavior state, which loads a first behavior graph of a target virtual character in response to a game start instruction; wherein the first behavior graph includes a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; the target virtual character is controlled by a first client; in response to a change in the behavior state of the target virtual character, the node identifier of the first branch node that affects the behavior state of the target virtual character and the running state of the first branch node are determined from the first behavior graph; a sending module is used to send the node identifier of the first branch node and the running state of the first branch node to a second client, and through the second client, the behavior state of the target virtual character is controlled according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph. In this method, by loading the same behavior graph for the same virtual character on different clients, when synchronizing the behavior state of the target virtual character, it is only necessary to send the information of the branch node activated in the first behavior graph to the second client. The second client synchronizes the behavior state of the target virtual character according to the information of the branch node and the second behavior graph. There is no need to write scripts, which simplifies the development process, reduces the development workload, and reduces the performance overhead of the game.
[0035] The step of controlling the behavior state of the target virtual character by the second client according to the node identifier of the first branch node, the operating state of the first branch node, and the second behavior graph of the target virtual character includes the following possible implementation methods:
[0036] Through the second client, according to the node identifier of the first branch node, a second branch node corresponding to the first branch node is determined from the second behavior graph; the running state of the first branch node is applied to the second branch node, and the behavior state of the target virtual character is controlled based on the second branch node.
[0037] Specifically, since the first behavior graph is identical to the second behavior graph, and the node identifier in the first behavior graph is identical to the node identifier in the second behavior graph, a branch node with the same node identifier as the first branch node can be found in the second behavior graph based on the node identifier of the first branch node, that is, the activated branch node, i.e., the aforementioned second branch node. The operating state of the first branch node is then applied to the second branch node, so that the operating state of the activated second branch node in the second behavior graph is identical to the operating state of the activated first branch node in the first behavior graph. Finally, based on the operating state of the second branch node, the target virtual character is controlled to execute the corresponding behavior. This allows the behavioral state of the target virtual character in the first client to be synchronized with the behavioral state of the target virtual character in the second client.
[0038] The second client does not need to perform a top-down traversal of the activated nodes in the second behavior graph. Instead, it directly finds the second branch node related to the behavior state based on the results of network synchronization (i.e., the node identification and operating status of the first branch node mentioned above). Based on this second branch node, it controls the target virtual character to perform the corresponding action, thereby skipping a large number of functional nodes that do not directly affect the behavior state but only affect decision-making, reducing unnecessary performance overhead. In addition, a more universal method is used at the bottom layer of the game engine to achieve action network synchronization, without having to consider whether it is external script logic or the internal logic of the behavior graph that drives the virtual character's action changes.
[0039] In order to compress the amount of data transmitted over the network and improve the transmission speed, and taking into account that the number of nodes that need to be synchronized with the network for each frame may not be the same, and that different types of nodes have different operating modes and data volumes, the step of sending the node identifier of the first branch node and the operating status of the first branch node to the second client includes the following possible implementation methods:
[0040] The running state of the first branch node is converted into an integer type; a target list is determined according to the running state of the first branch node after the conversion and the node identifier of the first branch node; the target list is converted into a string and sent to the server, which is then forwarded to the second client through the server.
[0041] The above-mentioned node identifier is an integer value, that is, when setting the node identifier for the branch node while loading the first behavior graph, a separate integer value can be set for the branch node, which can be expressed as NodeID. Therefore, the node identifier of the first branch node determined above is an integer value. In order to further reduce the amount of data, the operating status of the first branch node is converted into an integer (int) type. Then the node identifier (i.e., NodeID) and the operating status of the first branch node are transmitted in the form of an int list (i.e., the above-mentioned target list). That is to say, after determining the target list, the target list can be sent directly to the server, and forwarded to the second client through the server.
[0042] In addition, in order to save traffic, the int list (i.e., the target list) can be converted into a string and sent to the server, which is then forwarded to the second client through the server. Specifically, the operating status of the branch node is generally a floating-point type (float). Within the allowable error range, the float can be mapped to an int (for example, the fusion ratio in the range of 0 to 1 is mapped to an integer of -50 to 50) to save traffic. Finally, the int list will be converted into a string for sending. In this way, the node identifier and operating status are converted into data, thereby reducing the amount of data transmitted over the network and increasing the transmission speed.
[0043] In the related art, for the synchronization of the position and direction (usually only Yaw) of the virtual character, since the position and direction change frequently and the data format is relatively simple, a common practice is to upload the position and direction to the server at a fixed time interval (such as 0.1 seconds) when the position or direction of the virtual character changes. Other clients will receive the position and direction sent by the server and change the position and direction of the virtual character. For the action status of the virtual character, an existing common practice is to use a script to notify the server with a remote procedure call (RPC) when the activation branch of the behavior graph needs to be changed or the running status of the node needs to be modified, and then forward the notification to other clients through the server to update the status of the behavior graph branch or node. Since position synchronization and action synchronization are achieved in different ways, there may be a time difference between the synchronized position change and action change. There will be a more obvious time difference for synchronized actions such as jumping and climbing where the position changes quickly.
[0044] Based on this, in order to make the action and position change simultaneously and avoid time difference, the step of sending the node identifier of the first branch node and the operating status of the first branch node to the second client includes the following possible implementation methods:
[0045] Acquire the location information of the target virtual character; send the location information, the node identifier of the first branch node and the running status of the first branch node to the server, and forward it to the second client through the server.
[0046] One possible approach is to encode the location information, along with the node identifier and operational status of the first branch node, into a single data packet, which is then sent to the server, which then forwards it to the second client. This approach simultaneously transmits the changed location information, the node identifier, and operational status of the first branch node, avoiding any time difference between the action and location, and improving synchronization of the behavioral states.
[0047] Considering that when there are a large number of first branch nodes transmitted over the network, the data packet may be large (or the string may be long). In order to save the amount of data transmitted over the network, after the step of sending the node identifier of the first branch node and the operating status of the first branch node to the second client, the method further includes:
[0048] In response to a change in the behavior state of the target virtual character, if the behavior state after the change is a continuous behavior state with the behavior state before the change, a target instruction is generated; the target instruction is sent to the second client, and through the second client, the behavior state of the target virtual character is continued to be controlled according to the node identifier of the first branch node, the operating state of the first branch node, and the second behavior graph of the target virtual character.
[0049] Specifically, when the behavior state of the target virtual character changes, it is first determined whether the current behavior state of the target virtual character is continuous with the previous behavior state, such as continuously running or walking in a specified direction, or repeatedly performing jumping actions, etc. At this time, in order to save the amount of data transmitted over the network, a target instruction can be generated. The target instruction is used to indicate that the first branch node and the second branch node activated by the current first behavior graph and the second behavior graph remain unchanged, and the operating state remains unchanged. In other words, the activated actions are played at a constant fusion ratio and the same playback rate, and the operating state of the programmed post-processing node is not sent to change.
[0050] Then, the target instruction is forwarded to the second client through the server, so that the second client continues to control the target virtual character to perform the corresponding action based on the current operating state of the second branch node. In other words, when the action state remains continuous, the second client can directly reuse the data received last time, and the first client does not need to repeatedly send the same data, which can save traffic. In this way, when the target virtual character continues to perform the same behavioral action, there is no need to continuously send the information of the activated branch node to generate the target instruction so that the second client can continue to perform the current behavioral action, which saves the amount of data transmitted over the network and improves the synchronization efficiency of the behavioral state.
[0051] The above method solves the need for network synchronization of virtual character actions at the engine level, eliminating the need to specifically handle synchronized behavior states at the script level through methods such as RPC. This reduces the workload of script programmers on the project team and reduces performance overhead. Action states are sent and received simultaneously with position and direction, ensuring the temporal consistency of action changes and position changes, and avoiding synchronization time differences. In the creation of behavior graphs, only the use of the target virtual character in the first client needs to be considered. There is no need to create a different behavior graph specifically for the target virtual character in the second client, or to add special markers to the behavior graph to distinguish between the protagonist and third-party characters, simplifying the development process.
[0052] In a second aspect, an embodiment of the present disclosure provides a method for synchronizing a behavior state, which is applied to a second client. As shown in FIG2 , the method includes the following steps S202 to S204:
[0053] Step S202: In response to a game start instruction, a second behavior graph of a target virtual character is loaded; wherein the target virtual character is controlled by a first client; the first behavior graph of the target virtual character is loaded in the first client; the first behavior graph includes a plurality of branch nodes, each of which is pre-assigned with a node identifier; and the branch nodes are used to control the behavior state of the target virtual character;
[0054] Step S204, in response to receiving the node identifier of the first branch node and the operating status of the first branch node sent by the first client, control the behavioral state of the target virtual character according to the node identifier of the first branch node, the operating status of the first branch node, and the second behavior graph of the target virtual character, so that the behavioral state of the target virtual character in the first client is synchronized with the behavioral state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph.
[0055] The embodiment of the present disclosure provides a method for synchronizing a behavior state, wherein, in response to a game start instruction, a second behavior graph of a target virtual character is loaded; the target virtual character is controlled by a first client; the first behavior graph of the target virtual character is loaded in the first client; wherein the first behavior graph includes a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; in response to receiving the node identifier of the first branch node and the running state of the first branch node sent by the first client, according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, the behavior state of the target virtual character in the first client is controlled to synchronize with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph. In this method, by loading the same behavior graph for the same virtual character on different clients, when synchronizing the behavior state of the target virtual character, only the information of the branch nodes activated in the first behavior graph needs to be sent to the second client, and the second client synchronizes the behavior state of the target virtual character according to the information of the branch nodes and the second behavior graph, without the need to write scripts, thereby simplifying the development process, reducing the development workload, and reducing the performance overhead of the game.
[0056] The branch nodes included in the second line of the graph are preset with node identifiers; the node identifiers preset for the branch nodes in the second line of the graph are the same as the node identifiers preset for the branch nodes in the first line of the graph.
[0057] The step of controlling the behavior state of the target virtual character according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character in response to receiving the node identifier of the first branch node and the running state of the first branch node sent by the first client includes the following possible implementation methods:
[0058] In response to receiving a data packet sent by the first client, the data packet is decoded to obtain the node identifier of the first branch node and the operating status of the first branch node; based on the node identifier of the first branch node, a second branch node corresponding to the first branch node is determined from the second behavior graph; the operating status of the first branch node is applied to the second branch node, and the behavior status of the target virtual character is controlled based on the second branch node.
[0059] Specifically, the second client restores the node identifier (i.e., NodeID) of the first branch node and the operating status of each first branch node by decoding the character string, and then finds the corresponding second branch node in sequence according to the NodeID from the second behavior graph, applies the operating status of the first branch node to the second branch node, and controls the action of the target virtual character according to the second branch node.
[0060] It is understandable that for the second client, it is only necessary to run the corresponding animation playback nodes and programmed post-processing nodes, and make the operating status of these nodes (such as action fusion ratio, animation playback progress, etc.) consistent with the status of the target virtual character in the first client, then the behavior state of the target virtual character in the second client can be the same as the behavior state of the target virtual character in the first client. In other words, it is only necessary to synchronize the results of the action playback (that is, which nodes directly affect the action), but there is no need to synchronize the process that affects the action playback (that is, the selection results of the branch selection node and some internal states). After knowing the result, the second client does not need to traverse the node tree from top to bottom, but can start from the result and directly find these activated nodes in the first behavior graph, apply the received operating status to the corresponding second branch node, and let the second branch node work.
[0061] The above method also includes: in response to receiving a target instruction sent by the first client, controlling the behavior state of the target virtual character according to the node identifier of the first branch node, the operating status of the first branch node, and the second behavior graph of the target virtual character; wherein the target instruction is used to indicate that the behavior state of the target virtual character after the change is a continuous behavior state with the behavior state of the target virtual character before the change.
[0062] Corresponding to the above method embodiment, the embodiment of the present disclosure provides a behavior state synchronization device, which is provided on a first client, as shown in FIG3 , and includes:
[0063] The first loading module 301 is configured to load a first behavior graph of a target virtual character in response to a game start instruction; wherein the first behavior graph includes a plurality of branch nodes, each of which is pre-assigned with a node identifier; the branch nodes are used to control the behavior state of the target virtual character; and the target virtual character is controlled by the first client.
[0064] A determination module 302 is configured to determine, in response to a change in the behavior state of the target virtual character, from the first behavior graph, a node identifier of a first branch node that affects the behavior state of the target virtual character and an operating state of the first branch node;
[0065] The sending module 303 is used to send the node identifier of the first branch node and the operating status of the first branch node to the second client, and through the second client, control the behavior state of the target virtual character according to the node identifier of the first branch node, the operating status of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein, the second behavior graph is the same as the first behavior graph.
[0066] An embodiment of the present disclosure provides a device for synchronizing a behavior state, including a first loading module for loading a first behavior graph of a target virtual character in response to a game start instruction; wherein the first behavior graph includes a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; the target virtual character is controlled by a first client; a determination module for determining, in response to a change in the behavior state of the target virtual character, the node identifier of the first branch node that affects the behavior state of the target virtual character and the running state of the first branch node from the first behavior graph; a sending module for sending the node identifier of the first branch node and the running state of the first branch node to a second client, and controlling the behavior state of the target virtual character through the second client according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph. In this method, by loading the same behavior graph for the same virtual character on different clients, when synchronizing the behavior state of the target virtual character, it is only necessary to send the information of the branch node activated in the first behavior graph to the second client. The second client synchronizes the behavior state of the target virtual character according to the information of the branch node and the second behavior graph. There is no need to write scripts, which simplifies the development process, reduces the development workload, and reduces the performance overhead of the game.
[0067] The branch nodes included in the above-mentioned second behavior graph are preset with node identifiers; the node identifiers preset for the branch nodes in the second behavior graph are the same as the node identifiers preset for the branch nodes in the first behavior graph; the above-mentioned sending module is also used to: through the second client, determine the second branch node corresponding to the first branch node from the second behavior graph according to the node identifier of the first branch node; apply the operating status of the first branch node to the second branch node, and control the behavior status of the target virtual character based on the second branch node.
[0068] The above-mentioned sending module is also used to: convert the operating status of the first branch node into an integer type; determine the target list based on the converted operating status of the first branch node and the node identifier of the first branch node; convert the target list into a string and send it to the server, and forward it to the second client through the server.
[0069] The above node identifiers are integer values.
[0070] The sending module is further configured to: obtain location information of the target virtual character; send the location information, the node identifier of the first branch node, and the operating status of the first branch node to the server, and forward the information to the second client via the server.
[0071] The above-mentioned device also includes a target instruction sending module, which is used to: generate a target instruction in response to a change in the behavior state of the target virtual character, if the behavior state after the change is a continuous behavior state with the behavior state before the change; send the target instruction to the second client, and through the second client, continue to control the behavior state of the target virtual character according to the node identifier of the first branch node, the operating state of the first branch node, and the second behavior graph of the target virtual character.
[0072] The above-mentioned determination module is also used to: in response to a change in the behavior state of the target virtual character, traverse the branch nodes in the first behavior graph, and determine the activated branch node in the branch nodes as the first branch node; wherein the first branch node includes an animation playback node and a programmed processing node; obtain the node identifier of the first branch node and the running status of the first branch node.
[0073] The behavior state synchronization device provided in the embodiment of the present disclosure has the same technical features as the behavior state synchronization method provided in the above embodiment, and therefore can also solve the same technical problems and achieve the same technical effects.
[0074] Corresponding to the above-mentioned method embodiment, the embodiment of the present disclosure provides a behavior state synchronization device, which is provided on the second client. As shown in FIG4 , the device includes:
[0075] The second loading module 401 is configured to load a second behavior graph of the target virtual character in response to a game start instruction; the target virtual character is controlled by the first client; the first behavior graph of the target virtual character is loaded in the first client; wherein the first behavior graph includes a plurality of branch nodes, each of which is pre-assigned with a node identifier; and the branch nodes are used to control the behavior state of the target virtual character;
[0076] The state synchronization module 402 is used to control the behavior state of the target virtual character in response to receiving the node identifier of the first branch node and the operating state of the first branch node sent by the first client, according to the node identifier of the first branch node, the operating state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph.
[0077] The embodiment of the present disclosure provides a device for synchronizing a behavior state, comprising a second loading module for loading a second behavior graph of a target virtual character in response to a game start instruction; the target virtual character is controlled by a first client; the first behavior graph of the target virtual character is loaded in the first client; wherein the first behavior graph includes a plurality of branch nodes, each of which is preset with a node identifier; the branch nodes are used to control the behavior state of the target virtual character; a state synchronization module for controlling the behavior state of the target virtual character in response to receiving the node identifier of the first branch node and the running state of the first branch node sent by the first client, according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph. In this method, by loading the same behavior graph for the same virtual character on different clients, when synchronizing the behavior state of the target virtual character, only the information of the branch nodes activated in the first behavior graph needs to be sent to the second client, and the second client synchronizes the behavior state of the target virtual character according to the information of the branch nodes and the second behavior graph, without the need for script writing, thereby simplifying the development process, reducing the development workload, and reducing the performance overhead of the game.
[0078] The branch nodes included in the second line of the graph are preset with node identifiers; the node identifiers preset for the branch nodes in the second line of the graph are the same as the node identifiers preset for the branch nodes in the first line of the graph.
[0079] The above-mentioned state synchronization module is also used to: in response to receiving a data packet sent by the first client, decode the data packet to obtain the node identifier of the first branch node and the operating status of the first branch node; determine the second branch node corresponding to the first branch node from the second behavior graph based on the node identifier of the first branch node; apply the operating status of the first branch node to the second branch node, and control the behavioral status of the target virtual character based on the second branch node.
[0080] The above-mentioned device also includes a target instruction receiving module, which is used to: in response to receiving a target instruction sent by the first client, control the behavior state of the target virtual character according to the node identifier of the first branch node, the operating status of the first branch node, and the second behavior graph of the target virtual character; wherein the target instruction is used to indicate that the behavior state of the target virtual character after the change is a continuous behavior state with the behavior state of the target virtual character before the change.
[0081] The behavior state synchronization device provided in the embodiment of the present disclosure has the same technical features as the behavior state synchronization method provided in the above embodiment, and therefore can also solve the same technical problems and achieve the same technical effects.
[0082] This embodiment further provides an electronic device, including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above-mentioned behavior state synchronization method. The electronic device can be a server or a terminal device.
[0083] As shown in FIG5 , the electronic device includes a processor 100 and a memory 101 . The memory 101 stores machine-executable instructions that can be executed by the processor 100 . The processor 100 executes the machine-executable instructions to implement the above-mentioned method for synchronizing behavioral states.
[0084] Furthermore, the electronic device shown in FIG. 5 further includes a bus 102 and a communication interface 103 , and the processor 100 , the communication interface 103 and the memory 101 are connected via the bus 102 .
[0085] Memory 101 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between the system network element and at least one other network element is achieved through at least one communication interface 103 (which may be wired or wireless), and may utilize the Internet, a wide area network, a local area network, a metropolitan area network, etc. Bus 102 may be an ISA bus, a PCI bus, or an EISA bus. The bus may be classified as an address bus, a data bus, a control bus, etc. For ease of illustration, FIG5 shows only one bidirectional arrow, but this does not indicate that there is only one bus or only one type of bus.
[0086] The processor 100 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 100 or by instructions in the form of software. The above-mentioned processor 100 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, or discrete hardware components. The various methods, steps, and logic block diagrams disclosed in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present disclosure can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in memory 101. The processor 100 reads the information in memory 101 and, in conjunction with its hardware, completes the steps of the behavior state synchronization method of the aforementioned embodiment, with the first client as the execution subject, specifically including:
[0087] In response to a game start instruction, a first behavior graph of the target virtual character is loaded; wherein the first behavior graph includes a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; the target virtual character is controlled by a first client; in response to a change in the behavior state of the target virtual character, the node identifier of the first branch node that affects the behavior state of the target virtual character and the running state of the first branch node are determined from the first behavior graph; the node identifier of the first branch node and the running state of the first branch node are sent to a second client, and through the second client, the behavior state of the target virtual character is controlled according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph. In this method, by loading the same behavior graph for the same virtual character on different clients, when synchronizing the behavior state of the target virtual character, it is only necessary to send the information of the branch node activated in the first behavior graph to the second client. The second client synchronizes the behavior state of the target virtual character according to the information of the branch node and the second behavior graph. There is no need to write scripts, which simplifies the development process, reduces the development workload, and reduces the performance overhead of the game.
[0088] The branch nodes included in the second behavior graph are preset with node identifiers; the node identifiers preset for the branch nodes in the second behavior graph are the same as the node identifiers preset for the branch nodes in the first behavior graph; the step of controlling the behavior state of the target virtual character by a second client based on the node identifier of the first branch node, the operating state of the first branch node, and the second behavior graph of the target virtual character includes: determining, by the second client, a second branch node corresponding to the first branch node from the second behavior graph based on the node identifier of the first branch node; applying the operating state of the first branch node to the second branch node, and controlling the behavior state of the target virtual character based on the second branch node. In this case, the second client does not need to perform a top-down traversal of the activated nodes in the second behavior graph, but directly finds the second branch node related to the behavior state based on the result of network synchronization (i.e., the node identifier and operating state of the first branch node), and controls the target virtual character to perform the corresponding action based on the second branch node, thereby skipping a large number of functional nodes that do not directly affect the behavior state but only affect decision-making, reducing unnecessary performance overhead. In addition, a more universal method is used to implement action network synchronization at the bottom layer of the game engine, without considering whether external script logic or internal logic of the behavior graph drives the virtual character action changes.
[0089] The step of sending the node identifier and operating status of the first branch node to the second client includes: converting the operating status of the first branch node into an integer; determining a target list based on the converted operating status of the first branch node and the node identifier of the first branch node; and converting the target list into a string and sending it to the server, which then forwards it to the second client. In this method, the node identifier and operating status are converted into data, thereby reducing the amount of data transmitted over the network and improving transmission speed.
[0090] The above node identifiers are integer values.
[0091] The step of sending the node identifier of the first branch node and the operating status of the first branch node to the second client further includes: obtaining the location information of the target virtual character; sending the location information, the node identifier of the first branch node, and the operating status of the first branch node to the server, which then forwards the location information, the node identifier of the first branch node, and the operating status to the second client. In this method, by simultaneously sending the changed location information, the node identifier of the first branch node, and the operating status, a time difference between the action and the position is avoided, thereby improving the synchronization of the behavioral status.
[0092] After the step of sending the node identifier of the first branch node and the operating state of the first branch node to the second client, the method further includes: in response to a change in the behavior state of the target virtual character, if the behavior state after the change is a continuous behavior state with the behavior state before the change, generating a target instruction; sending the target instruction to the second client, and through the second client, continuing to control the behavior state of the target virtual character according to the node identifier of the first branch node, the operating state of the first branch node, and the second behavior graph of the target virtual character. In this method, when the target virtual character continues to perform the same behavior action, there is no need to continuously send the information of the activated branch node to generate the target instruction so that the second client can continue to perform the current behavior action, which saves the amount of data transmitted over the network and thereby improves the synchronization efficiency of the behavior state.
[0093] The above-mentioned step of determining the node identifier of the first branch node that affects the behavioral state of the target virtual character and the running state of the first branch node from the first behavioral graph in response to the change in the behavioral state of the target virtual character includes: in response to the change in the behavioral state of the target virtual character, traversing the branch nodes in the first behavioral graph, and determining the activated branch node in the branch nodes as the first branch node; wherein the first branch node includes an animation playback node and a programmed processing node; and obtaining the node identifier of the first branch node and the running state of the first branch node.
[0094] The second client is the execution subject, specifically including:
[0095] In response to a game start instruction, a second behavior graph of the target virtual character is loaded; wherein the target virtual character is controlled by a first client; the first behavior graph of the target virtual character is loaded in the first client; the first behavior graph includes a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; in response to receiving the node identifier of the first branch node and the running state of the first branch node sent by the first client, the behavior state of the target virtual character is controlled according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph. In this method, by loading the same behavior graph for the same virtual character on different clients, when synchronizing the behavior state of the target virtual character, it is only necessary to send the information of the branch nodes activated in the first behavior graph to the second client, and the second client synchronizes the behavior state of the target virtual character according to the information of the branch nodes and the second behavior graph, without the need to write scripts, which simplifies the development process, reduces the development workload, and reduces the performance overhead of the game.
[0096] The branch nodes included in the second line of the graph are preset with node identifiers; the node identifiers preset for the branch nodes in the second line of the graph are the same as the node identifiers preset for the branch nodes in the first line of the graph.
[0097] The above-mentioned step of controlling the behavior state of the target virtual character in response to receiving the node identification of the first branch node and the running status of the first branch node sent by the first client, according to the node identification of the first branch node, the running status of the first branch node, and the second behavior graph of the target virtual character, includes: in response to receiving the data packet sent by the first client, decoding the data packet to obtain the node identification of the first branch node and the running status of the first branch node; determining the second branch node corresponding to the first branch node from the second behavior graph according to the node identification of the first branch node; applying the running status of the first branch node to the second branch node, and controlling the behavior state of the target virtual character based on the second branch node.
[0098] The above method also includes: in response to receiving a target instruction sent by the first client, controlling the behavior state of the target virtual character according to the node identifier of the first branch node, the operating status of the first branch node, and the second behavior graph of the target virtual character; wherein the target instruction is used to indicate that the behavior state of the target virtual character after the change is a continuous behavior state with the behavior state of the target virtual character before the change.
[0099] This embodiment further provides a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned method for synchronizing behavioral states, with the first client as the execution subject, and specifically including:
[0100] In response to a game start instruction, a first behavior graph of the target virtual character is loaded; wherein the first behavior graph includes a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; the target virtual character is controlled by a first client; in response to a change in the behavior state of the target virtual character, the node identifier of the first branch node that affects the behavior state of the target virtual character and the running state of the first branch node are determined from the first behavior graph; the node identifier of the first branch node and the running state of the first branch node are sent to a second client, and through the second client, the behavior state of the target virtual character is controlled according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph. In this method, by loading the same behavior graph for the same virtual character on different clients, when synchronizing the behavior state of the target virtual character, it is only necessary to send the information of the branch node activated in the first behavior graph to the second client. The second client synchronizes the behavior state of the target virtual character according to the information of the branch node and the second behavior graph. There is no need to write scripts, which simplifies the development process, reduces the development workload, and reduces the performance overhead of the game.
[0101] The branch nodes included in the second behavior graph are preset with node identifiers; the node identifiers preset for the branch nodes in the second behavior graph are the same as the node identifiers preset for the branch nodes in the first behavior graph; the step of controlling the behavior state of the target virtual character by a second client based on the node identifier of the first branch node, the operating state of the first branch node, and the second behavior graph of the target virtual character includes: determining, by the second client, a second branch node corresponding to the first branch node from the second behavior graph based on the node identifier of the first branch node; applying the operating state of the first branch node to the second branch node, and controlling the behavior state of the target virtual character based on the second branch node. In this case, the second client does not need to perform a top-down traversal of the activated nodes in the second behavior graph, but directly finds the second branch node related to the behavior state based on the result of network synchronization (i.e., the node identifier and operating state of the first branch node), and controls the target virtual character to perform the corresponding action based on the second branch node, thereby skipping a large number of functional nodes that do not directly affect the behavior state but only affect decision-making, reducing unnecessary performance overhead. In addition, a more universal method is used to implement action network synchronization at the bottom layer of the game engine, without considering whether external script logic or internal logic of the behavior graph drives the virtual character action changes.
[0102] The step of sending the node identifier and operating status of the first branch node to the second client includes: converting the operating status of the first branch node into an integer; determining a target list based on the converted operating status of the first branch node and the node identifier of the first branch node; and converting the target list into a string and sending it to the server, which then forwards it to the second client. In this method, the node identifier and operating status are converted into data, thereby reducing the amount of data transmitted over the network and improving transmission speed.
[0103] The above node identifiers are integer values.
[0104] The step of sending the node identifier of the first branch node and the operating status of the first branch node to the second client further includes: obtaining the location information of the target virtual character; sending the location information, the node identifier of the first branch node, and the operating status of the first branch node to the server, which then forwards the location information, the node identifier of the first branch node, and the operating status to the second client. In this method, by simultaneously sending the changed location information, the node identifier of the first branch node, and the operating status, a time difference between the action and the position is avoided, thereby improving the synchronization of the behavioral status.
[0105] After the step of sending the node identifier of the first branch node and the operating state of the first branch node to the second client, the method further includes: in response to a change in the behavior state of the target virtual character, if the behavior state after the change is a continuous behavior state with the behavior state before the change, generating a target instruction; sending the target instruction to the second client, and through the second client, continuing to control the behavior state of the target virtual character according to the node identifier of the first branch node, the operating state of the first branch node, and the second behavior graph of the target virtual character. In this method, when the target virtual character continues to perform the same behavior action, there is no need to continuously send the information of the activated branch node to generate the target instruction so that the second client can continue to perform the current behavior action, which saves the amount of data transmitted over the network and thereby improves the synchronization efficiency of the behavior state.
[0106] The above-mentioned step of determining the node identifier of the first branch node that affects the behavioral state of the target virtual character and the running state of the first branch node from the first behavioral graph in response to the change in the behavioral state of the target virtual character includes: in response to the change in the behavioral state of the target virtual character, traversing the branch nodes in the first behavioral graph, and determining the activated branch node in the branch nodes as the first branch node; wherein the first branch node includes an animation playback node and a programmed processing node; and obtaining the node identifier of the first branch node and the running state of the first branch node.
[0107] The second client is the execution subject, specifically including:
[0108] In response to a game start instruction, a second behavior graph of the target virtual character is loaded; wherein the target virtual character is controlled by a first client; the first behavior graph of the target virtual character is loaded in the first client; the first behavior graph includes a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; in response to receiving the node identifier of the first branch node and the running state of the first branch node sent by the first client, the behavior state of the target virtual character is controlled according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph. In this method, by loading the same behavior graph for the same virtual character on different clients, when synchronizing the behavior state of the target virtual character, it is only necessary to send the information of the branch nodes activated in the first behavior graph to the second client, and the second client synchronizes the behavior state of the target virtual character according to the information of the branch nodes and the second behavior graph, without the need to write scripts, which simplifies the development process, reduces the development workload, and reduces the performance overhead of the game.
[0109] The branch nodes included in the second line of the graph are preset with node identifiers; the node identifiers preset for the branch nodes in the second line of the graph are the same as the node identifiers preset for the branch nodes in the first line of the graph.
[0110] The above-mentioned step of controlling the behavior state of the target virtual character in response to receiving the node identification of the first branch node and the running status of the first branch node sent by the first client, according to the node identification of the first branch node, the running status of the first branch node, and the second behavior graph of the target virtual character, includes: in response to receiving the data packet sent by the first client, decoding the data packet to obtain the node identification of the first branch node and the running status of the first branch node; determining the second branch node corresponding to the first branch node from the second behavior graph according to the node identification of the first branch node; applying the running status of the first branch node to the second branch node, and controlling the behavior state of the target virtual character based on the second branch node.
[0111] The above method also includes: in response to receiving a target instruction sent by the first client, controlling the behavior state of the target virtual character according to the node identifier of the first branch node, the operating status of the first branch node, and the second behavior graph of the target virtual character; wherein the target instruction is used to indicate that the behavior state of the target virtual character after the change is a continuous behavior state with the behavior state of the target virtual character before the change.
[0112] The computer program product of the behavior state synchronization method, device and electronic device provided in the embodiments of the present disclosure includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments and will not be repeated here.
[0113] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described systems and devices can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0114] In addition, in the description of the embodiments of the present disclosure, unless otherwise expressly specified or limited, the terms "installed," "connected," and "connected" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integral connections; they can refer to mechanical connections or electrical connections; they can refer to direct connections or indirect connections through an intermediate medium; and they can refer to internal connections between two components. Those skilled in the art will understand the specific meanings of the above terms in the present disclosure based on the specific circumstances.
[0115] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the relevant technology or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0116] In the description of this disclosure, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings and are intended solely to facilitate the description of this disclosure and simplify the description. They do not indicate or imply that the devices or components referred to must have a specific orientation, be constructed, or operate in a specific orientation. Therefore, they should not be construed as limitations on this disclosure. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0117] Finally, it should be noted that the above embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The scope of protection of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the above embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above embodiments within the technical scope disclosed in the present disclosure, or replace some of the technical features therein with equivalents. Such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure should be based on the scope of protection of the claims.
Claims
1. A method for synchronizing a behavior state, the method being applied to a first client, the method comprising: In response to a game start instruction, a first behavior graph of a target virtual character is loaded; wherein the first behavior graph includes a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; the target virtual character is controlled by the first client; In response to a change in the behavior state of the target virtual character, determining, from the first behavior graph, a node identifier of a first branch node that affects the behavior state of the target virtual character and an operating state of the first branch node; The node identifier of the first branch node and the running status of the first branch node are sent to the second client, and the behavior state of the target virtual character is controlled through the second client according to the node identifier of the first branch node, the running status of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph.
2. The method according to claim 1, wherein: The branch nodes included in the second behavior graph are preset with node identifiers; the node identifiers preset for the branch nodes in the second behavior graph are the same as the node identifiers preset for the branch nodes in the first behavior graph; The step of controlling the behavior state of the target virtual character through the second client according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character includes: determining, by the second client, a second branch node corresponding to the first branch node from the second behavior graph according to the node identifier of the first branch node; The running state of the first branch node is applied to the second branch node, and the behavior state of the target virtual character is controlled based on the second branch node.
3. The method according to claim 1, wherein: The step of sending the node identifier of the first branch node and the operating status of the first branch node to the second client includes: Convert the running state of the first branch node into an integer type; Determine a target list according to the converted running state of the first branch node and the node identifier of the first branch node; The target list is converted into a string and sent to the server, which is then forwarded to the second client.
4. The method according to claim 1, wherein: The node identifier is an integer value.
5. The method according to claim 1, wherein: The step of sending the node identifier of the first branch node and the operating status of the first branch node to the second client further includes: Obtaining location information of the target virtual character; The location information, the node identifier of the first branch node and the operating status of the first branch node are sent to a server, and forwarded to the second client through the server.
6. The method according to claim 1, wherein: After the step of sending the node identifier of the first branch node and the operating status of the first branch node to the second client, the method further includes: In response to a change in the behavior state of the target virtual character, if the behavior state after the change is a continuous behavior state with the behavior state before the change, generating a target instruction; The target instruction is sent to the second client, and through the second client, the behavior state of the target virtual character continues to be controlled according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character.
7. The method according to claim 1, wherein: In response to a change in the behavior state of the target virtual character, the step of determining, from the first behavior graph, a node identifier of a first branch node that affects the behavior state of the target virtual character and a running state of the first branch node comprises: In response to a change in the behavior state of the target virtual character, traverse the branch nodes in the first behavior graph, and determine an activated branch node among the branch nodes as the first branch node; wherein the first branch node includes an animation playback node and a program processing node; A node identifier of the first branch node and a running status of the first branch node are obtained.
8. A method for synchronizing a behavior state, the method being applied to a second client, the method comprising: In response to a game start instruction, a second behavior graph of a target virtual character is loaded; wherein the target virtual character is controlled by a first client; the first client is loaded with a first behavior graph of the target virtual character; the first behavior graph includes a plurality of branch nodes, each of which is preset with a node identifier; the branch nodes are used to control the behavior state of the target virtual character; In response to receiving the node identifier of the first branch node and the operating status of the first branch node sent by the first client, the behavior state of the target virtual character is controlled according to the node identifier of the first branch node, the operating status of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph.
9. The method according to claim 8, wherein: The branch nodes included in the second behavior graph are preset with node identifiers; the node identifiers preset for the branch nodes in the second behavior graph are the same as the node identifiers preset for the branch nodes in the first behavior graph.
10. The method according to claim 8, wherein: In response to receiving the node identifier of the first branch node and the running state of the first branch node sent by the first client, the step of controlling the behavior state of the target virtual character according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character includes: In response to receiving a data packet sent by the first client, decoding the data packet to obtain a node identifier of the first branch node and an operating status of the first branch node; determining, from the second behavior graph, a second branch node corresponding to the first branch node according to the node identifier of the first branch node; The running state of the first branch node is applied to the second branch node, and the behavior state of the target virtual character is controlled based on the second branch node.
11. The method according to claim 8, wherein: The method further comprises: In response to receiving a target instruction sent by the first client, the behavior state of the target virtual character is controlled according to the node identifier of the first branch node, the operating state of the first branch node, and the second behavior graph of the target virtual character; wherein the target instruction is used to indicate that the behavior state of the target virtual character after the change is a continuous behavior state with the behavior state of the target virtual character before the change.
12. A device for synchronizing a behavior state, the device being arranged on a first client, the device comprising: A first loading module is configured to load a first behavior graph of a target virtual character in response to a game start instruction; wherein the first behavior graph includes a plurality of branch nodes, and the branch nodes are preset with node identifiers; the branch nodes are used to control the behavior state of the target virtual character; and the target virtual character is controlled by the first client; a determination module configured to determine, in response to a change in the behavior state of the target virtual character, from the first behavior graph, a node identifier of a first branch node that affects the behavior state of the target virtual character and an operating state of the first branch node; A sending module is configured to send the node identifier of the first branch node and the operating status of the first branch node to a second client, and through the second client, control the behavior state of the target virtual character according to the node identifier of the first branch node, the operating status of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph.
13. A device for synchronizing a behavior state, the device being arranged on a second client, the device comprising: A second loading module, configured to load a second behavior graph of the target virtual character in response to a game start instruction; The target virtual character is controlled by the first client; The first client is loaded with a first behavior graph of the target virtual character; wherein the first behavior graph includes a plurality of branch nodes, each of which is preset with a node identifier; and the branch nodes are used to control the behavior state of the target virtual character; A state synchronization module is configured to control the behavior state of the target virtual character in response to receiving the node identifier of the first branch node and the running state of the first branch node sent by the first client, according to the node identifier of the first branch node, the running state of the first branch node, and the second behavior graph of the target virtual character, so that the behavior state of the target virtual character in the first client is synchronized with the behavior state of the target virtual character in the second client; wherein the second behavior graph is the same as the first behavior graph.
14. An electronic device, wherein: It includes a processor and a memory, the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the behavior state synchronization method described in any one of claims 1-7, or the behavior state synchronization method described in any one of claims 8-11.
15. A computer-readable storage medium, wherein: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by the processor, the computer-executable instructions prompt the processor to implement the method for synchronizing the behavioral states described in any one of claims 1-7, or to implement the method for synchronizing the behavioral states described in any one of claims 8-11.
Citation Information
Patent Citations
Data synchronization method and device, equipment and storage medium
CN112843682A
Method and device for controlling virtual character in game and electronic terminal
CN115501593A
Behavior state synchronization method and device and electronic equipment
CN116617649A
Efficient synchronization of behavior trees using network significant nodes
US20140372554A1
System and Method of Implementing Behavior Trees When Modifying Attribute Values of Game Entities Based On Physical Token Detection
US20170225076A1
Cited By
Virtual object interaction method and device, equipment and storage medium
CN119579740A
