Method, device, equipment, and program for controlling virtual objects

By dynamically adjusting behavior trees for NPCs based on distance to player-controlled objects, the method ensures balanced resource usage and enhanced NPC performance in open world games.

JP2024541214AActive Publication Date: 2024-11-08TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
JP2024523895
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2022-01-27
Filing Date
2022-11-07
Publication Date
2024-11-08
Estimated Expiration
2042-11-07

Smart Images

  • Figure 2024541214000001_ABST
    Figure 2024541214000001_ABST
Patent Text Reader

Abstract

A method, device, equipment, medium, and program product for controlling a virtual object belong to the technical field of computers. The method includes the steps of: controlling a first virtual object by a first behavior tree, the first virtual object being a non-player character (NPC) (220); acquiring a first distance between the first virtual object and a second virtual object in a virtual environment and a second distance between the first virtual object and a third virtual object in the virtual environment, the second virtual object being a virtual object controlled by a player, and the third virtual object being a virtual object controlled by another player (240); and, if the first distance is smaller than the second distance, determining to control the first virtual object by a second behavior tree based on the first distance, the first distance being negatively correlated with resources consumed during execution of the second behavior tree (260). The above technical means ensures that the NPC can achieve rich performance when the resources of the computer device are limited.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] This application claims priority to a Chinese patent application filed on January 27, 2022, bearing application number "202210101350.1" and titled "Virtual object control method, device, apparatus, medium and program product," the entire contents of which are incorporated herein by reference.

[0002] The embodiments of the present application belong to the field of computer technology, and in particular to a method, an apparatus, a device, a medium, and a program product for controlling a virtual object. [Background technology]

[0003] In open world games, there are a large number of AI (Artificial Intelligence) objects, and the AI ​​objects are NPCs (Non-player Characters) with anthropomorphic behavior.

[0004] In the related art, a large number of AI objects generally use the same behavior tree; however, if an AI object can achieve rich performance, the behavior tree used therefor is inevitably complex; and if a large number of AI objects use the same complex behavior tree, the performance of the server will inevitably be seriously challenged.

[0005] How to ensure that AI objects can achieve rich performance while avoiding excessive server resources being consumed by a large number of AI objects is a problem to be solved. Summary of the Invention [Problem to be solved by the invention]

[0006] The present application provides a method, device, equipment, medium and program product for controlling a virtual object, and ensures that NPC can achieve rich performance even when the resources of a computer device are limited. The technical means are as follows: [Means for solving the problem]

[0007] According to one aspect of the present application, there is provided a method for controlling a virtual object executed by a computing device, the method comprising: controlling a first virtual object by a first behavior tree, the first virtual object being a non-player character (NPC); obtaining a first distance between a first virtual object and a second virtual object in the virtual environment and a second distance between the first virtual object and a third virtual object in the virtual environment, where the second virtual object is a virtual object controlled by the player and the third virtual object is a virtual object controlled by another player; and if the first distance is smaller than the second distance, determining, based on the first distance, to control the first virtual object by a second behavior tree, where the second behavior tree is obtained by switching or adjusting the first behavior tree.

[0008] According to another aspect of the present application, there is provided a method for displaying a virtual object executed by a computing device, the method comprising: displaying a first virtual object, a second virtual object, and a third virtual object, wherein the first virtual object is a non-player character (NPC), the second virtual object is a virtual object controlled by the player, and the third virtual object is a virtual object controlled by another player; When a first distance between the first virtual object and the second virtual object in the virtual environment is smaller than a second distance between the first virtual object and a third virtual object in the virtual environment, displaying that the first virtual object performs a first number of actions when the first distance is p; displaying the first virtual object performing a second number of actions when the first distance is q, The first number is smaller than the second number when p is greater than q, or the first number is larger than the second number when p is less than q.

[0009] According to another aspect of the present application, there is provided a method for displaying a virtual object executed by a computing device, the method comprising: displaying a first virtual object, a second virtual object, and a third virtual object, wherein the first virtual object is a non-player character (NPC), the second virtual object is a virtual object controlled by the player, and the third virtual object is a virtual object controlled by another player; When a first distance between the first virtual object and the second virtual object in the virtual environment is smaller than a second distance between the first virtual object and a third virtual object in the virtual environment, when the first distance is p, displaying that a time interval during which the first virtual object performs an action is a first time length; a step of displaying that a time interval during which the first virtual object performs an action is a second time length when the first distance is q, The steps include: when p is greater than q, the first length of time is greater than the second length of time; or when p is less than q, the first length of time is less than the second length of time.

[0010] According to another aspect of the present application, there is provided a device for controlling a virtual object, the device comprising: a control module that controls a first virtual object by a first behavior tree, the first virtual object being a non-player character (NPC); an acquisition module for acquiring a first distance between a first virtual object and a second virtual object in a virtual environment and a second distance between the first virtual object and a third virtual object in the virtual environment, where the second virtual object is a virtual object controlled by a player and the third virtual object is a virtual object controlled by another player; and a decision module that decides to control a first virtual object by a second behavior tree based on the first distance if the first distance is smaller than the second distance, where the second behavior tree is obtained by switching or adjusting the first behavior tree.

[0011] According to one aspect of the present application, there is provided a computer device including a processor and a memory, wherein a computer program is stored in the memory, and the computer program, when loaded and executed by the processor, realizes a method for controlling a virtual object or a method for displaying the virtual object.

[0012] According to another aspect of the present application, there is provided a computer-readable storage medium having a computer program stored thereon, the computer program, when loaded and executed by a processor, realizing a method for controlling the virtual object or a method for displaying the virtual object.

[0013] According to another aspect of the present application, there is provided a computer program product including a computer program stored in a computer-readable storage medium, the computer program being read by a processor of a computing device from the computer-readable storage medium, and the processor executing the computer program to cause the computing device to perform the method for controlling a virtual object according to the aspect above, or to realize the method for displaying a virtual object according to the aspect above. Effect of the Invention

[0014] The beneficial effects of the technical means according to the embodiments of the present application include at least the following:

[0015] By determining the behavior tree for controlling the first virtual object based on the first distance between the first virtual object and the second virtual object, the behavior tree for controlling the first virtual object is always in a dynamic adjustment state, that is, the NPCs close to the second virtual object and far from the second virtual object are controlled by different behavior trees, the behavior tree for the closer NPC consumes more resources, and the behavior tree for the farther NPC consumes less resources, so that the total resources of the computer device consumed by a large number of NPCs are kept in a balanced state, and the resources of the computer device are not consumed excessively, thereby reducing the operating load of the computer device. At the same time, when the NPC is close to the second virtual object, it has rich performance.

[0016] In addition, when there are multiple player objects (i.e., virtual objects controlled by players), the target distance for determining the behavior tree for controlling the NPC is determined by comparing the distance between the NPC and the player objects, making the NPC's behavior tree more rational and improving the rationality of the NPC's performance. [Brief description of the drawings]

[0017] [Figure 1] FIG. 2 is a schematic diagram of a behavior tree according to an exemplary embodiment of the present application; [Diagram 2] 1 is a flowchart of a method for controlling a virtual object according to an exemplary embodiment of the present application. [Diagram 3] 1 is a schematic diagram of a Level of Distance (LOD) layering technique according to an exemplary embodiment of the present application; [Figure 4] FIG. 2 is a schematic diagram of an LOD layering technique according to another exemplary embodiment of the present application; [Diagram 5]FIG. 2 is a schematic diagram illustrating a performance of a first virtual object according to an exemplary embodiment of the present application. [Figure 6] FIG. 13 is a schematic diagram illustrating a performance of a first virtual object according to another exemplary embodiment of the present application. [Figure 7] FIG. 2 is a schematic diagram illustrating the performance of a first virtual object located at different LOD levels according to an exemplary embodiment of the present application; [Figure 8] FIG. 2 is a schematic diagram of m decorator nodes attached to one sequence node according to an exemplary embodiment of the present application; [Figure 9] 1 is a flow chart of a single conditional decision according to an exemplary embodiment of the present application; [Figure 10] 11 is a flowchart of a method for controlling a virtual object according to another exemplary embodiment of the present application. [Figure 11] FIG. 2 is a block diagram of a control device for a virtual object according to an exemplary embodiment of the present application. [Figure 12] FIG. 1 is a block diagram of a computing device according to an exemplary embodiment of the present application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0018] Exemplary embodiments are described in detail herein, examples of which are illustrated in the drawings. Where the following description refers to the drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise noted. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application, as detailed in the claims.

[0019] It should be understood that "several" referred to in this specification refers to one or more, and "multiple" refers to two or more. "And / or" is for describing the correlation of the correlated objects, and indicates that three relationships may exist, for example, "A and / or B" may indicate three situations: "A exists independently", "A and B exist simultaneously", and "B exists independently". The character " / " generally indicates that the related objects before and after are in an "or" relationship.

[0020] First, the related art of the present application will be described.

[0021] In the technology related to this application, a method for controlling the performance of an AI object includes controlling the AI ​​object through a finite state machine or a Behaviac behavior tree (a type of behavior tree).

[0022] Finite state machines are a means of implementing traditional AI technology, and define multiple states of an AI object and the switching conditions between states. When an AI object is in state A, it can switch from state A to state B when condition C for switching from state A to state B is met. The AI ​​object performs different tasks in different states, determines the switching state according to conditions, and combines a series of states and switching conditions into a complete AI object performance. Finite state machines have the advantage that both the principle and implementation are relatively simple, but the disadvantages are also obvious. They are generally applied when the states are limited and the transition relationship is simple. In open world games, the performance of an AI object is complex, and when performing state division, the number of states is large and the transition relationship between different states is complex, and the abstraction level of the AI ​​object controlled by the finite state machine is too low and not intuitive.

[0023] Behaviac behavior tree is an open source behavior tree implementation, which realizes control nodes such as selection nodes, sequence nodes, parallel nodes, and condition nodes to realize switching of behavior tree execution nodes. During the execution of the behavior tree, the performance of the AI ​​object is transformed by switching between different execution nodes. Behaviac behavior tree has the advantage that the service side only needs to realize simple execution and condition nodes, and thus the service logic and the behavior tree control logic can be decoupled and applied to the performance of complex AI objects. However, Behaviac behavior tree does not support blackboard function, is not intuitive during debugging, and the use of parallel nodes is inconvenient.

[0024] In the technology related to the present application, the synchronization methods of the performance of an AI object include server computation distribution, client computation + server transfer, and client computation + server synchronization.

[0025] In order to ensure the consistency and real-time performance of AI objects when forming a team of multiple people, a related solution is to execute the control of the AI ​​objects on a server, and the server is responsible for the calculation of logic related to the AI ​​objects, and distributes and presents the calculation results to each client (i.e., server calculation distribution). For game works in which the AI ​​objects are expected to exhibit rich behaviors, in order to reduce the load on the server that controls the AI ​​objects, a related solution is to transfer the calculation logic of the behavior tree that controls the AI ​​objects to a client, and the client performs logic calculations of the behavior tree nodes, and then reports the calculation results of the AI ​​objects to the server, and finally transfers them to other clients by the server (i.e., client calculation + server transfer). Another related solution is to have each client perform calculations independently, and use specific technical means to ensure the consistency of the calculation configuration (i.e., client calculation + server synchronization).

[0026] Server computation distribution has the advantages of accurate logic, low latency, and no problem of cheating by clients. However, it also has obvious disadvantages. In open world games, if a large amount of server AI computation is performed on the server, it will significantly affect performance and be detrimental to the player's experience. In this way, the performance of AI objects is single, such as simple patrol, courtship, and escape.

[0027] Client operation + server transfer has the advantage of greatly reducing the server's calculation load and improving server performance. However, it inevitably causes problems such as clients being prone to cheating, and if the network of the client in charge of the operation is poor, it will affect the performance of AI objects in other clients. This solution has certain limitations and is often applied to short one-round game products.

[0028] The client calculation + server synchronization solution has obvious drawbacks, such as the fact that inconsistencies between multiple client calculations are likely to occur, resulting in different performance of the same AI object on different clients, and at the same time, it also poses security risks. In addition, this solution is difficult to support the performance of richer AI objects, such as the combination with a time system or weather system.

[0029] In the embodiment of the present application, the behavior tree for controlling the AI ​​object is dynamically determined based on the distance between the AI ​​object and the virtual object controlled by the player, and the behavior tree used for the closer AI object consumes more resources and the behavior tree used for the farther AI object consumes less resources, thereby ensuring that the closer AI object has rich performance, while reducing the resource consumption of the computer device required to control a large number of AI objects, and further reducing the operating load of the computer device. The technical means according to the embodiment of the present application will be described in detail below.

[0030] The nouns related to the embodiments of the present application will be briefly described below.

[0031] A virtual environment is a virtual environment that is displayed (or provided) when a client is executed on a terminal (also called a terminal device). The virtual environment may be a simulation environment of the real world, a semi-simulated / semi-fictional environment, or a purely fictional environment. The virtual environment may be any one of a 2D virtual environment, a 2.5D virtual environment, and a 3D virtual environment, and the present application is not limited thereto. In the following embodiment, the virtual environment is described as a 3D virtual environment.

[0032] Preferably, the virtual environment can provide a battle environment for virtual objects. Exemplarily, in an open world game, a player controls a virtual object to wander freely in the virtual environment, and can freely select the time and manner of completing a game task, and during the wandering, the virtual object controlled by the player continuously interacts with an AI object in the virtual environment. Exemplarily, in a battle royale game, at least one virtual object plays a single round of battle in the virtual environment, and the virtual object avoids attacks made by enemy units and dangers in the virtual environment (e.g., poison gas, swamps, etc.) in order to survive in the virtual environment, and when the life value of the virtual object in the virtual environment becomes zero, the life of the virtual object in the virtual environment ends, and finally, the virtual object that smoothly passes through the route in the stage becomes the winner. Exemplarily, in a stage clear game, at least one virtual object plays a one-round battle in the virtual environment, and the virtual object obtains the clear authority of the current stage by killing a monster, and enters the next stage or ends the current battle.

[0033] A virtual object is a movable object in a virtual environment. The movable object may be a virtual person, a virtual animal, an animated character, etc., such as a person or an animal displayed in a 3D virtual environment. Preferably, the virtual object is a 3D solid model constructed based on animation skeleton technology. Each virtual object has its shape and volume in the 3D virtual environment and occupies a part of the space in the 3D virtual environment.

[0034] Unreal Engine (UE) 4 is an application development engine, and the applications may include games, etc., and Unreal Engine 4 may be abbreviated as UE4.

[0035] The UE4 behavior tree refers to a behavior tree provided in UE 4. The UE4 behavior tree includes a root node, a composite node, a task node, and a secondary node.

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

[0037] A composite node includes a sequence node, a selection node, and a parallel node. At least two child nodes are connected below the composite node.

[0038] A sequence node executes its lower nodes in sequence, and if all lower nodes return success, the sequence node itself returns success, and if any lower node returns failure, it instructs the execution of subsequent lower nodes to stop. If there is no task node below the sequence node, it returns failure to the sequence node.

[0039] The selection node executes its subordinate nodes sequentially, and if one of the subordinate nodes returns success, the selection node itself returns success, and if all of the subordinate nodes return failure, the sequence node returns failure. If there is no task node below the selection node, it returns failure to the selection node.

[0040] A parallel node connects one main task node to other parallel nodes, where the other parallel nodes include composite nodes or task nodes; when the main task node returns success, the parallel node returns success; when the main task node returns failure, the parallel node returns failure; and the result of the parallel node is independent of the return result of the other parallel nodes.

[0041] A task node controls an AI object to perform a certain action. A task node is usually located at the bottom of a UE4 behavior tree and is the end point of an AI object's action. Task nodes can be easily divided into task nodes that are completed instantly (abbreviated as instantaneous task nodes) and task nodes that continue for a certain period of time (abbreviated as continuation task nodes). If there is always an interruption in a continuation task node, the UE4 behavior tree will execute the interruption through a decorator node.

[0042] The secondary nodes include a decorator node and a service node.

[0043] Decorator nodes are attached to compositor nodes or task nodes and determine whether a subtree of a UE4 behavior tree should be executed and whether the subtree should be suspended.

[0044] If the parent node of the decorator node is a selection node, the decorator node has four option settings: None, Self, LowerPriority, and Both; if the parent node of the decorator node is a sequence node, the decorator node has two option settings: None and Self.

[0045] · None: A decorator node that selects None will only execute the conditional function. If the calculation result is true, the branch in which the decorator node is located will be executed. If the calculation result is false, the branch in which the decorator node is located will not be executed.

[0046] Self: A decorator node that selects Self can not only execute a conditional decision function, but also abort the branch in which the decorator node is located. If the result of the conditional decision changes from true to false during the execution of the branch in which the decorator node is located, the execution of the branch is aborted.

[0047] ·LowerPriority: A decorator node with LowerPriority selected can not only execute the conditional decision function, but also abort the branch with a lower priority. If the result of the conditional decision changes from false to true while the branch with a lower priority is being executed, the branch with the lower priority will be aborted and the branch in which the decorator node is located will be executed.

[0048] · Both: A decorator node that selects Both can not only execute a conditional decision function, but can also abort the branch in which it is located or a branch with a lower priority.

[0049] Service nodes are usually attached to a compositor or task node, and the service node will run at defined time intervals as long as its branch is executed. Service nodes are often used to check and update the blackboard. Service nodes replace the traditional Parallel node in other behavior tree systems. Service nodes do not have any return value and do not directly affect the UE4 behavior tree execution process.

[0050] The blackboard stores the data required to execute UE4 behavior trees, and the data required to execute UE4 behavior trees is called the blackboard's values. The blackboard works in conjunction with UE4 behavior trees to control the performance of AI objects.

[0051] Next, an implementation environment of the embodiment of the present application will be described.

[0052] In an embodiment of the present application, the behavior tree for controlling the performance of the first virtual object is executed on a server or a terminal. As shown in FIG. 1, a schematic diagram of a behavior tree according to an exemplary embodiment of the present application is shown. The composite node includes a selection node 102, a sequence node 105, and a sequence node 108, and the behavior tree further includes a root node 101.

[0053] Task node 106, task node 107, task node 110, and task node 111 are task nodes that control the performance of the first virtual object. Service node 103 is attached to selection node 102, and when the branch below it is executed, updates environmental information at every predetermined cycle and stores the updated environmental information in the blackboard, where the environmental information may include the light intensity of the current environment. Service node 109 is attached to sequence node 108, and updates the torch time at every predetermined cycle and stores the updated torch time in the blackboard. The torch time is the time from the time when the first virtual object (e.g., AI object, NPC, etc.) starts executing the task branch with the torch to the current time.

[0054] The decorator node 104 decides to execute the task branch to move to the shade of the tree (or not execute the task branch to move to the shade of the tree), or decides to abort the task branch to move to the shade of the tree (decides to abort the task branch with the torch).

[0055] Preferably, when the light intensity is greater than 200, the decorator node 104 determines to execute a task branch that moves to the shade of a tree. When the light intensity is less than or equal to 200, the decorator node 104 determines to execute a branch with a lower priority. Specifically, how the decorator node 104 controls the execution and interruption of a branch needs to be determined by combining attribute settings of the decorator node, and a description thereof will be omitted here.

[0056] In one embodiment, the behavior tree shown in Fig. 1 is executed entirely on a server. The server includes at least one of a single server, multiple servers, a cloud computing platform, and a virtualization center. Exemplarily, the server includes a processor and a memory, and the memory further includes a receiving module, a control module, and a sending module, where the receiving module receives a request sent from an application, e.g., a request from a player to control a second virtual character to move, the control module controls the rendering of the virtual environment, and the sending module sends a response to the application, e.g., sends an instruction to the application to control a second virtual character to move.

[0057] In one embodiment, the behavior tree shown in Figure 1 is executed entirely on a terminal, on which an application supporting a virtual environment is installed and executed, and preferably, the device types of the terminals of which the application supporting the virtual environment is installed may be the same or different, and include at least one of smart TVs, wearable devices, in-car terminals, smartphones, tablet computers, e-book readers, MP3 (Moving Picture Experts Group Audio Layer 3) players, MP4 players, laptop portable computers, and desktop computers.

[0058] In one embodiment, the behavior tree shown in FIG. 1 is partially stored and executed in a server and partially stored and executed in a terminal, but the embodiment of the present application is not limited thereto.

[0059] In one embodiment, the present application further determines the level of the first virtual object by LOD layering technology before executing a behavior tree that controls the performance of the first virtual object, and this layering process may be partly stored and executed on a server and partly stored and executed on a terminal, or this layering process may be entirely stored and executed on a server, or this layering process may be entirely stored and executed on a terminal, and the embodiments of the present application are not limited thereto.

[0060] In the following embodiment, an example will be described in which the behavior tree and LOD layering techniques are all executed on the server.

[0061] In order to ensure that the NPC can achieve rich performance even when the resources of a computer device are limited, FIG. 2 shows a flowchart of a method for controlling a virtual object according to an exemplary embodiment of the present application, which is illustrated by way of example in which the method is executed on a server, and may include steps 220, 240, and 260.

[0062] In step 220, a first virtual object is controlled by a first behavior tree.

[0063] The first virtual object refers to an NPC having anthropomorphic behavior, and in an open world game, the first virtual object is also called an AI object, and the AI ​​object acts in the virtual environment according to its own control logic. Preferably, the activity includes, for example, the AI ​​object patrolling its own territory, fighting with an AI object that invades its territory, resting, sleeping, and other self-interactions. Preferably, the activity further includes interacting with the player-controlled virtual object, for example, the AI ​​object continues to observe the player-controlled virtual object with curiosity, and the AI ​​object feels nervous about the player-controlled virtual object and hurries away.

[0064] The first behavior tree refers to a behavior tree that controls the performance of the first virtual object. Preferably, the type of the first behavior tree is an Unreal Engine UE4 behavior tree. In one embodiment, the UE4 behavior tree is obtained by peeling off a behavior tree module in UE4 and removing the engine-related parts.

[0065] In one embodiment, the first behavior tree may be a behavior tree that controls the first virtual object when there is no virtual object controlled by the player within a predetermined range of the first virtual object, and the first behavior tree may be a behavior tree that controls the first virtual object when all players cannot observe the first virtual object. For example, when all players cannot observe the first virtual object, the first behavior tree controls the first virtual object to remain stationary in place. Preferably, the first behavior tree may be called an initial behavior tree, for example, the first behavior tree may be a behavior tree in a default initial state immediately after the operation of the client starts, and in another example, the first behavior tree may be a behavior tree before the current time of the first virtual object, and the behavior tree at the current time of the first virtual object needs to be updated, i.e., the current time is a time when the behavior tree of the first virtual object needs to be updated, and the embodiment of the present application is not limited thereto.

[0066] In one embodiment, the first behavior tree may be a behavior tree that controls the first virtual object when the first virtual object is already within the player's observation range, for example, as shown in FIG. 1, when the first virtual object is already within the player's observation range, the decorator node 104 corresponding to the first behavior tree decides to execute the branch to move to the shade of the tree (or not to execute the branch to move to the shade of the tree) and decides whether to abort the branch to move to the shade of the tree (or a branch with a lower priority, i.e., the branch with the torch).

[0067] In one embodiment, the server manages the first virtual object by a spatial octree. An octree is a tree data structure, in which each internal node has exactly eight child nodes, and is most commonly used to divide a three-dimensional space by recursively subdividing it into eight quadrants. When managing the first virtual object by a spatial octree, each octree node records the space size and the information of the first virtual object contained therein.

[0068] At step 240, a first distance between the first virtual object and a second virtual object in the virtual environment and a second distance between the first virtual object and a third virtual object in the virtual environment are obtained.

[0069] The second virtual object is a virtual object controlled by the player, and the third virtual object is a virtual object controlled by another player, and the other player is a player other than the player. The virtual environment is the same as that described in the above embodiment, and therefore the description is omitted here.

[0070] In one embodiment, the server acquires a first distance between a first virtual object and a second virtual object in the virtual environment, and a second distance between the first virtual object and a third virtual object in the virtual environment at every predetermined time interval, for example, the server acquires the first distance and the second distance every 1 s.

[0071] In another embodiment, the server can determine the next distance acquisition time corresponding to the current time based on the current distance between the first virtual object and the virtual object controlled by the player. Illustratively, taking the first distance as an example, the server determines the time interval until the next acquisition of the first distance based on the acquired first distance. Preferably, if the first distance is large, the time interval until the next acquisition of the first distance is large, and if the first distance is small, the time interval until the next acquisition of the first distance is small.

[0072] In another embodiment, the surrounding area of ​​the virtual object controlled by the player may be divided into a plurality of distance ranges, and the server may determine the next distance acquisition time corresponding to the current time based on the current distance between the first virtual object and the virtual object controlled by the player and the distance range. Illustratively, taking the first distance as an example, when the first distance is within a target distance range among at least two distance ranges corresponding to the second virtual object, the server determines the time interval for next acquiring the first distance based on the time interval corresponding to the target distance range. In one embodiment, the server performs distance range division for the virtual object controlled by the player through the LOD layering technique, and further determines the time interval for acquiring the first distance or the second distance. Taking the second virtual object as an example, as shown in FIG. 3, a schematic diagram of the LOD layering technique according to an exemplary embodiment of the present application is shown.

[0073] The server divides the area with the second virtual object 305 as the center into three layers using the LOD layering technique, where LOD level 2 (301) is the third layer farthest from the second virtual object 305, LOD level 1 (302) is the second layer next to the second virtual object 305, and LOD level 0 (303) is the first layer closest to the second virtual object 305. FIG. 3 further shows a first virtual object 304, which is located at LOD level 0 (303). Preferably, the radius of the circle of the third layer is 8000 cm, the radius of the circle of the second layer is 4000 cm, and the radius of the circle of the first layer is 1000 cm. Preferably, no LOD level setting is performed for areas other than LOD level 2 (301).

[0074] 3, after determining the LOD level corresponding to the second virtual object 305, the server can determine a target level at which the first virtual object 304 is located based on the first distance between the first virtual object 304 and the second virtual object 305, and further determine a time interval for acquiring the first distance corresponding to the target level. For example, when the first virtual object 304 is located on the third layer (LOD level 2), the time interval for acquiring the first distance is 2s, when the first virtual object 304 is located on the second layer (LOD level 1), the time interval for acquiring the first distance is 1s, and when the first virtual object 304 is located on the first layer, the time interval for acquiring the first distance is 0.5s.

[0075] Preferably, the embodiments of the present application do not limit the number of player-controlled virtual objects, nor the number of player objects that need to obtain a distance between them and a first virtual object, i.e. there may be a third distance, a fourth distance, etc.

[0076] In step 260, if the first distance is less than the second distance, it is determined to control the first virtual object by the second behavior tree based on the first distance.

[0077] The first distance and the resources consumed when the second behavior tree is executed are negatively correlated. It should be understood that the first distance and the resources consumed when the second behavior tree is executed are negatively correlated, which means that the larger the first distance is, the less resources consumed by the second behavior tree, and the smaller the first distance is, the more resources consumed by the second behavior tree. The resources consumed by the behavior tree may be determined based on the complexity of the behavior tree or the update frequency of the behavior tree, where the higher the complexity of the behavior tree is, the more resources consumed by the behavior tree, and the more frequently the behavior tree is updated, the more resources consumed by the behavior tree.

[0078] Preferably, the second behavior tree may be obtained by changing the complexity of the first behavior tree based on the first distance, or may be obtained by changing the update frequency of the first behavior tree based on the first distance, or may be directly replaced with a second behavior tree different from the first behavior tree, and the embodiments of the present application are not limited in this regard.

[0079] When the first distance is smaller than the second distance, the first virtual object is closer to the second virtual object, and the first virtual object corresponding to the second virtual object can be preferentially guaranteed to ensure the player's sensory experience of the first virtual object, thereby improving the player's user experience and improving the rationality of the NPC's performance.

[0080] In one embodiment, the surrounding area of ​​the player-controlled virtual object is divided into a plurality of distance ranges, and the process of determining the second behavior tree can be performed as follows: The server determines to control the first virtual object by the second behavior tree corresponding to the target distance range based on the first distance falling within a target distance range among at least two distance ranges corresponding to the second virtual object.

[0081] Each distance range corresponds to one second behavior tree, i.e., at least two distance ranges correspond one-to-one with at least two second behavior trees. The closer to the distance range of the second virtual object, the higher the resources consumed when executing the corresponding second behavior tree, and the farther from the distance range of the second virtual object, the lower the resources consumed when executing the corresponding second behavior tree.

[0082] Exemplarily, the server determines a target level where the first virtual object is located by the LOD layering technique, and determines to control the first virtual object by the second behavior tree corresponding to the target level. As shown in FIG. 3 (a third virtual object is not shown), it may be determined that the first virtual object 304 is located at the first layer LOD level 0 (303) based on a first distance between the first virtual object 304 and the second virtual object 305, and the server determines to control the first virtual object by the second behavior tree corresponding to the first layer LOD level 0 (303). The resources consumed by the behavior tree corresponding to the first layer LOD level 0 (303), the behavior tree corresponding to the second layer LOD level 1 (302), and the behavior tree corresponding to the third layer LOD level 2 (301) are sorted in descending order.

[0083] In one embodiment, when the first distance is greater than the second distance, it is determined that the first virtual object is controlled by a second behavior tree corresponding to the target distance range based on the second distance falling within a target distance range of at least two distance ranges corresponding to a third virtual object.

[0084] As shown in FIG. 4 , at this time, the first distance between the first virtual object 304 and the second virtual object 305 is greater 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 third layer of the second virtual object 305, and at the same time, the first virtual object 304 is located in the second layer of the third virtual object 306, so it is determined to control the first virtual object 304 by the second behavior tree corresponding to the second layer.

[0085] The second behavior tree may be any behavior tree determined based on the first distance from a behavior tree set (including the first behavior tree) corresponding to the first virtual object, and the behavior tree set corresponding to the first virtual object may be preloaded, thereby directly realizing behavior tree switching and improving the conversion efficiency of the performance of the NPC. In one embodiment, the second behavior tree may be obtained by switching or adjusting the first behavior tree. Two specific cases are described in the following embodiments.

[0086] In one embodiment, the first behavior tree and the second behavior tree are both UE4 behavior trees.

[0087] Illustratively, as shown in FIG. 5, which is a schematic diagram showing the performance of a first virtual object according to an exemplary embodiment of the present application, the first virtual object 304 is located at LOD level 1 (second layer) corresponding to the second virtual object 305, and at this time, the first virtual object 304 continues to observe the second virtual object 305. As shown in FIG. 6, after the second virtual object 305 or the first virtual object 304 moves, the first virtual object 304 is located at LOD level 0 (first layer) corresponding to the second virtual object 305, and at this time, the first virtual object 304 tries to move away from the second virtual object 305. The performance of the first virtual object 304 controlled by the second behavior tree corresponding to LOD level 0 is richer than the performance of the first virtual object 304 controlled by the second behavior tree corresponding to LOD level 1.

[0088] In one embodiment, Fig. 7 is a schematic diagram illustrating the performance of a first virtual object located at different LOD levels according to an exemplary embodiment of the present application, in which the virtual object controlled by the player has LOD level 0, LOD level 1, and LOD level 2. In Fig. 7(A), the first virtual object 304 is currently located at LOD level 2, and the first virtual object 304 is performing self-interaction (patrolling, fighting with other NPCs, resting, sleeping, etc.), in Fig. 7(B), the first virtual object 304 is currently located at LOD level 1, and the first virtual object 304 is continuously observing the second virtual object (also called alert state), and in Fig. 7(C), the first virtual object 304 is currently located at LOD level 0, and the first virtual object 304 is running away from the second virtual object.

[0089] Preferably, when the first distance is equal to the second distance, it may be determined to control the first virtual object by the second behavior tree based on the first distance or the second distance.

[0090] Preferably, if the first virtual object is only within a predetermined range of the second virtual object, it may be determined directly to control the first virtual object by the second behavior tree based on a first distance between the first virtual object and the second object in the virtual environment.

[0091] Preferably, when the first virtual object does not come within a predetermined range of any second virtual object, or the player-controlled virtual object is unable to observe the first virtual object, the first virtual object may be controlled without using a behavior tree, or the first virtual object may simply be controlled to stand stationary.

[0092] From the above, by determining the behavior tree for controlling the first virtual object based on the first distance between the first virtual object and the second virtual object, the behavior tree for controlling the first virtual object is always in a dynamic adjustment state, that is, the NPCs close to the second virtual object and far from the second virtual object are controlled by different behavior trees, the behavior tree for the closer NPC consumes more resources, and the behavior tree for the farther NPC consumes less resources, so that the total resource of the computer device consumed by a large number of NPCs is kept in a balanced state, and the resource of the computer device is not excessively consumed, thereby reducing the operating load of the computer device. At the same time, when the NPC is close to the second virtual object, it has rich performance.

[0093] In addition, when there are multiple player objects (i.e., virtual objects controlled by players), the target distance for determining the behavior tree for controlling the NPC is determined by comparing the distance between the NPC and the player objects, making the NPC's behavior tree more rational and improving the rationality of the NPC's performance.

[0094] In addition, a hierarchical distance range is applied to the virtual object controlled by the player, and a behavior tree for controlling the NPC is determined based on the different distance ranges that the NPC falls into, thereby realizing hierarchical management of the NPC behavior tree, thereby realizing rich performance for the NPC at close range and simple performance for the NPC at long distance, ensuring that the closer NPC has rich performance and reducing the resource consumption of the computer device.In addition, by determining that the first distance falls within a predetermined target distance range, it is determined that the NPC is controlled by a second behavior tree corresponding to the target distance range, and a method for determining the second behavior tree according to the distance is further provided, thereby enriching the method for determining the second behavior tree.

[0095] In the preferred embodiment shown in FIG. 2, taking the first distance as an example smaller than the second distance, step 260 may be replaced by step S3 (including step S31 and step S32).

[0096] In step S31, the first behavior tree is switched to the second behavior tree based on the first distance.

[0097] In step S32, it is determined that the first virtual object is controlled by the second behavior tree.

[0098] At this time, the second behavior tree is obtained by switching the first behavior tree, and the second behavior tree corresponds to the first distance.

[0099] In one embodiment, when 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, the server switches from the first behavior tree to the second behavior tree, thereby increasing the complexity of the behavior tree controlling the first virtual object, where the complexity can be understood as the server performance consumed to execute the behavior tree, and when the behavior tree has many branches, or when the behavior tree has many decorator nodes, or when the behavior tree has many service nodes, the server performance consumed by the behavior tree is large.

[0100] Exemplarily, referring to the schematic diagram of LOD hierarchy shown in FIG. 3, the first behavior tree is a behavior tree corresponding to any one of LOD level 0 (303), LOD level 1 (302), and LOD level 2 (301). The second behavior tree is a behavior tree corresponding to a level other than the level corresponding to the first behavior tree. For example, the first behavior tree corresponds to LOD level 1 (302), and the second behavior tree corresponds to LOD level 0 (303). Preferably, when the LOD level of the first virtual object does not change, the behavior tree of the first virtual object does not change.

[0101] Preferably, before switching the first behavior tree to the second behavior tree, the server may further preload the second behavior tree, so that in the behavior tree switching process, it is only necessary to stop the first behavior tree and start the second behavior tree, thereby improving the efficiency of behavior tree switching.

[0102] In some possible implementations, the server switches from the first behavior tree to the second behavior tree, thereby increasing the update period of the behavior tree controlling the first virtual object, the update period indicating how often the output of the behavior tree is updated, the smaller the update period, the greater the update frequency.

[0103] As described above, by switching the first behavior tree to the second behavior tree, a method for switching the behavior tree that controls the first virtual object is provided, and the switching method of the behavior tree is enriched. Also, by preloading the behavior tree in the behavior library, it is only necessary to simply stop and start the behavior tree when switching, which avoids the overhead of creating the behavior tree and improves the efficiency of switching the behavior tree.

[0104] In the preferred embodiment shown in FIG. 2, taking the first distance as an example smaller than the second distance, step 260 may be replaced by step S4 (including step S41, step S42 and step S43).

[0105] In step S41, the first update period of the first behavior tree is adjusted to a second update period based on the first distance.

[0106] The first update period and the second update period indicate a time interval between two adjacent decisions output by the first behavior tree. Exemplarily, as shown in FIG. 1, the first update period and the second update period indicate a time interval of the first behavior tree between a time when it decides to execute task node 106 and a time when it decides to execute task node 107, and the update period can be expressed in the form of an update frequency, an update number, etc., calculated by a simple mathematical transformation.

[0107] 3, it should be understood that, in one embodiment, the first distance corresponds to the second update period, and the first distance range in which the first distance is located corresponds to the second update period, i.e., the target level in which the first virtual object is located corresponds to the second update period. For example, the update period of LOD level 0 is the shortest, which is 100 ms, the update period of LOD level 1 is the next shortest, which is 500 ms, and the update period of LOD level 3 is the longest, which is 1000 ms.

[0108] Based on the first distance, the server adjusts the first update period of the first behavior tree to a second update period. Preferably, if the LOD level of the first virtual object does not change, the server does not adjust the update period of the first behavior tree. If the first virtual object exceeds the LOD level distribution of the second virtual object, the server can stop the decision output of the first behavior tree.

[0109] In step S42, the first behavior tree that uses the second update period is determined as the second behavior tree.

[0110] The server determines the first behavior tree that uses the second update period as the second behavior tree.

[0111] In step S43, it is determined that the first virtual object is controlled by the second behavior tree.

[0112] The server determines to control the first virtual object by the second behavior tree, and at this time, the update period of the second behavior tree is the second update period.

[0113] In one embodiment, the method further includes step S5 after step S4.

[0114] In step S5, the third update period of the service node of the first behavior tree is adjusted to the fourth update period.

[0115] The fourth update period corresponds to the first distance, in which the service node updates the data required to execute the first behavior tree, and the third and fourth update periods indicate the time intervals between two adjacent updates performed by the service node.

[0116] In a primary or secondary behavior tree, service nodes are usually connected to composite or task nodes, and they are executed at defined time intervals as long as the branch is executed. Service nodes are often used to check and update the blackboard. In UE4 behavior trees, service nodes replace the traditional Parallel nodes in other behavior tree systems. Service nodes do not have any return value and do not directly affect the execution process.

[0117] From the above, by adjusting the update period of the first behavior tree, the behavior tree controlling the first virtual object is always in a dynamic adjustment state, the NPCs closer to the second virtual object and the NPCs farther from the second virtual object are controlled by behavior trees with different update periods, the update period of the behavior tree used for the closer NPC is short, and the update period of the behavior tree used for the farther NPC is long, so that the total resources of the computer device consumed by a large number of NPCs are kept in a balanced state, and the resources of the computer device are not consumed excessively, thereby reducing the operating load of the computer device. At the same time, when the NPC is close to the second virtual object, it has rich performance and real-time update of the performance of the NPC.

[0118] The above technical means further includes, when adjusting the update period of the first behavior tree, adaptively adjusting the update period of the service node of the first behavior tree, so that the adjusted update period of the service node adapts to the first distance and adapts to the adjusted update period of the first behavior tree, thereby further ensuring that the resources of the computer equipment are not excessively consumed, ensuring the normal operation of the first behavior tree, and making the NPC have normal performance.

[0119] In the preferred embodiment shown in FIG. 2, after step 260, the method further includes step S6.

[0120] In step S6, in the process of controlling the first virtual object by the second behavior tree, after the target data is last updated within the kth update period of the second behavior tree, a condition decision is made once for the m decorator nodes.

[0121] The target data is input data required to execute the second behavior tree, and m decorator nodes are attached to one sequence node of the second behavior tree, the sequence node returns a success value if all child nodes of the sequence node return success values, and the decorator node determines at least one of whether to execute the branch in which the sequence node is located, aborting the branch in which the sequence node is located, and aborting a low priority branch among the branches in which the sequence node is located, where m and k are positive integers.

[0122] Preferably, step S6 may be replaced by steps S61 and S62.

[0123] In step S61, in the process of controlling the first virtual object by the second behavior tree, if the value of the blackboard is updated for the i-th time, the current number of updates of the value of the blackboard is marked in the sequence node.

[0124] m decorator nodes are attached to the sequence node, and the m decorator nodes focus on the same blackboard value, and the blackboard value is updated n times within the kth update period of the second behavior tree. The blackboard value is data required to execute the first behavior tree, and for example, as shown in Figure 1, the 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.

[0125] The sequence node has m decorator nodes, and as shown in FIG. 8, m decorator nodes are attached to the sequence node 801, and the m decorator nodes focus on the same blackboard value. For example, the blackboard value is light intensity. Illustratively, the light intensity calculated by decorator node 1 is greater than 2000, the light intensity calculated by decorator node 2 is less than 4000, the ratio of the light intensity and the air humidity calculated by decorator node 3 is greater than 5, and the ratio of the light intensity and the environmental temperature calculated by decorator node 4 is greater than 10.

[0126] The value of the blackboard is updated n times within the update period of the second behavior tree, that is, in the time interval between when the first behavior tree outputs two adjacent decisions, the value of the blackboard is updated n times, for example, the previous decision is to control the first virtual object to obtain a shady position, and the next decision is to control the first virtual object to move to a shady position, and between the two decisions, the light intensity is updated n times by the service node.

[0127] In one embodiment, the sequence node returns a success value if all child nodes of the sequence node return success values, the decorator node decides to execute a branch of the second behavior tree and decides to abort the branch of the second behavior tree, the blackboard value is stored in a blackboard used in combination with the second behavior tree, and m, k, and n are all positive integers.

[0128] In step S62, after the value of the blackboard is updated for the nth time, m calculation results of m decorator nodes based on the value of the blackboard are obtained, and a condition decision is made once based on the m calculation results.

[0129] After the value of the blackboard is updated n times, the server obtains m calculation results of m decorator nodes according to the values ​​of the blackboard, and the server makes one conditional judgment based on the m calculation results, and the conditional judgment determines at least one of: whether to execute the branch in which the sequence node is located, aborting the branch in which the sequence node is located, and aborting a branch with a lower priority among the branches in which the sequence node is located.

[0130] In one embodiment, m decorator nodes are traversed to notify when the value of the blackboard is updated for the i-th time, and the above step S61 may be replaced with the step of "marking the sequence node m times when the value of the blackboard is updated for the i-th time by marking the sequence node once each time notifying one decorator node among the m decorator nodes", and step S62 may be replaced with the step of "obtaining m calculation results of the m decorator nodes using the value of the blackboard after the sequence node is marked m*n times."

[0131] Illustratively, the sequence node is marked each time the value in the blackboard is updated. Figure 9 illustrates a flowchart for performing a conditional decision once, according to an exemplary embodiment of the present application.

[0132] Step 901 starts.

[0133] The server initiates a flow that marks sequence nodes based on the blackboard value, which is updated once.

[0134] In step 902, the blackboard values ​​are updated.

[0135] The server updates the values ​​of the same blackboard that m decorator nodes focus on through the service node.

[0136] In step 903, the j-th decorator node is notified, and the initial value of j is 1.

[0137] The server notifies the j-th decorator node that the value on the blackboard is updated.

[0138] In step 904, the sequence node is marked.

[0139] The server marks the sequence node once for each decorator node it notifies.

[0140] In step 905, j is equal to m.

[0141] The server determines whether the notifications for the m decorator nodes are completed, and if so, executes step 907; otherwise, executes step 906.

[0142] In step 906, j=j+1.

[0143] The server updates the value of j to j+1 and executes the process again from step 903.

[0144] In step 907, the m calculation results of the m decorator nodes are obtained.

[0145] The server obtains m calculation results of m decorator nodes, and each decorator independently calculates the value of the blackboard, and the calculation method is to judge whether the value of the blackboard is larger than the preset value.

[0146] In step 908, a condition determination is made once.

[0147] The server performs one conditional judgment based on m decorator nodes. For example, the server obtains m calculation results of m decorator nodes, and if the first to m calculation results are all true, one conditional judgment is true, and if there is one false in the first to m calculation results, one conditional judgment is false.

[0148] The condition decision determines at least one of: whether to execute the branch in which the sequence node is located; aborting the branch in which the sequence node is located; and aborting a lower priority branch among the branches in which the sequence node is located.

[0149] In step 909, the process ends.

[0150] The server completes the flow of marking sequence nodes based on the blackboard values ​​that are updated once.

[0151] As described above, by optimizing the condition judgment process of the decorator node within one update period, a condition judgment is performed only once within one update period, which avoids unnecessary performance loss during execution of the behavior tree, reduces the operating load of the computer equipment, reduces the execution time of the behavior tree, and optimizes the performance of the computer equipment, compared to the condition judgment process in the related technology of the present application.

[0152] In the related technology of the present application, when one sequence node has multiple decorators and these decorators all focus on one blackboard value, a large performance overhead occurs when the blackboard value changes. As shown in FIG. 8, when m decorator nodes in a sequence node 801 all focus on a blackboard value of light ray intensity, when the light ray intensity changes, the m decorator nodes are traversed to notify one by one. Each time one decorator node is notified, the server calculates the results of m decorators and then performs one conditional judgment. In this way, when the blackboard value is modified once, m conditional judgments occur. When the blackboard value is modified n times during the current behavior tree update, m*n conditional judgments occur. The technical means according to the embodiment of the present application only requires one judgment, thereby reducing the execution overhead and execution time of the behavior tree.

[0153] In order to ensure that NPCs can achieve rich performance even when the resources of a computer device are limited, FIG. 10 shows a method for controlling a virtual object according to another exemplary embodiment of the present application, which is illustrated by taking an example in which the method is executed on a server, and the method includes steps 1001 to 1009.

[0154] Step 1001 starts.

[0155] The server starts to execute the virtual object control method according to the present embodiment.

[0156] In step 1002, all behavior trees that control a first virtual object are preloaded.

[0157] Before determining the behavior tree that controls the first virtual object, the server preloads all behavior trees that control the first virtual object. All behavior trees include a first behavior tree and a second behavior tree. In an embodiment of the present application, the second behavior tree is a behavior tree different from the first behavior tree, that is, the second behavior tree is obtained by switching the first behavior tree.

[0158] In step 1003, the first behavior tree is started.

[0159] The server activates a first behavior tree to control the first virtual object. The first behavior tree may be a behavior tree when there is no player-controlled virtual object within a predetermined range of the first virtual object, and may be called an initial behavior tree. The first behavior tree may be a behavior tree that controls the first virtual object when all players cannot observe the first virtual object. The first behavior tree may be a behavior tree that controls the first virtual object when the first virtual object is already within the player's observation range.

[0160] In step 1004, the first virtual object is controlled to move, or the second virtual object is controlled to move.

[0161] The server controls a first virtual object to move according to a first behavior tree, or the server controls a second virtual object to move according to a first behavior tree. The first virtual object is a non-player character (NPC). The second virtual object is a virtual object controlled by a player.

[0162] In step 1005, the distance between the first virtual object and the second virtual object is obtained, and the LOD level of the first virtual object is evaluated.

[0163] The server can periodically obtain the first distance between the first virtual object and the second virtual object, and evaluate the level at which the first virtual object is located by the LOD layering technique. The server can use the LOD layering technique to set the second virtual object as the center of a circle, and divide the spatial distance to the first virtual object into at least two levels according to the distance. For example, the distance range shown in the first layer is 0 to 50, the distance range shown in the second layer is 50 to 100, and the distance range shown in the third layer is 100 to 150, and if the first distance is 75, it is determined that the first virtual object is located in the second layer.

[0164] In step 1006, the LOD level is changed.

[0165] The server determines whether the level on which the first virtual object is located has changed, and if so, executes step 1007, otherwise executes step 1005 and continues to control the first virtual object by the first behavior tree.

[0166] In step 1007, the first behavior tree is stopped.

[0167] The server stops controlling the first virtual object by the first behavior tree.

[0168] In step 1008, the second behavior tree is launched.

[0169] The server launches a second behavior tree and controls the first virtual object through the second behavior tree.

[0170] In step 1009, the process ends.

[0171] The server ends the execution of the virtual object control method according to the present embodiment.

[0172] The following describes a method for displaying a virtual object according to an embodiment of the present application, taking as an example that the method is applied to a terminal (or a client running on the terminal), and the method includes the following three steps:

[0173] 1. Display a first virtual object, a second virtual object, and a third virtual object.

[0174] In one embodiment, the terminal displays a first virtual object, a second virtual object, and a third virtual object in a virtual environment, and the first virtual object is a non-player character (NPC). Preferably, the first virtual object refers to an NPC with anthropomorphic behavior, and in an open world game, the first virtual object is also called an AI object, and the AI ​​object acts in the virtual environment according to its own control logic.

[0175] The second virtual object is a virtual object controlled by the player, and the third virtual object is a virtual object controlled by another player. Taking the second virtual object as an example, the terminal receives an operation request for the second virtual object from the player and responds to the request. For example, the terminal receives a request to make the second virtual object run toward the first virtual object, and controls the second virtual object to move quickly toward the first virtual object.

[0176] 2. When a first distance between a first virtual object and a second virtual object in a virtual environment is smaller than a second distance between the first virtual object and a third virtual object in the virtual environment, display that the first virtual object performs a first number of actions when the first distance is p.

[0177] 3. When the first distance is q, display the first virtual object performing a second number of actions.

[0178] If p is greater than q then the first number is less than the second number, or alternatively if p is less than q then the first number is greater than the second number.

[0179] In one embodiment, when p is greater than q, the first number is smaller than the second number, or when p is smaller than q, the first number is greater than the second number. It should be understood that when the first distance is smaller than the second distance, as the distance between the first virtual object and the second virtual object changes from far to close, i.e., as the first distance gradually decreases, the number of actions performed by the first virtual object gradually increases, and as the distance between the first virtual object and the second virtual object changes from close to far, i.e., as the first distance gradually increases, the number of actions performed by the first virtual object gradually decreases.

[0180] For example, when the first distance is smaller than the second distance, if the first distance is large, the first virtual object performs one action, such as sleeping on the spot, and if the first distance is small, the first virtual object performs four actions, such as moving to the first virtual object, observing the second virtual object, spitting on the second virtual object, and running away from the second virtual object.

[0181] In one case, assuming that a first virtual object and a second virtual object exist in a virtual environment separated by a first distance and that neither the first virtual object nor the second virtual object moves within a subsequent time period, the number of actions that the first virtual object attempts to perform is inversely correlated with the first distance, i.e., the first distance is inversely correlated with the overhead of the behavior tree that controls the first virtual object.

[0182] When the first distance is greater than the second distance, the terminal displays that the first virtual object performs a first number of actions when the second distance is p, and displays that the first virtual object performs a second number of actions when the second distance is q.

[0183] Preferably, when the first virtual object is only within a predetermined range of the second virtual object, if the first distance is p, the terminal displays that the first virtual object performs a first number of actions, and when the first distance is q, the terminal displays that the first virtual object performs a second number of actions.

[0184] From the above, by displaying different numbers of actions performed by the first virtual object according to different distances in the virtual environment, the resources consumed by the closer NPC are more, the resources consumed by the farther NPC are less, and the total resources of the computer device consumed by a large number of NPCs are kept in a balanced state, and the resources of the computer device are not excessively consumed, so that the operating load of the computer device is reduced. At the same time, when the NPC is closer to the second virtual object, it has more actions.

[0185] In addition, when there are multiple player objects (i.e., virtual objects controlled by players), the number of actions that the NPC should display is determined by comparing the distance between the NPC and the player objects, making the performance of the NPC more reasonable.

[0186] The following describes another virtual object display method according to an embodiment of the present application, taking as an example that the method is applied to a terminal (or a client running on a terminal), and the method includes the following three steps:

[0187] 1. Displaying a first virtual object, a second virtual object, and a third virtual object, the first virtual object being a non-player character (NPC), the second virtual object being a virtual object controlled by a player, and the third virtual object being a virtual object controlled by another player.

[0188] In one embodiment, the terminal displays a first virtual object, a second virtual object, and a third virtual object in a virtual environment, and the first virtual object is a non-player character (NPC). Preferably, the first virtual object refers to an NPC with anthropomorphic behavior, and in an open world game, the first virtual object is also called an AI object, and the AI ​​object acts in the virtual environment according to its own control logic.

[0189] The second virtual object is a virtual object controlled by the player, and the third virtual object is a virtual object controlled by another player. Taking the second virtual object as an example, the terminal receives an operation request for the second virtual object from the player and responds to the request. For example, the terminal receives a request to make the second virtual object run toward the first virtual object, and controls the second virtual object to move quickly toward the first virtual object.

[0190] 2. When a first distance between a first virtual object and a second virtual object in the virtual environment is smaller than a second distance between the first virtual object and a third virtual object in the virtual environment, when the first distance is p, a time interval during which the first virtual object performs an action is displayed as a first time length.

[0191] 3. When the first distance is q, it is displayed that the time interval during which the first virtual object performs the action is a second time length.

[0192] If p is greater than q, the first length of time is greater than the second length of time, or if p is less than q, the first length of time is less than the second length of time.

[0193] In one embodiment, when p is greater than q, the first time length is greater than the second time length, or when p is less than q, the first time length is less than the second time length. It should be understood that when the first distance is smaller than the second distance, as the distance between the first virtual object and the second virtual object changes from far to close, i.e., as the first distance gradually decreases, the time interval during which the first virtual object performs the adjacent action gradually decreases, and as the distance between the first virtual object and the second virtual object changes from close to far, i.e., as the first distance gradually increases, the time interval during which the first virtual object performs the adjacent action gradually increases.

[0194] For example, when the first distance is smaller than the second distance, when the first distance is large, the time interval between two actions, such as fighting and sleeping, of the first virtual object is 5 s, and when the first distance is small, the time interval between four actions, such as moving toward the first virtual object, observing the second virtual object, spitting on the second virtual object, and running away from the second virtual object, of the first virtual object is 3 s.

[0195] In one case, assuming that a first virtual object and a second virtual object exist in a virtual environment separated by a first distance and that neither the first virtual object nor the second virtual object moves within a subsequent time period, the time interval between the operation that the first virtual object attempts to perform and the first distance are positively correlated, that is, the first distance and the overhead of the behavior tree that controls the first virtual object are inversely correlated.

[0196] When the first distance is greater than the second distance, the terminal displays that the time interval during which the first virtual object performs the action is a first time length when the second distance is p, and that the time interval during which the first virtual object performs the action is a second time length when the second distance is q.

[0197] Preferably, when the first virtual object is only within a predetermined range of the second virtual object, if the first distance is p, the terminal displays that the time interval during which the first virtual object performs the action is a first time length, and when the first distance is q, the terminal displays that the time interval during which the first virtual object performs the action is a second time length.

[0198] From the above, by displaying different intervals for the first virtual object to perform actions according to different distances in the virtual environment, the resources consumed by the closer NPC are more, the resources consumed by the farther NPC are less, and the total resources of the computer device consumed by the large number of NPCs are kept in a balanced state, and the resources of the computer device are not consumed excessively, thereby reducing the operating load of the computer device. At the same time, when the NPC is closer to the second virtual object, the performance has a higher fluency.

[0199] In addition, when there are multiple player objects (i.e., virtual objects controlled by players), the time interval for the NPC to perform an action can be determined by comparing the distance between the NPC and the player objects, making the performance of the NPC more reasonable.

[0200] FIG. 11 is a block diagram showing a configuration of a control device for a virtual object according to an exemplary embodiment of the present application, the device comprising: A control module 1101 that controls a first virtual object by a first behavior tree, the first virtual object being a non-player character (NPC); an acquisition module 1102 for acquiring a first distance between a first virtual object and a second virtual object in the virtual environment and a second distance between the first virtual object and a third virtual object in the virtual environment, where the second virtual object is a virtual object controlled by a player and the third virtual object is a virtual object controlled by another player; and a determination module 1103 that determines to control a first virtual object using a second behavior tree based on the first distance when the first distance is smaller than the second distance, where the first distance and resources consumed when executing the second behavior tree are negatively correlated.

[0201] In a preferred embodiment, the determination module 1103 further determines to control the first virtual object by a second behavior tree corresponding to a target distance range based on the first distance falling within a target distance range among at least two distance ranges corresponding to the second virtual object, and each of the distance ranges corresponds to one of the second behavior trees.

[0202] In a preferred embodiment, the determination module 1103 further determines, when the first distance is greater than the second distance, to control the first virtual object by a second behavior tree corresponding to the target distance range based on the second distance falling within a target distance range among the at least two distance ranges corresponding to the third virtual object.

[0203] In a preferred embodiment, the second behavior tree is obtained by switching the first behavior tree.

[0204] In a preferred embodiment, the decision module 1103 further switches the first behavior tree to a second behavior tree based on the first distance.

[0205] In a preferred embodiment, the determining module 1103 further determines to control the first virtual object by a second behavior tree, where the second behavior tree corresponds to the first distance.

[0206] In a preferred embodiment, the second behavior tree is obtained by adjusting the first behavior tree.

[0207] In a preferred embodiment, the decision module 1103 further adjusts the first update period of the first behavior tree to a second update period based on the first distance, where the first update period and the second update period indicate a time interval during which the first behavior tree outputs two adjacent decisions.

[0208] In a preferred embodiment, the determining module 1103 further determines the first behavior tree using the second update period as the second behavior tree.

[0209] In a preferred embodiment, the determining module 1103 further determines to control the first virtual object by a second behavior tree.

[0210] In a preferred embodiment, the determination module 1103 further adjusts the third update period of the service node of the first behavior tree to a fourth update period, the fourth update period corresponding to the first distance, the service node updates data required to execute the first behavior tree, and the third update period and the fourth update period indicate a time interval between two adjacent updates performed by the service node.

[0211] In a preferred embodiment, the apparatus further includes a processing module 1104 .

[0212] In a preferred embodiment, in the process of controlling the first virtual object by the second behavior tree, the processing module 1104 performs a conditional decision once for the m decorator nodes after last updating target data within the kth update period of the second behavior tree, the target data being input data required to execute the second behavior tree, m decorator nodes being attached to one sequence node of the second behavior tree, the sequence node returning a success value if all child nodes of the sequence node return success values, and the decorator node determining at least one of whether to execute the branch in which the sequence node is located, aborting the branch in which the sequence node is located, and aborting a low priority branch among the branches in which the sequence node is located, where m and k are positive integers.

[0213] In a preferred embodiment, the target data includes a blackboard value, and within the kth update period, the blackboard value is updated n times, where n is a positive integer, and the processing module 1104 further marks the sequence node with the current update number of the blackboard value when the blackboard value is updated for the ith time, where i is a positive integer less than or equal to n.

[0214] In a preferred embodiment, the processing module 1104 further obtains m calculation results of m decorator nodes according to the values ​​of the blackboard after the values ​​of the blackboard are updated for the nth time, and performs one conditional judgment based on the m calculation results.

[0215] In a preferred embodiment, when a value in the blackboard is updated for the i-th time, m decorator nodes are traversed for notification.

[0216] In a preferred embodiment, the processing module 1104 further marks the sequence node m times when updating the blackboard value for the i-th time by marking the sequence node once each time it notifies one of the m decorator nodes.

[0217] In a preferred embodiment, the processing module 1104 further obtains m calculation results of m decorator nodes according to the values ​​of the blackboard after the sequence node is marked m*n times.

[0218] In a preferred embodiment, the first behavior tree and the second behavior tree are both of type Unreal Engine UE4 behavior trees.

[0219] From the above, the above 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, so that the behavior tree for controlling the first virtual object is always in a dynamic adjustment state, that is, the NPCs close to the second virtual object and the NPCs far from the second virtual object are controlled by different behavior trees, and the behavior tree for the closer NPC consumes more resources, and the behavior tree for the farther NPC consumes less resources, so that the total resources of the computer device consumed by a large number of NPCs is kept in a balanced state, and the resources of the computer device are not consumed excessively, thereby reducing the operating load of the computer device. At the same time, when the NPC is close to the second virtual object, it has rich performance.

[0220] In addition, when there are multiple player objects (i.e., virtual objects controlled by players), the target distance for determining the behavior tree for controlling the NPC is determined by comparing the distance between the NPC and the player objects, making the NPC's behavior tree more rational and improving the rationality of the NPC's performance.

[0221] 12 shows a block diagram of a computer device according to an exemplary embodiment of the present application. The computer device 1200 includes a central processing unit (CPU) 1201, a system memory 1204 including a random access memory (RAM) 1202 and a read-only memory (ROM) 1203, and a system bus 1205 connecting the system memory 1204 to the central processing unit 1201. The computer device 1200 further includes a basic input / output system (I / O system) 1206 that helps transfer information between elements in the computer device, and a mass storage device 1207 for storing an operating system 1213, applications 1214, and other program modules 1215.

[0222] The basic input / output system 1206 includes a display 1208 for displaying information and input devices 1209, such as a mouse, keyboard, or the like, for a user to input information. The display 1208 and input devices 1209 are connected to the central processing unit 1201 via an input / output controller 1210, which is both connected to the system bus 1205. The basic input / output system 1206 may further include an input / output controller 1210 for receiving and processing input from a number of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1210 may further provide output to a display, printer, or other type of output device.

[0223] The mass storage device 1207 is connected to the central processing unit 1201 via a mass storage controller (not shown) that is connected to the system bus 1205. The mass storage device 1207 and its associated computer machine readable media provide non-volatile storage for the computer machine 1200. That is, the mass storage device 1207 may include a computer machine readable medium (not shown), such as a hard disk or a Compact Disc Read-Only Memory (CD-ROM) drive.

[0224] Without loss of generality, the computer machine readable medium may include computer machine storage media and communication media. Computer machine storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information such as computer machine readable instructions, data structures, program modules or other data. Computer machine storage media includes 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, tape cassette, magnetic tape, magnetic disk storage or other magnetic storage. Of course, those skilled in the art will recognize that the computer machine storage media is not limited to the above types. The system memory 1204 and mass storage device 1207 may be collectively referred to as memory.

[0225] According to various embodiments of the present disclosure, the computing device 1200 may further be connected to a remote computing device on a network, such as the Internet, and may be executed in such a manner that the computing device 1200 is connected to a network 1211 via a network interface unit 1212 connected to the system bus 1205, or may be connected to another type of network or remote computing device system (not shown) using the network interface unit 1212.

[0226] The memory further includes one or more programs, the one or more programs being stored in the memory, and the central processing unit 1201 executes the one or more programs to realize all or part of the steps of the above-mentioned virtual object control method or virtual object display method.

[0227] An embodiment of the present application further provides a computer device including a processor and a memory, the memory storing a computer program, which, when loaded and executed by the processor, realizes a method for controlling a virtual object or a method for displaying a virtual object according to the embodiments of the above methods.

[0228] The present application further provides a computer-readable storage medium having a computer program stored thereon, the computer program realizing a method for controlling a virtual object or a method for displaying a virtual object according to an embodiment of the above method, when loaded and executed by a processor.

[0229] The present application provides a computer program product including a computer program, the computer program being stored in a computer-readable storage medium, a processor of a computing device reading the computer program from the computer-readable storage medium, and the processor executing the computer program to cause the computing device to perform the method for controlling a virtual object or the method for displaying a virtual object according to the method embodiments.

[0230] In addition, information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, data to be stored, data to be displayed, etc.) and signals related to this application must be authorized by the user or fully authorized by each party, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions. For example, virtual objects, virtual environments, etc. related to this application are obtained when fully authorized.

[0231] The above numbers of the embodiments of the present application are for illustrative purposes only and do not indicate superiority or inferiority of the embodiments.

[0232] It is understood by those skilled in the art that all or part of the steps for realizing the above embodiments may be completed by hardware, or may be completed by instructing related hardware with a program, the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk, an optical disk, etc.

[0233] The above are only preferred embodiments of the present application, and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application should be included within the protection scope of the present application.

Claims

1. A method for controlling a virtual object executed by a computing device, comprising: controlling a first virtual object by a first behavior tree, the first virtual object being a non-player character (NPC); obtaining a first distance between the first virtual object and a second virtual object in a virtual environment and a second distance between the first virtual object and a third virtual object in the virtual environment, the second virtual object being a virtual object controlled by a player and the third virtual object being a virtual object controlled by another player; a step of determining, when the first distance is smaller than the second distance, to control the first virtual object using a second behavior tree based on the first distance, wherein the first distance and resources consumed when executing the second behavior tree are negatively correlated.

2. The step of determining to control the first virtual object by a second behavior tree based on the first distance includes: determining, based on the first distance falling within a target distance range of at least two distance ranges corresponding to the second virtual object, to control the first virtual object by a second behavior tree corresponding to the target distance range; The method of claim 1 , wherein each said distance range corresponds to one said second behavior tree.

3. The method comprises:

3. The method of claim 2, further comprising: determining, when the first distance is greater than the second distance, to control the first virtual object by a second behavior tree corresponding to the target distance range based on the second distance falling within a target distance range of at least two distance ranges corresponding to the third virtual object.

4. The step of determining to control the first virtual object by a second behavior tree based on the first distance includes: switching the first behavior tree to the second behavior tree based on the first distance; The method according to any one of claims 1 to 3, further comprising: determining to control the first virtual object by the second behavior tree, the second behavior tree corresponding to the first distance.

5. The step of determining to control the first virtual object by a second behavior tree based on the first distance includes: adjusting a first update period of the first behavior tree to a second update period based on the first distance, the first update period and the second update period indicating a time interval between two adjacent decisions output by the first behavior tree; determining the first behavior tree using the second update period as the second behavior tree; The method according to any one of claims 1 to 3, further comprising: determining to control the first virtual object by the second behavior tree.

6. The method comprises: adjusting a third update period of a service node of the first behavior tree to a fourth update period; 6. The method of claim 5, further comprising the steps of: the fourth update period corresponds to the first distance, the service node updates data necessary to execute the first behavior tree, and the third update period and the fourth update period indicate a time interval between two adjacent updates performed by the service node.

7. m decorator nodes are attached to one sequence node of the second behavior tree, and the method further comprises: In the process of controlling the first virtual object by the second behavior tree, after updating target data last within a k-th update period of the second behavior tree, a condition determination is performed once for the m decorator nodes, The method of any one of claims 1 to 3, further comprising the steps of: the goal data being input data required to execute the second behavior tree; the sequence node returning a success value if all child nodes of the sequence node return success values; and the decorator node determining at least one of: whether to execute the branch in which the sequence node is located, aborting the branch in which the sequence node is located, and aborting a low priority branch among the branches in which the sequence node is located, wherein m and k are positive integers.

8. the target data includes a blackboard value, the m decorator nodes focus on the same blackboard value, and within the kth update period, the blackboard value is updated n times, where n is a positive integer; the step of performing a conditional decision once for the m decorator nodes after the last update of the target data within the kth update period of the second behavior tree, if the blackboard value is updated for the i-th time, marking the sequence node with the current update count of the blackboard value, where i is a positive integer less than or equal to n; The method of claim 7, further comprising: after the value of the blackboard is updated for the nth time, obtaining m calculation results of the m decorator nodes using the value of the blackboard; and performing a conditional judgment once based on the m calculation results.

9. traversing the m decorator nodes to notify when the blackboard value is updated for the i-th time and marking the sequence node with the current update count of the blackboard value, marking the sequence node m times when updating the blackboard value for the i-th time by marking the sequence node once for each notification to one of the m decorator nodes; After the value of the blackboard is updated for the nth time, the step of obtaining m calculation results of the m decorator nodes according to the value of the blackboard includes:

9. The method of claim 8, further comprising obtaining m calculation results of the m decorator nodes with values ​​of the blackboard after the sequence node has been marked m*n times.

10. The method according to any one of claims 1 to 3, wherein the first behavior tree and the second behavior tree are both of type Unreal Engine UE4 behavior trees.

11. A method for displaying a virtual object executed by a computing device, comprising: a step of displaying a first virtual object, a second virtual object, and a third virtual object, wherein the first virtual object is a non-player character (NPC), the second virtual object is a virtual object controlled by a player, and the third virtual object is a virtual object controlled by another player; when a first distance between the first virtual object and the second virtual object in a virtual environment is smaller than a second distance between the first virtual object and the third virtual object in the virtual environment, when the first distance is p, the first virtual object performs a first number of actions; When the first distance is q, displaying that the first virtual object performs a second number of actions, when p is greater than q, the first number is smaller than the second number, or when p is smaller than q, the first number is larger than the second number.

12. A method for displaying a virtual object executed by a computing device, comprising: a step of displaying a first virtual object, a second virtual object, and a third virtual object, wherein the first virtual object is a non-player character (NPC), the second virtual object is a virtual object controlled by a player, and the third virtual object is a virtual object controlled by another player; when a first distance between the first virtual object and the second virtual object in a virtual environment is smaller than a second distance between the first virtual object and the third virtual object in the virtual environment, when the first distance is p, displaying that a time interval during which the first virtual object performs an action is a first time length; a step of displaying that a time interval during which the first virtual object performs an action is a second time length when the first distance is q, and if p is greater than q, the first time length is greater than the second time length, or if p is less than q, the first time length is less than the second time length.

13. a control module that controls a first virtual object by a first behavior tree, the first virtual object being a non-player character (NPC); an acquisition module that acquires a first distance between the first virtual object and a second virtual object in a virtual environment and a second distance between the first virtual object and a third virtual object in the virtual environment, the second virtual object being a virtual object controlled by a player and the third virtual object being a virtual object controlled by another player; A virtual object control device comprising: a determination module that determines to control the first virtual object using a second behavior tree based on the first distance when the first distance is smaller than the second distance, wherein the first distance and resources consumed when executing the second behavior tree are negatively correlated.

14. A computer device including a processor and a memory, wherein a computer program is stored in the memory, and the computer program, when loaded and executed by the processor, realizes the method according to any one of claims 1 to 3, the method for displaying a virtual object according to claim 11, or the method for displaying a virtual object according to claim 12.

15. A computer program causing a computer device to realize the method according to any one of claims 1 to 3, the method for displaying a virtual object according to claim 11, or the method for displaying a virtual object according to claim 12.

Citation Information

Patent Citations

  • Moving control method and device for virtual objects, terminal and storage medium

    CN110538455A

  • State control method and device

    JP2019518257A