Virtual object control method, device, apparatus, medium, and program product

By dynamically adjusting the behavior tree based on the distance between NPCs and player-controlled virtual objects, the problem of excessive AI object resource consumption in open-world games is solved, achieving a balance between rich NPC performance and server performance.

CN114404987BActive Publication Date: 2026-07-03TENCENT TECHNOLOGY (SHENZHEN) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2022-01-27
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

In open-world games, the use of the same behavior tree by AI objects leads to excessive server load, making it difficult to ensure rich expressiveness while avoiding excessive resource consumption.

Method used

By dynamically adjusting the behavior tree based on the distance between the virtual object and the virtual object controlled by the player, different behavior trees are used to control NPCs at different distances. NPCs that are closer consume more resources, while NPCs that are farther away consume fewer resources, thus maintaining a balance of computer equipment resources.

Benefits of technology

This approach enables NPCs to have rich expressive forms under limited computer resources, while avoiding excessive consumption of server performance and maintaining the smoothness and consistency of the game's performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114404987B_ABST
    Figure CN114404987B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, medium, and program product for controlling virtual objects, belonging to the field of computer technology. The method includes: controlling a first virtual object, which is a non-player character (NPC), through a first row tree; obtaining a first distance between the first virtual object and a second virtual object, which is a player-controlled virtual object, in a virtual environment; and determining, based on the first distance, to control the first virtual object through a second row tree, which is obtained by replacing or adjusting the first row tree. This solution ensures that NPCs can achieve rich expressive forms even with limited computer equipment resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of computer technology, and specifically relates to a method, apparatus, device, medium and program product for controlling virtual objects. Background Technology

[0002] Open-world games contain a large number of AI (Artificial Intelligence) objects, which are NPCs (Non-player Characters) with anthropomorphic behaviors.

[0003] In related technologies, a large number of AI objects often use the same behavior tree. However, if an AI object can achieve rich forms of expression, the behavior tree it uses must be very complex. If a large number of AI objects use the same complex behavior tree, the server performance will inevitably be poor.

[0004] How to ensure that AI objects can achieve rich forms of expression while avoiding excessive server performance consumption by a large number of AI objects has become an urgent technical problem to be solved. Summary of the Invention

[0005] This application provides a method, apparatus, device, medium, and program product for controlling virtual objects, to ensure that NPCs can achieve rich forms of expression under limited computer equipment resources. The technical solution is as follows:

[0006] According to one aspect of this application, a method for controlling a virtual object is provided, the method comprising:

[0007] The first virtual object is controlled through the first row tree. The first virtual object is a non-player character (NPC).

[0008] Obtain the first distance between a first virtual object and a second virtual object in the virtual environment, wherein the second virtual object is a virtual object controlled by the player;

[0009] Based on the first distance, it is determined that the first virtual object is controlled by the second row tree, which is obtained by replacing or adjusting the first row tree.

[0010] According to another aspect of this application, a method for displaying a virtual object is provided, the method comprising:

[0011] Display a first virtual object and a second virtual object. The first virtual object is a non-player character (NPC), and the second virtual object is a virtual object controlled by the player.

[0012] When the first virtual object and the second virtual object are at a first distance p in the virtual environment, the first virtual object is shown to perform a first number of actions;

[0013] When the first virtual object and the second virtual object are at a first distance of q in the virtual environment, the first virtual object is shown to perform a second number of actions;

[0014] Where p is greater than q, the first quantity is less than the second quantity; or, p is less than q, the first quantity is greater than the second quantity.

[0015] According to another aspect of this application, a method for displaying a virtual object is provided, the method comprising:

[0016] Display a first virtual object and a second virtual object. The first virtual object is a non-player character (NPC), and the second virtual object is a virtual object controlled by the player.

[0017] When the first virtual object and the second virtual object are at a first distance p in the virtual environment, the time interval for the first virtual object to perform the action is displayed as the first duration.

[0018] When the first virtual object and the second virtual object are at a first distance of q in the virtual environment, the time interval for the first virtual object to perform the action is displayed as the second duration;

[0019] Where p is greater than q, the first duration is greater than the second duration; or p is less than q, the first duration is less than the second duration.

[0020] According to another aspect of this application, a control device for a virtual object is provided, the device comprising:

[0021] The control module is used to control the first virtual object through the first line tree. The first virtual object is a non-player character (NPC).

[0022] The acquisition module is used to acquire the first distance between the first virtual object and the second virtual object in the virtual environment, where the second virtual object is a virtual object controlled by the player.

[0023] The determination module is used to determine, based on a first distance, the control of a first virtual object through a second row tree, which is obtained by replacing or adjusting the first row tree.

[0024] According to one aspect of this application, a computer device is provided, the computer device comprising: a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the control method of the virtual object as described above.

[0025] According to another aspect of this application, a computer-readable storage medium is provided, the storage medium storing a computer program that is loaded and executed by a processor to implement the control method of the virtual object as described above.

[0026] According to another aspect of this application, a computer program product is provided, the computer program product including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the control method for the virtual object provided in the above aspect.

[0027] The beneficial effects of the technical solutions provided in this application include at least the following:

[0028] Based on the first distance between the first virtual object and the second virtual object, a behavior tree controlling the first virtual object is determined, so that the behavior tree controlling the first virtual object is always in a dynamic adjustment state. That is, NPCs that are closer to the second virtual object and those that are farther away will be controlled through different behavior trees. The behavior tree used by the closer NPCs consumes more resources, while the behavior tree used by the farther NPCs consumes less resources. The total computer equipment resources consumed by a large number of NPCs will be kept in a balanced state, and the computer equipment resources will not be over-consumed. At the same time, when the NPC is closer to the second virtual object, it will have richer performance forms. Attached Figure Description

[0029] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0030] Figure 1 A schematic diagram of a behavior tree provided in an exemplary embodiment of this application is shown;

[0031] Figure 2 A flowchart illustrating a method for controlling a virtual object provided in an exemplary embodiment of this application is shown.

[0032] Figure 3 This illustration shows a schematic diagram of the LOD layering technology provided in an exemplary embodiment of this application;

[0033] Figure 4 A schematic diagram of LOD layering technology provided in another exemplary embodiment of this application is shown;

[0034] Figure 5 A schematic diagram illustrating the appearance of a first virtual object provided in an exemplary embodiment of this application is shown;

[0035] Figure 6A schematic diagram illustrating the behavior of a first virtual object provided in another exemplary embodiment of this application is shown;

[0036] Figure 7 This illustration shows a schematic diagram of the behavior of a first virtual object at different LOD levels provided in an exemplary embodiment of this application;

[0037] Figure 8 This illustration shows a schematic diagram of m decorator nodes attached to a sequential node according to an exemplary embodiment of this application;

[0038] Figure 9 This application illustrates a flowchart of a conditional judgment process provided by an exemplary embodiment.

[0039] Figure 10 A flowchart illustrating a method for controlling a virtual object provided in another exemplary embodiment of this application is shown;

[0040] Figure 11 This invention provides a structural block diagram of a control device for a virtual object according to an exemplary embodiment of the present application.

[0041] Figure 12 A structural block diagram of a computer device provided in an exemplary embodiment of this application is shown. Detailed Implementation

[0042] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0043] It should be understood that "several" in this article refers to one or more, and "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0044] First, the relevant technologies of this application will be introduced:

[0045] In the related technologies of this application, the control scheme for the behavior of AI objects includes controlling AI objects through finite state machines or Behaviac behavior trees (a type of behavior tree).

[0046] Finite state machines (FSMs) are a traditional AI implementation scheme. They define multiple states of an AI object and the conditions for transitioning between states. When an AI object is in state A, it can switch to state B if condition C, which allows it to transition from state A to state B, is met. The AI ​​object performs different tasks in different states and switches states based on conditional decisions. A series of states and transition conditions combine to form the complete AI object representation. The advantage of FSMs is their simplicity in principle and implementation, but their disadvantages are also quite obvious. They are generally suitable for situations with a finite number of states and simple transition relationships. In large-scale games, AI objects are often complex, with numerous states to define and complex transition relationships between states. Using FSMs would be too low-level of abstraction and not intuitive enough.

[0047] Behaviac is an open-source behavior tree implementation from Tencent. It implements control nodes such as selection, sequence, parallel, and condition to facilitate switching between behavior tree execution nodes. During behavior tree execution, the behavior of AI objects is transformed by switching different execution nodes. The advantage of Behaviac is that the business side only needs to implement simple execution and condition nodes, decoupling business logic from behavior tree control logic, making it suitable for more complex AI object representations. However, Behaviac does not support blackboard functionality, making debugging less intuitive, and the use of parallel nodes is inconvenient.

[0048] In the related technologies of this application, the synchronization schemes for AI object performance include server-side computation distribution, client-side computation + server forwarding, and client-side computation + synchronization server.

[0049] To ensure the consistency and real-time performance of AI objects in multiplayer teams, a conventional solution is to place the control of AI objects on the server side. The server is responsible for the calculation of the relevant logic of the AI ​​objects and sends the calculation results to each client for display (i.e., server-side calculation and distribution). However, for games that require AI objects to exhibit rich behaviors, to reduce the pressure on the server side to control the AI ​​object's performance, one existing solution is to transfer the behavior tree calculation logic of the AI ​​objects to a specific client. The client performs the behavior tree node logic calculations, then reports the calculation results to the server, and finally the server forwards them to other clients (i.e., client-side calculation + server forwarding). Another solution is for each client to perform independent calculations, using certain technical means to ensure the consistency of the calculation structure (i.e., client-side calculation + server synchronization).

[0050] The advantages of server-side computation are accurate logic, low latency, and no client-side cheating issues. However, the disadvantages are also quite obvious. In open-world games, placing a large amount of server-side AI computation on the server side will significantly impact performance and negatively affect the player experience. Therefore, in this approach, the behavior of AI objects is relatively simple, such as only simple patrolling, chasing, and fleeing.

[0051] The advantage of client-side computation combined with server forwarding is that it can greatly reduce the computational burden on the server and improve server performance. However, it inevitably brings the problem of client-side cheating, and when the network of the client responsible for computation is poor, it will affect the performance of AI objects on other clients. At the same time, this solution has certain limitations and is more often used in short-term, single-game products.

[0052] The client-side computation + synchronous server approach also has some obvious drawbacks, such as the potential for inconsistencies in computation across multiple clients, which can lead to different behaviors of the same AI object on different clients. It also poses security risks. Furthermore, this approach is difficult to support more complex AI object behaviors, such as integration with time and weather systems.

[0053] The following is a brief introduction to the terms used in the embodiments of this application:

[0054] Virtual environment: This refers to the virtual environment displayed (or provided) by the client when running on the terminal. This virtual environment can be a simulation of the real world, a semi-simulated / semi-fictional environment, or a purely fictional environment. The virtual environment can be any of a two-dimensional, 2.5-dimensional, or three-dimensional virtual environment; this application does not limit it to any particular type. The following embodiments use a three-dimensional virtual environment as an example.

[0055] Optionally, the virtual environment can provide a combat environment for virtual objects. For example, in an open-world game, players can freely control virtual objects to roam the virtual environment and choose when and how to complete game tasks. During roaming, the player-controlled virtual object will continuously interact with AI objects within the virtual environment. In battle royale games, at least one virtual object engages in a single-round battle within the virtual environment. The virtual object survives by avoiding attacks from enemy units and dangers present in the virtual environment (such as poison gas circles, swamps, etc.). When the virtual object's health reaches zero, its life ends. The virtual object that successfully completes the level's route at the end is the winner. For example, in a level-based game, at least one virtual object engages in a single-round battle within the virtual environment. The virtual object gains access to the current level by defeating monsters, allowing it to advance to the next level or end the current round.

[0056] Virtual objects refer to movable objects in a virtual environment. These movable objects can be virtual characters, virtual animals, anime characters, etc., such as people and animals displayed in a 3D virtual environment. Optionally, virtual objects are 3D models created based on animation skeletal technology. Each virtual object has its own shape and volume in the 3D virtual environment and occupies a portion of the space in the 3D virtual environment.

[0057] Unreal Engine (UE) 4: Unreal Engine 4 is an application development engine, which can include games and other applications. Unreal Engine 4 can be abbreviated as UE4.

[0058] UE4 Behavior Tree: Refers to the behavior tree provided in UE4. The UE4 behavior tree includes a root node, composite nodes, task nodes, and auxiliary nodes.

[0059] The root node is the starting node of the UE4 behavior tree.

[0060] Composite nodes include sequence nodes, selector nodes, and simpleparallel nodes. A composite node has at least two child nodes.

[0061] Sequential nodes are used to indicate the order in which subordinate nodes are executed. If all subordinate nodes return success (Succeeded), the sequential node itself returns success; if any subordinate node returns failure (Failed), execution of subsequent subordinate nodes stops. If there are no task nodes below the sequential node, failure is returned to the sequential node.

[0062] The select node is used to instruct the execution of its subordinate nodes in sequence. If one of the subordinate nodes returns success, the select node itself returns success; if all nodes return failure, the select node returns failure. If there are no task nodes below the select node, failure is returned to the select node.

[0063] Parallel nodes are used to connect a master task node and another parallel node, which may be a composite node or a task node. If the master task node returns success, the parallel node returns success; if the master task node returns failure, the parallel node returns failure. The result of a parallel node is independent of the result of the other parallel node.

[0064] Task nodes are used to control the specific behaviors of AI objects. They are typically located at the bottom of the UE4 behavior tree and represent the endpoint of the AI ​​object's behavior. Task nodes can be broadly categorized into instantaneous task nodes (simply called momentary task nodes) and continuous task nodes (simply called persistent task nodes). Persistent task nodes inevitably experience interruptions, which are handled in the UE4 behavior tree through decorator nodes.

[0065] Auxiliary nodes include decorator nodes and service nodes.

[0066] Decorator nodes are used to attach to composite nodes or task nodes. Decorator nodes are used to determine whether a subtree of the UE4 behavior tree is executed and whether a subtree is interrupted.

[0067] When the decorator node's parent node is a selection node, the decorator node has four optional settings: None, Self, LowerPriority, and Both; when the decorator node's parent node is a sequence node, the decorator node has two optional settings: None and Self.

[0068] • None: Decorator nodes with None selected only perform conditional checks. If the result is true, the branch containing the decorator node is executed; if the result is false, the branch containing the decorator node is not executed.

[0069] • Self: Selecting a decorator node with Self not only performs the conditional evaluation function but also interrupts the branch containing the decorator node. If the condition evaluation result changes from true to false while the branch containing the decorator node is being executed, the execution of that branch will be interrupted.

[0070] • LowerPriority: Decorator nodes that select LowerPriority not only perform conditional checks but can also interrupt lower-priority branches. If a conditional check changes from false to true while a lower-priority branch is being executed, the lower-priority branch is interrupted, and execution proceeds to the branch containing the decorator node.

[0071] • Both: Selecting a decorator node with both not only performs the conditional judgment function, but also interrupts the branch where the decorator node is located or a low-priority branch.

[0072] Service nodes are typically attached to composite nodes or task nodes. They execute at defined time intervals whenever their branches are executed. Service nodes are commonly used to check and update the blackboard. Service nodes replace traditional parallel nodes in other behavior tree systems. Service nodes do not return any values ​​and do not directly affect the execution flow of the UE4 behavior tree.

[0073] The blackboard is used to store the data required to execute the UE4 behavior tree; this data is called the blackboard value. The blackboard is used in conjunction with the UE4 behavior tree to control the behavior of AI objects.

[0074] The implementation environment of the embodiments of this application will be described next.

[0075] In this application, the behavior tree controlling the behavior of the first virtual object runs on a server or terminal. (Refer to the references...) Figure 1 This illustrates a behavior tree provided in an exemplary embodiment of this application. The composite node includes a selection node 102, a sequence node 105, and a sequence node 108, and the behavior tree also includes a root node 101.

[0076] Task nodes 106, 107, 110, and 111 are task nodes that control the behavior of the first virtual object. Service node 103 is attached to selection node 102. When its subordinate branches execute, service node 103 updates environmental information at preset intervals and stores the updated environmental information, including the current ambient light intensity, on the blackboard. Service node 109 is attached to sequence node 108. Service node 109 updates the torch time at preset intervals and stores the updated torch time on the blackboard. The torch time is the time from when the first virtual object started executing the torch-holding task branch to the current time.

[0077] Decorator node 104 is used to determine whether to execute the task branch of moving to the shade (or not execute the task branch of moving to the shade), or to determine whether to interrupt the execution of the task branch of moving to the shade (or to determine whether to interrupt the task branch of holding a torch).

[0078] Optionally, when the light intensity is greater than 200, decorator node 104 determines to execute the task branch that moves to the shade. When the light intensity is not greater than 200, it executes the lower priority branch. Specifically, how decorator node 104 controls branch execution and interruption needs to be determined in conjunction with the decorator node's attribute settings, which will not be elaborated here.

[0079] In one embodiment, Figure 1The behavior tree shown runs entirely on a server. The server can be one or more servers, a cloud computing platform, or a virtualization center. For example, the server includes a processor and memory. The memory further includes a receiving module, a control module, and a sending module. The receiving module receives requests from the application, such as a player's request to control the movement of a second virtual character. The control module controls the rendering of the virtual environment. The sending module sends responses to the application, such as instructions to control the movement of the second virtual character.

[0080] In one embodiment, Figure 1 The behavior tree shown is entirely run on the terminal. The terminal has applications that support virtual environments installed and running. Optionally, the terminals supporting virtual environments may be of the same or different device types, including at least one of the following: smart TVs, wearable devices, in-vehicle terminals, smartphones, tablets, e-book readers, MP3 players, MP4 players, laptops, and desktop computers.

[0081] In one embodiment, Figure 1 The behavior tree shown is partially stored and runs on the server, and partially stored and runs on the terminal; this application does not limit this.

[0082] In one embodiment, before running the behavior tree that controls the behavior of the first virtual object, this application also uses LOD (Level of Distance) layering technology to determine the level of the first virtual object. This layering process may be partially stored and run on the server, and another part may be stored and run on the server; this layering process may also be entirely stored and run on the server; this layering process may also be entirely stored and run on the terminal.

[0083] In the following embodiments, the behavior tree and LOD layering technologies will be used as examples to illustrate the process of running entirely on a server.

[0084] To ensure that NPCs can achieve rich forms of expression under limited computer equipment resources, Figure 2 This application illustrates a method for controlling a virtual object provided in an exemplary embodiment, exemplified by the method running on a server. The method includes:

[0085] Step 220: Control the first virtual object through the first row tree;

[0086] The first virtual object refers to an NPC with anthropomorphic behavior. In open-world games, the first virtual object can also be called an AI object. AI objects act within the virtual environment through their own control logic. Optionally, this activity includes self-interaction, such as an AI object patrolling its territory, arguing with AI objects that invade its territory, resting, or sleeping. Optionally, this activity also includes interaction with player-controlled virtual objects, such as an AI object showing curiosity and continuously observing a player-controlled virtual object, or an AI object showing tension and quickly fleeing when faced with a player-controlled virtual object.

[0087] First Behavior Tree: Refers to the behavior tree used to control the behavior of the first virtual object. Optionally, the type of the first behavior tree is the Unreal Engine UE4 behavior tree. In one embodiment, the UE4 behavior tree is obtained by stripping the behavior tree module from UE4 and removing the engine-related parts.

[0088] In one embodiment, the first behavior tree can be a behavior tree for virtual objects that are not controlled by players within a preset range of the first virtual object, which may be called the initial behavior tree. The initial behavior tree can also be a behavior tree for controlling the first virtual object when none of the players can observe it. For example, when none of the players can observe the first virtual object, the first virtual object behaves as if it is stationary.

[0089] In one embodiment, the first behavior tree can be the behavior tree of the first virtual object controlled when the first virtual object is already within the player's field of view, for example, in conjunction with reference to... Figure 1 The diagram illustrates the first row of the tree. Decorator node 104 is used to determine whether to execute the branch that moves to the shade (or not to execute the branch that moves to the shade), and / or whether to interrupt the execution of the branch that moves to the shade (or the low-priority branch, i.e. the branch with the torch).

[0090] In one embodiment, the server manages the first virtual object using a spatial octree. An octree is a tree-like data structure where each internal node has exactly eight child nodes, commonly used to partition three-dimensional space, recursively subdividing it into eight quadrants. When managing the first virtual object using a spatial octree, each octree node records the size of the space and information about the first virtual object it contains.

[0091] Step 240: Obtain the first distance between the first virtual object and the second virtual object in the virtual environment;

[0092] The second virtual object refers to the virtual object controlled by the player.

[0093] In one embodiment, the server obtains a first distance between a first virtual object and a second virtual object in the virtual environment at preset time intervals, for example, the server obtains the first distance every 1 second.

[0094] In another embodiment, the server determines the time interval between obtaining the first distance and obtaining the first distance again, based on the first distance obtained. Optionally, if the first distance is large, the time interval between obtaining the first distance again is large; if the first distance is small, the time interval between obtaining the first distance again is small.

[0095] More specifically, if the first distance falls within the target distance range of at least two distance ranges, the server determines the next time interval for acquiring the first distance based on the time interval corresponding to the target distance range. In one embodiment, the server employs LOD (Level of Detail) layering technology to determine the time interval for acquiring the first distance. (Refer to the reference...) Figure 3 This illustrates a schematic diagram of the LOD layering technology provided in an exemplary embodiment of this application.

[0096] Among them, LOD2 301 is the third layer farthest from the second virtual object 305, LOD1 302 is the second layer second farthest from the second virtual object 305, and LOD0 303 is the first layer closest to the second virtual object 305. Figure 3 The first virtual object 304 is also shown. Optionally, the radius of the circle in the third layer is 8000 cm, the radius of the circle in the second layer is 4000 cm, and the radius of the circle in the first layer is 1000 cm.

[0097] Depend on Figure 3 Therefore, the server can determine the target level of the first virtual object using LOD layering technology, and determine the time interval for obtaining the first distance corresponding to the target level. For example, if the first virtual object is in the third level (LOD2), the next time interval for obtaining the first distance is 2 seconds; if it is in the second level (LOD1), the time interval is 1 second; and if it is in the first level, the time interval is 0.5 seconds.

[0098] Step 260: Based on the first distance, determine that the first virtual object is controlled by the second behavior tree.

[0099] Among them, the resources consumed by the first distance and the second row tree during runtime are negatively correlated.

[0100] In one embodiment, the server determines to control the first virtual object by means of a second behavior tree corresponding to the target distance range, based on the target distance range falling within at least two distance ranges; wherein at least two distance ranges correspond one-to-one with at least two second behavior trees.

[0101] In one embodiment, the negative correlation between the resources consumed by the first distance and the second row tree during runtime can be understood as follows: the larger the first distance, the less resources the second row tree consumes, and the smaller the first distance, the more resources the second row tree consumes.

[0102] To illustrate, the server determines the target level of the first virtual object using LOD layering technology, and determines to control the first virtual object through a second behavior tree corresponding to the target level.

[0103] Reference Figure 3 Based on the distance between the first virtual object 304 and the second virtual object 305, it can be determined that the first virtual object 304 is at the first level LOD0. The server determines to control the first virtual object through the second behavior tree corresponding to the first level LOD0. The behavior trees corresponding to the first level LOD0, the second level LOD1, and the third level LOD2 are sorted in descending order of resource consumption.

[0104] In one embodiment, before step 260, the method further includes: the server obtaining a second distance between a first virtual object and a third virtual object in the virtual environment; wherein at least one third virtual object also exists in the virtual environment, and the third virtual object is a virtual object controlled by another player.

[0105] At this point, step 260 can be replaced by step S1.

[0106] S1, if the first distance is less than the second distance, based on the first distance falling into the target distance range of at least two distance ranges, determine to control the first virtual object through the second behavior tree corresponding to the target distance range;

[0107] Alternatively, step 260 can be replaced with S2.

[0108] S2, if the first distance is greater than the second distance, based on the second distance falling into the target distance range of at least two distance ranges, determine to control the first virtual object through the second behavior tree corresponding to the target distance range.

[0109] Reference Figure 4 At this time, the first distance between the first virtual object 304 and the second virtual object 305 is less than the second distance between the first virtual object 304 and the third virtual object 306. That is, the first virtual object 304 is located in the second layer of the second virtual object 305, and at the same time, the first virtual object 304 is located in the third layer of the third virtual object 306. Therefore, the second behavior tree corresponding to the second layer is determined to control the first virtual object 304.

[0110] In one embodiment, the second row tree is obtained by replacing or adjusting the first row tree. The two specific cases will be described in detail in the following embodiments.

[0111] In one embodiment, both the first and second behavior trees are of type UE4 behavior trees.

[0112] In one embodiment, in conjunction with reference Figure 5 , Figure 5 A schematic diagram of a virtual environment is shown, in which the first virtual object 304 is at LOD1 (second layer), and at this time, the first virtual object 304 is continuously observing the second virtual object 305. (Refer to the reference.) Figure 6 At this time, the first virtual object 304 is at LOD0 (first layer), and the first virtual object 304 will move away from the second virtual object 305.

[0113] In one embodiment, Figure 7 This illustrates the behavior of the first virtual object at LOD0, LOD1, and LOD2 layers. Figure 7 In part (A), the first virtual object 304 is located at LOD2 and is performing self-interaction (patrolling, arguing with other NPCs, sleeping, etc.). Figure 7 In part (B), the first virtual object 304 is located at the LOD1 layer and is continuously observing the second virtual object (also known as the alert state). Figure 7 In part (C), the first virtual object 304 is located at the LOD0 layer and is escaping from the second virtual object.

[0114] In summary, based on the first distance between the first virtual object and the second virtual object, a behavior tree controlling the first virtual object is determined, ensuring that the behavior tree controlling the first virtual object is always in a dynamic adjustment state. That is, NPCs that are closer to and farther from the second virtual object will be controlled through different behavior trees. NPCs that are closer to the second virtual object will use behavior trees that consume more resources, while NPCs that are farther away will use behavior trees that consume less resources. The total computer equipment resources consumed by a large number of NPCs will be maintained in a balanced state, and computer equipment resources will not be excessively consumed. At the same time, when an NPC is closer to the second virtual object, it will have richer performance forms.

[0115] The above method further provides a way to determine the second row tree by distance by determining that the first distance falls within a preset target distance range and then determining that the first virtual object is controlled by the second row tree corresponding to the target distance range.

[0116] based on Figure 2In the optional embodiment shown, step 260 can be replaced by step S3 (including steps S31 and S32):

[0117] S31, based on the first distance, replace the first row tree with the second row tree;

[0118] S32, determine that the first virtual object is controlled through the second row tree.

[0119] At this point, the second row tree is obtained by replacing the first row tree, and the second row tree corresponds to the first distance.

[0120] In one embodiment, if the first behavior tree is a behavior tree corresponding to a first distance range, the second behavior tree is a behavior tree corresponding to a second distance range, and the first distance range is greater than the second distance range, then the server replaces the first behavior tree with the second behavior tree, thereby increasing the complexity of the behavior tree controlling the first virtual object. The complexity can be understood as the server performance consumed by running the behavior tree. If the behavior tree has many branches, or many decorator nodes, or many service nodes, etc., then the behavior tree consumes a large amount of server performance.

[0121] Indicative, combined Figure 3 The LOD layering technique shown has a first behavior tree corresponding to any one of the following layers: LOD0 layer 303, LOD1 layer 302, and LOD2 layer 301. The second behavior tree corresponds to all layers except the one corresponding to the first behavior tree. For example, the first behavior tree corresponds to LOD1 layer 302, and the second behavior tree corresponds to LOD0 layer 303.

[0122] Optionally, the server preloads the second-row tree before switching to it, so that the switch process only requires stopping the first-row tree and starting the second-row tree.

[0123] In summary, by replacing the first behavior tree with the second behavior tree, a way to determine the behavior tree that controls the first virtual object is provided. Furthermore, by preloading the behavior trees in the behavior library, only a simple behavior tree stop and start is required during replacement, avoiding the overhead of creating a behavior tree.

[0124] based on Figure 2 In the optional embodiment shown, step 260 can be replaced by step S4 (including steps S41, S42 and S43):

[0125] S41, based on the first distance, adjust the first update cycle of the first row tree to the second update cycle;

[0126] The first update cycle and the second update cycle are used to indicate the time interval between two adjacent decisions output by the first behavior tree. (Illustrative, in conjunction with references) Figure 1 The first update cycle and the second update cycle are used to indicate the time interval between determining the task execution node 106 and determining the task execution node 107 in the first row tree. The update cycle can also be represented by update frequency, update frequency, etc., which can be calculated through simple mathematical transformations.

[0127] In one embodiment, in conjunction with reference Figure 3 The diagram illustrating LOD layering technology shows that the first distance corresponds to the second update cycle. This can be understood as the first distance range corresponding to the second update cycle, meaning the target layer of the first virtual object corresponds to the second update cycle. For example, LOD0 has the shortest update cycle at 100ms; LOD1 has the next shortest at 500ms; and LOD3 has the longest update cycle at 1000ms.

[0128] Based on the first distance, the server adjusts the first update cycle of the first row of the tree to the second update cycle.

[0129] S42, the first row tree using the second update cycle is determined as the second row tree;

[0130] The server will determine the first row tree of the second update cycle as the second row tree.

[0131] S43, determine that the first virtual object is controlled through the second row tree.

[0132] The server determines that the first virtual object is controlled through the second row tree, and the update cycle of the second row tree is the second update cycle.

[0133] In one embodiment, step S4 is followed by step S5.

[0134] S5, adjust the third update cycle of the service nodes in the first row of the tree to the fourth update cycle.

[0135] The fourth update cycle corresponds to the first interval, and the service node is used to update the data required to run the first row tree. The third and fourth update cycles are used to indicate the time interval between two adjacent updates performed by the service node.

[0136] In a first- or second-behavior tree, service nodes are typically connected to composite nodes or task nodes, and they execute at defined time intervals whenever their branches are executed. Service nodes are often used to check and update the blackboard. In UE4 behavior trees, service nodes replace the traditional parallel nodes found in other behavior tree systems. Service nodes do not return any values ​​and do not directly affect the execution flow.

[0137] In summary, by adjusting the update cycle of the first behavior tree, the behavior tree controlling the first virtual object is always in a dynamic adjustment state. NPCs that are closer to and farther from the second virtual object will be controlled by behavior trees with different update cycles. NPCs that are closer will use behavior trees with shorter update cycles, while NPCs that are farther away will use behavior trees with longer update cycles. The total computer equipment resources consumed by a large number of NPCs will be kept in a balanced state, and computer equipment resources will not be over-consumed. At the same time, when an NPC is closer to the second virtual object, it will have richer performance forms.

[0138] The above scheme also adaptively adjusts the update cycle of the service nodes of the first row tree when adjusting the update cycle of the first row tree, so that the update cycle of the service nodes after adjustment is adapted to the first distance and the adjusted update cycle of the first row tree, further ensuring that computer equipment resources are not over-consumed.

[0139] based on Figure 2 In the alternative embodiment shown, step S6 is further included after step 260.

[0140] S6, In the process of controlling the first virtual object through the second row tree, after the last update of the target data in the kth update cycle of the second row tree, a condition judgment is performed on the m decorator nodes.

[0141] The target data is the input data required to run the second row tree. A sequential node of the second row tree has m decorator nodes attached to it. The sequential node is used to return a success value if all child nodes of the sequential node return a success value. The decorator nodes are used to determine at least one of the following: execute or not execute the branch where the sequential node is located, determine the branch where the sequential node is located, or determine the low-priority branch of the branch where the sequential node is located. m and k are positive integers.

[0142] Optionally, step S6 can be replaced by steps S61 and S62.

[0143] S61, In the process of controlling the first virtual object through the second behavior tree, when the blackboard value is updated for the ith time, mark the current number of times the blackboard value has been updated on the sequence node;

[0144] In this sequence node, m decorator nodes are attached, and these m decorator nodes focus on the same blackboard value. The blackboard value is updated n times within the k-th update cycle of the second row tree. The blackboard value is the data required to run the first row tree; for example, in conjunction with a reference... Figure 1 Decorator node 104 focuses on the blackboard value of light intensity, and at this time only one decorator node 104 is attached to the sequence node 105.

[0145] This sequential node contains m decorator nodes, which, in conjunction with the reference... Figure 8 Sequential node 801 has m decorator nodes attached, and all m decorator nodes focus on the same blackboard value. For example, the blackboard value is light intensity. Illustratively, decorator node 1 calculates light intensity greater than 2000, decorator node 2 calculates light intensity less than 4000, decorator node 3 calculates the ratio of light intensity to air humidity greater than 5, and decorator node 4 calculates the ratio of light intensity to ambient temperature greater than 10.

[0146] The blackboard value is updated n times within the update cycle of the second row tree. That is, the blackboard value is updated n times during the time interval between two adjacent decisions output by the first row tree. For example, the previous decision controls the first virtual object to obtain the shade position, and the next decision controls the first virtual object to move to the shade position. Between the two decisions, the light intensity is updated n times by the service node.

[0147] In one embodiment, the sequence node is used to return a success value if all child nodes of the sequence node return a success value, the decorator node is used to determine the branch of the second line tree to execute and the branch of the second line tree to interrupt execution, and the blackboard value is stored in the blackboard used to match the second line tree, where m, k, and n are all positive integers.

[0148] S62, after the blackboard value is updated for the nth time, obtain the m calculation results of m decorator nodes based on the blackboard value, and perform a condition judgment based on the m calculation results;

[0149] After the blackboard value is updated n times, the server obtains m calculation results of m decorator nodes based on the blackboard value. The server performs a condition judgment based on the m calculation results. The condition judgment is used to determine at least one of the following: the branch where the sequential node is executed or not executed, the branch where the sequential node is interrupted, and the low-priority branch of the branch where the sequential node is interrupted.

[0150] In one embodiment, when the blackboard value is updated for the i-th time, m decorator nodes are traversed and notified. The above step S61 can be replaced by "when one of the m decorator nodes is notified, the sequential node is marked once, so that the sequential node is marked a total of m times when the blackboard value is updated for the i-th time". Step S62 can be replaced by "after the sequential node is marked m*n times, the m calculation results of the m decorator nodes based on the blackboard value are obtained".

[0151] To illustrate, sequential nodes will be marked each time the blackboard value is updated. Figure 9 The process of marking sequential nodes when updating the blackboard value once is shown.

[0152] 901, Begin;

[0153] The server begins the process of marking sequential nodes based on a single updated blackboard value.

[0154] 902, Update blackboard value;

[0155] The server updates the same blackboard value that m decorator nodes are interested in through the service node.

[0156] 903, notify the j-th decorator node, the initial value of j is 1;

[0157] The server will notify the j-th decorator node that the blackboard value has been updated.

[0158] 904, marking sequential nodes;

[0159] The server marks the sequence node once after each decorator node is notified.

[0160] 905, j equals m;

[0161] The server determines whether all m decorator nodes have been notified. If yes, it proceeds to step 907; otherwise, it proceeds to step 906.

[0162] 906, j = j + 1;

[0163] The server updates the value of j to j+1 and re-executes step 903.

[0164] 907, retrieve m calculation results from m decorator nodes;

[0165] The server retrieves m calculation results from m decorator nodes. Each decorator performs an independent calculation on the blackboard value by comparing it with a preset value.

[0166] 908, perform a conditional check;

[0167] The server performs a conditional check based on m decorator nodes. For example, the server retrieves m computation results from m decorator nodes. If all m to m computation results are true, the conditional check is true; if any one of the m to m computation results is false, the conditional check is false.

[0168] The conditional judgment is used to determine at least one of the following: the branch containing the sequential node to be executed or not executed, the branch containing the interrupted sequential node, and the lower priority branch of the branch containing the interrupted sequential node.

[0169] 909, End.

[0170] The server terminates the process of marking sequential nodes based on a single updated blackboard value.

[0171] In summary, by optimizing the condition judgment process of decorator nodes within an update cycle, only one condition judgment is performed within an update cycle. Compared with the condition judgment process in the related technologies of this application, unnecessary performance loss during behavior tree operation is avoided, and the performance of computer equipment is optimized.

[0172] In the related technologies of this application, if multiple decorators exist on a sequential node, and these decorators all focus on a single blackboard value, a significant performance overhead will occur when the blackboard value changes. (Refer to the references...) Figure 8 If all m decorator nodes on sequential node 801 are concerned with the blackboard value of light intensity, then when the light intensity changes, each of the m decorator nodes will be notified sequentially through a traversal process. After notifying each decorator node, the server will calculate the results of the m decorators and then perform a conditional check. This results in m conditional checks during a single blackboard value modification. If the blackboard value is modified n times during this behavior tree update, up to m*n conditional checks will be generated.

[0173] To ensure that NPCs can achieve rich forms of expression under limited computer equipment resources, Figure 10 This application illustrates a method for controlling a virtual object provided in an exemplary embodiment, exemplified by the method running on a server. The method includes:

[0174] Step 1001, Begin;

[0175] The server begins executing the virtual object control method provided in this embodiment.

[0176] Step 1002: Preload all behavior trees used to control the first virtual object;

[0177] Before determining the behavior tree for controlling the first virtual object, the server preloads all behavior trees used to control the first virtual object. All behavior trees include the first behavior tree and the second behavior tree. In this embodiment, the second behavior tree is different from the first behavior tree; that is, the second behavior tree is obtained by replacing the first behavior tree.

[0178] Step 1003, start the first row of the tree;

[0179] The server initiates the first behavior tree to control the first virtual object. The first behavior tree can be the behavior tree for virtual objects that are not controlled by players within a preset range of the first virtual object; this can be called the initial behavior tree. The first behavior tree can also be the behavior tree for controlling the first virtual object when none of the players can observe it. Furthermore, the first behavior tree can also be the behavior tree for controlling the first virtual object when it is already within the players' observation range.

[0180] Step 1004: Control the movement of the first virtual object or the second virtual object;

[0181] The server controls the movement of the first virtual object through the first row tree, or the server controls the movement of the second virtual object. The first virtual object is a non-player character (NPC). The second virtual object is a virtual object controlled by the player.

[0182] Step 1005: Obtain the distance between the first virtual object and the second virtual object, and evaluate the LOD level of the first virtual object;

[0183] The server obtains the first distance between the first virtual object and the second virtual object, and evaluates the level of the first virtual object using LOD (Level of Detail) layering technology. LOD layering technology divides the space into at least two levels, centered on the second virtual object and based on its spatial distance from the first virtual object. For example, the first level indicates a distance range of 0–50, the second level indicates a distance range of 50–100, and the third level indicates a distance range of 100–150. If the first distance is 75, then the first virtual object is determined to be in the second level.

[0184] Step 1006, LOD level change;

[0185] The server determines whether the hierarchy of the first virtual object has changed; if yes, it executes step 1007; otherwise, it executes step 1005.

[0186] Step 1007: Stop the first row as a tree;

[0187] The server stops controlling the first virtual object through the first row tree.

[0188] Step 1008, start the second row tree;

[0189] The server starts the second line tree and controls the first virtual object through the second line tree.

[0190] Step 1009, End.

[0191] The server terminates the execution of the virtual object control method provided in this embodiment.

[0192] The following describes a method for displaying virtual objects provided in this application, using an example of applying the method to a terminal (or a client running on the terminal). The method includes the following three steps:

[0193] 1. Display the first virtual object and the second virtual object;

[0194] In one embodiment, the terminal displays a first virtual object and a second virtual object in a virtual environment, wherein the first virtual object is a non-player character (NPC). Optionally, the first virtual object refers to an NPC with anthropomorphic behavior. In open-world games, the first virtual object can also be called an AI object, which operates in the virtual environment through its own control logic.

[0195] The second virtual object refers to the virtual object controlled by the player. The terminal receives operation requests from the player for the second virtual object and responds to those requests. For example, if the terminal receives a request for the second virtual object to run towards the first virtual object, the terminal controls the second virtual object to move quickly towards the first virtual object.

[0196] 2. When the first virtual object and the second virtual object are at a first distance p in the virtual environment, the first virtual object is shown to perform a first number of actions;

[0197] 3. When the first virtual object and the second virtual object are at a first distance of q in the virtual environment, the first virtual object is shown to perform a second number of actions;

[0198] Where p is greater than q, the first quantity is less than the second quantity; or, p is less than q, the first quantity is greater than the second quantity.

[0199] In one embodiment, when p is greater than q, the first quantity is less than the second quantity; or, when p is less than q, the first quantity is greater than the second quantity. This can be understood as follows: when the distance between the first virtual object and the second virtual object decreases (i.e., the first distance gradually decreases), the number of actions performed by the first virtual object gradually increases. When the distance between the first virtual object and the second virtual object increases (i.e., the first distance gradually increases), the number of actions performed by the first virtual object gradually decreases.

[0200] To illustrate, when the first distance is large, the first virtual object performs one action, such as sleeping in place; when the first distance is small, the first virtual object performs four actions, such as moving towards the first virtual object, observing the second virtual object, spitting at the second virtual object, and quickly escaping from the second virtual object.

[0201] It is worth noting that, in one scenario, assuming that the first virtual object and the second virtual object exist in the virtual environment at a distance of a first distance, and that both the first virtual object and the second virtual object remain stationary for a period of time, the number of actions that the first virtual object will perform will be inversely correlated with the first distance. That is, the first distance is inversely correlated with the overhead of controlling the behavior tree of the first virtual object.

[0202] In summary, by displaying the first virtual object performing different numbers of actions based on distance in the virtual environment, NPCs that are closer consume more resources, while NPCs that are farther away consume fewer resources. The total computer equipment resources consumed by a large number of NPCs will be kept in a balanced state, and computer equipment resources will not be over-consumed. At the same time, when an NPC is closer to the second virtual object, it will have more actions.

[0203] The following describes a method for displaying virtual objects provided in this application, using an example of applying the method to a terminal (or a client running on the terminal). The method includes the following three steps:

[0204] 1. Display the first virtual object and the second virtual object. The first virtual object is a non-player character (NPC), and the second virtual object is a virtual object controlled by the player.

[0205] In one embodiment, the terminal displays a first virtual object and a second virtual object in a virtual environment, wherein the first virtual object is a non-player character (NPC). Optionally, the first virtual object refers to an NPC with anthropomorphic behavior. In open-world games, the first virtual object can also be called an AI object, which operates in the virtual environment through its own control logic.

[0206] The second virtual object refers to the virtual object controlled by the player. The terminal receives operation requests from the player for the second virtual object and responds to those requests. For example, if the terminal receives a request for the second virtual object to run towards the first virtual object, the terminal controls the second virtual object to move quickly towards the first virtual object.

[0207] 2. When the first distance between the first virtual object and the second virtual object in the virtual environment is p, the time interval for the first virtual object to perform the action is displayed as the first duration.

[0208] 3. When the first distance between the first virtual object and the second virtual object in the virtual environment is q, the time interval for the first virtual object to perform the action is displayed as the second duration;

[0209] Where p is greater than q, the first duration is greater than the second duration; or p is less than q, the first duration is less than the second duration.

[0210] In one embodiment, when p is greater than q, the first duration is greater than the second duration; or, when p is less than q, the first duration is less than the second duration. This can be understood as follows: when the distance between the first virtual object and the second virtual object decreases (i.e., the first distance gradually decreases), the time interval between adjacent actions performed by the first virtual object gradually decreases. Conversely, when the distance between the first virtual object and the second virtual object increases (i.e., the first distance gradually increases), the time interval between adjacent actions performed by the first virtual object gradually increases.

[0211] To illustrate, when the initial distance is large, the first virtual object performs two actions, such as arguing and sleeping, with a time interval of 5 seconds between the two actions; when the initial distance is small, the first virtual object performs four actions, such as moving towards the first virtual object, observing the second virtual object, spitting at the second virtual object, and quickly escaping from the second virtual object, with a time interval of 3 seconds between the four actions.

[0212] It is worth noting that, in one scenario, assuming that the first virtual object and the second virtual object exist in the virtual environment at a distance of a first distance, and both the first virtual object and the second virtual object remain stationary for a period of time, the time interval of the action performed by the first virtual object will be positively correlated with the first distance, that is, the first distance is negatively correlated with the overhead of controlling the behavior tree of the first virtual object.

[0213] In summary, by displaying different intervals for the first virtual object to perform actions based on distance in the virtual environment, NPCs that are closer consume more resources, while NPCs that are farther away consume fewer resources. The total computer resources consumed by a large number of NPCs will be kept in a balanced state, and computer resources will not be over-consumed. At the same time, when NPCs are closer to the second virtual object, they will have a higher smoothness.

[0214] Figure 11 This application shows a structural block diagram of a control device for a virtual object provided in an exemplary embodiment. The device includes:

[0215] Control module 1101 is used to control a first virtual object through a first behavior tree. The first virtual object is a non-player character NPC.

[0216] The acquisition module 1102 is used to acquire a first distance between a first virtual object and a second virtual object in a virtual environment, wherein the second virtual object is a virtual object controlled by the player.

[0217] The determination module 1103 is used to determine, based on the first distance, the control of the first virtual object through the second row tree, wherein the resources consumed by the first distance and the second row tree at runtime are negatively correlated.

[0218] In an optional embodiment, the determining module 1103 is further configured to determine, based on the target distance range falling within at least two distance ranges, to control the first virtual object through a second behavior tree corresponding to the target distance range; wherein, at least two distance ranges correspond one-to-one with at least two second behavior trees.

[0219] In an optional embodiment, at least one third virtual object also exists in the virtual environment, which is a virtual object controlled by other players; the acquisition module 1102 is also used to acquire a second distance between the first virtual object and the third virtual object in the virtual environment.

[0220] In an optional embodiment, the determining module 1103 is further configured to, when the first distance is less than the second distance, determine to control the first virtual object by a second behavior tree corresponding to the target distance range based on the first distance falling within at least two distance ranges.

[0221] In an optional embodiment, the determining module 1103 is further configured to, when the first distance is greater than the second distance, determine to control the first virtual object by a second behavior tree corresponding to the target distance range based on the second distance falling within at least two distance ranges.

[0222] In an optional embodiment, the second row tree is obtained by replacing the first row tree.

[0223] In an optional embodiment, the determining module 1103 is further configured to replace the first row tree with a second row tree based on a first distance.

[0224] In an optional embodiment, the determining module 1103 is further configured to determine that the first virtual object is controlled by a second behavior tree, the second behavior tree corresponding to the first distance.

[0225] In an optional embodiment, the second row tree is obtained by adjusting the first row tree.

[0226] In an optional embodiment, the determining module 1103 is further configured to adjust the first update cycle of the first row tree to a second update cycle based on a first distance, wherein the first update cycle and the second update cycle are used to indicate the time interval between two adjacent decisions of the first row tree.

[0227] In an optional embodiment, the determining module 1103 is further configured to determine the first row tree that adopts the second update cycle as the second row tree.

[0228] In an optional embodiment, the determining module 1103 is further configured to determine that the first virtual object is controlled by the second behavior tree.

[0229] In an optional embodiment, the determining module 1103 is further configured to adjust the third update cycle of the service node of the first row tree to a fourth update cycle; wherein the fourth update cycle corresponds to the first distance, the service node is used to update the data required to run the first row tree, and the third update cycle and the fourth update cycle are used to indicate the time interval between two adjacent updates performed by the service node.

[0230] In an optional embodiment, the device further includes a processing module 1104.

[0231] In an optional embodiment, the processing module 1104 is configured to perform a conditional judgment on the m decorator nodes after the last update of the target data in the k-th update cycle of the second behavior tree during the process of controlling the first virtual object through the second behavior tree; wherein, the target data is the input data required to run the second behavior tree, and a sequential node of the second behavior tree is attached to m decorator nodes; the sequential node is configured to return a success value if all child nodes of the sequential node return a success value, and the decorator nodes are configured to determine at least one of executing or not executing the branch where the sequential node is located, determining the branch where the sequential node is located to be interrupted, or determining the low-priority branch of the branch where the sequential node is located to be interrupted, where m and k are positive integers.

[0232] In an optional embodiment, the target data includes a blackboard value that is updated n times in the k-th update cycle, where n is a positive integer. The processing module 1104 is further configured to mark the current update count of the blackboard value on the sequence node when the blackboard value is updated for the i-th time, where i is a positive integer not greater than n.

[0233] In an optional embodiment, the processing module 1104 is further configured to obtain m calculation results of m decorator nodes based on the blackboard value after the blackboard value is updated for the nth time, and perform a condition judgment based on the m calculation results.

[0234] In an optional embodiment, when the blackboard value is updated for the i-th time, m decorator nodes are traversed and notified.

[0235] In an optional embodiment, the processing module 1104 is further configured to mark the sequential node once each time one of the m decorator nodes is notified, such that the sequential node is marked a total of m times when the blackboard value is updated for the i-th time.

[0236] In an optional embodiment, the processing module 1104 is further configured to obtain m calculation results of m decorator nodes based on blackboard values ​​after the sequential node has been marked m*n times.

[0237] In an optional embodiment, both the first and second behavior trees are Unreal Engine UE4 behavior trees.

[0238] In summary, the aforementioned device determines the behavior tree for controlling the first virtual object based on the first distance between the first virtual object and the second virtual object. This ensures that the behavior tree for controlling the first virtual object is always in a dynamic adjustment state. That is, NPCs that are closer to the second virtual object and those that are farther away will be controlled through different behavior trees. NPCs that are closer to the second virtual object will use behavior trees that consume more resources, while NPCs that are farther away will use behavior trees that consume less resources. The total computer equipment resources consumed by a large number of NPCs will be maintained in a balanced state, and computer equipment resources will not be excessively consumed. At the same time, when an NPC is closer to the second virtual object, it will have a rich variety of performance forms.

[0239] Figure 12 This is a schematic diagram illustrating the structure of a computer device according to an exemplary embodiment. The computer device 1200 includes a Central Processing Unit (CPU) 1201, a system memory 1204 including Random Access Memory (RAM) 1202 and Read-Only Memory (ROM) 1203, and a system bus 1205 connecting the system memory 1204 and the CPU 1201. The computer device 1200 also includes a Basic Input / Output System (I / O System) 1206 to facilitate information transfer between various devices within the computer device, and a mass storage device 1207 for storing an operating system 1213, application programs 1214, and other program modules 1215.

[0240] The basic input / output system 1206 includes a display 1208 for displaying information and an input device 1209 for user input, such as a mouse or keyboard. Both the display 1208 and the input device 1209 are connected to the central processing unit 1201 via an input / output controller 1210 connected to the system bus 1205. The basic input / output system 1206 may also include the input / output controller 1210 for receiving and processing input from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1210 also provides output to a display screen, printer, or other types of output devices.

[0241] The mass storage device 1207 is connected to the central processing unit 1201 via a mass storage controller (not shown) connected to the system bus 1205. The mass storage device 1207 and its associated computer device-readable media provide non-volatile storage for the computer device 1200. That is, the mass storage device 1207 may include computer device-readable media (not shown), such as a hard disk or a compact disc read-only memory (CD-ROM) drive.

[0242] Without loss of generality, the computer device readable medium may include computer device storage media and communication media. Computer device storage media include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer device readable instructions, data structures, program modules, or other data. Computer device storage media include RAM, ROM, erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), CD-ROM, digital video disc (DVD) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that the computer device storage media are not limited to the above-mentioned types. The system memory 1204 and mass storage device 1207 described above can be collectively referred to as memory.

[0243] According to various embodiments of this disclosure, the computer device 1200 can also be connected to a remote computer device on a network, such as the Internet. That is, the computer device 1200 can be connected to the network 1211 via a network interface unit 1212 connected to the system bus 1205, or the network interface unit 1212 can be used to connect to other types of networks or remote computer device systems (not shown).

[0244] The memory also includes one or more programs, which are stored in the memory. The central processing unit 1201 executes the one or more programs to implement all or part of the steps of the above-mentioned virtual object control method.

[0245] This application also provides a computer device, which includes a processor and a memory. The memory stores at least one instruction, at least one program, code set, or instruction set. The at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the virtual object control method provided in the above method embodiments.

[0246] This application also provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the virtual object control method provided in the above method embodiments.

[0247] This application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the virtual object control method provided in the above-described method embodiments.

[0248] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0249] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0250] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for controlling a virtual object, characterized in that, The method is executed by the server, and the method includes: The first virtual object is controlled through the first line tree, and the first virtual object is a non-player character NPC. Obtain a first distance between the first virtual object and the second virtual object in the virtual environment, wherein the second virtual object is a virtual object controlled by the player; Based on the first distance, the first update cycle of the first behavior tree is adjusted to the second update cycle. The first update cycle and the second update cycle are used to indicate the time interval between determining the execution of the first task node and determining the execution of the second task node. The first task node and the second task node are adjacent task nodes. The length of the second update cycle is positively correlated with the first distance. The first row tree using the second update cycle is determined as the second row tree, and the first distance and the resources consumed by the second row tree during runtime are negatively correlated. It is determined that the first virtual object is controlled through the second behavior tree; Wherein, when the first virtual object and the second virtual object are at a first distance p in the virtual environment, the time interval for the first virtual object to perform an action is a first duration; when the first distance between the first virtual object and the second virtual object in the virtual environment is q, the time interval for the first virtual object to perform an action is a second duration; if p is greater than q, the first duration is greater than the second duration; or, if p is less than q, the first duration is less than the second duration; the action is implemented by controlling the first virtual object through task nodes in the second behavior tree.

2. The method according to claim 1, characterized in that, The step of determining whether to control the first virtual object through the second row tree based on the first distance includes: Based on the target distance range where the first distance falls within at least two distance ranges, it is determined that the first virtual object is controlled by a second behavior tree corresponding to the target distance range; The at least two distance ranges correspond one-to-one with at least two of the second row trees.

3. The method according to claim 2, characterized in that, The virtual environment also contains at least one third virtual object, which is a virtual object controlled by another player; the method further includes: Obtain a second distance between the first virtual object and the third virtual object in the virtual environment; The step of determining the control of the first virtual object through a second behavior tree corresponding to the target distance range based on the first distance falling within at least two distance ranges includes: If the first distance is less than the second distance, based on the first distance falling into the target distance range of the at least two distance ranges, it is determined that the first virtual object will be controlled by the second behavior tree corresponding to the target distance range.

4. The method according to claim 3, characterized in that, The method further includes: If the first distance is greater than the second distance, based on the second distance falling within the target distance range of the at least two distance ranges, it is determined that the first virtual object will be controlled by the second behavior tree corresponding to the target distance range.

5. The method according to any one of claims 1 to 4, characterized in that, The step of determining whether to control the first virtual object through the second row tree based on the first distance includes: Based on the first distance, the first behavior tree is replaced with the second behavior tree; It is determined that the first virtual object is controlled through the second behavior tree, which corresponds to the first distance.

6. The method according to any one of claims 1 to 4, characterized in that, The method further includes: Adjust the third update cycle of the service node of the first behavior tree to the fourth update cycle; The fourth update cycle corresponds to the first distance, the service node is used to update the data required to run the first behavior tree, and the third update cycle and the fourth update cycle are used to indicate the time interval between two adjacent updates performed by the service node.

7. The method according to any one of claims 1 to 4, characterized in that, The second row tree has m decorator nodes attached to a sequential node; the method further includes: During the process of controlling the first virtual object through the second behavior tree, after the target data is last updated in the kth update cycle of the second behavior tree, a condition judgment is made on the m decorator nodes. Wherein, the target data is the input data required to run the second behavior tree, the sequential node is used to return a success value if all child nodes of the sequential node return a success value, the decorator node is used to determine at least one of the following: execute or not execute the branch where the sequential node is located, determine to interrupt the branch where the sequential node is located, or determine the low-priority branch of the branch where the sequential node is located, where m and k are positive integers.

8. The method according to claim 7, characterized in that, The target data includes a blackboard value, the m decorator nodes focus on the same blackboard value, and the blackboard value is updated n times in the k-th update cycle, where n is a positive integer; After the last update of the target data in the k-th update cycle of the second row tree, a conditional judgment is performed on the m decorator nodes, including: When the blackboard value is updated for the i-th time, mark the current number of times the blackboard value has been updated on the sequence node, where i is a positive integer not greater than n; After the blackboard value is updated for the nth time, obtain the m calculation results of the m decorator nodes based on the blackboard value, and perform a condition judgment based on the m calculation results.

9. The method according to claim 8, characterized in that, When the blackboard value is updated for the i-th time, the m decorator nodes will be notified; marking the current update count of the blackboard value on the sequential nodes includes: When a decorator node is notified from the m decorator nodes, the sequential node is marked once, so that the sequential node is marked a total of m times when the blackboard value is updated for the i-th time; After the blackboard value is updated for the nth time, obtaining the m calculation results of the m decorator nodes based on the blackboard value includes: The sequential node is marked m After n iterations, obtain m calculation results for the m decorator nodes based on the blackboard value.

10. The method according to any one of claims 1 to 4, characterized in that, Both the first behavior tree and the second behavior tree are Unreal Engine UE4 behavior trees.

11. A method for displaying a virtual object, characterized in that, The method is executed by a terminal, and the method includes: Display a first virtual object and a second virtual object. The first virtual object is a non-player character (NPC), and the second virtual object is a player-controlled virtual object. The first virtual object is controlled by a first behavior tree. When the first virtual object and the second virtual object are at a first distance p in the virtual environment, the time interval for the first virtual object to perform an action is displayed as a first duration. When the first distance between the first virtual object and the second virtual object in the virtual environment is q, the time interval for the first virtual object to perform an action is displayed as the second duration. Where p is greater than q, the first duration is greater than the second duration; or p is less than q, the first duration is less than the second duration; the action is implemented by controlling the first virtual object through task nodes in the second behavior tree, the second behavior tree is obtained by the server adjusting the first update cycle of the first behavior tree to the second update cycle based on the first distance, the first update cycle and the second update cycle are used to indicate the time interval between determining to execute the first task node and determining to execute the second task node, the first task node and the second task node are adjacent task nodes, and the length of the second update cycle is positively correlated with the first distance.

12. A control device for a virtual object, characterized in that, The device includes: The control module is used to control a first virtual object through a first behavior tree, wherein the first virtual object is a non-player character NPC; The acquisition module is used to acquire a first distance between the first virtual object and the second virtual object in the virtual environment, wherein the second virtual object is a virtual object controlled by the player; The determination module is used to adjust the first update cycle of the first behavior tree to a second update cycle based on the first distance. The first update cycle and the second update cycle are used to indicate the time interval between determining the execution of the first task node and determining the execution of the second task node in the first behavior tree. The first task node and the second task node are adjacent task nodes. The length of the second update cycle is positively correlated with the first distance. The determining module is further configured to determine the first row tree using the second update cycle as the second row tree, wherein the first distance and the resources consumed by the second row tree during runtime are negatively correlated; The determining module is further configured to determine that the first virtual object is controlled by the second behavior tree; Wherein, when the first virtual object and the second virtual object are at a first distance p in the virtual environment, the time interval for the first virtual object to perform an action is a first duration; when the first distance between the first virtual object and the second virtual object in the virtual environment is q, the time interval for the first virtual object to perform an action is a second duration; if p is greater than q, the first duration is greater than the second duration; or, if p is less than q, the first duration is less than the second duration; the action is implemented by controlling the first virtual object through task nodes in the second behavior tree.

13. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the virtual object control method as described in any one of claims 1 to 10, or the virtual object display method as described in claim 11.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that is loaded and executed by a processor to implement the control method for a virtual object as described in any one of claims 1 to 10, or the display method for a virtual object as described in claim 11.

15. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform a method for controlling a virtual object as described in any one of claims 1 to 10, or a method for displaying a virtual object as described in claim 11.