Control method, device, instrument, and program of virtual object
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2025-09-22
- Publication Date
- 2026-07-07
AI Technical Summary
Existing technologies face challenges in ensuring rich performance of AI objects in open-world games without excessive server resource consumption.
A method and device for controlling virtual objects using behavior trees that dynamically adjust based on the distance between NPCs and player-controlled objects, with closer NPCs using more resource-intensive trees and farther NPCs using less resource-intensive trees.
This approach balances computer resource consumption and enhances NPC performance by dynamically adjusting behavior trees based on proximity to players, reducing operating load and improving user experience.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
[Technical Field]
[0001] This application claims priority to a Chinese patent application filed on January 27, 2022, bearing application number "202210101350.1" and entitled "Virtual object control method, device, equipment, medium and program product," the entire contents of which are incorporated herein by reference.
[0002] The present invention relates to a method, an apparatus, a device, a medium, and a program product for controlling a virtual object. [Background technology]
[0003] Open world games contain a large number of AI (Artificial Intelligence) objects, which are NPCs (Non-player Characters) with anthropomorphic behavior.
[0004] In related technologies, a large number of AI objects generally use the same behavior tree, but if an AI object can achieve rich performance, the behavior tree used therefor is necessarily complex. 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 resource consumption due to a large number of AI objects is a problem that needs 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 virtual objects, ensuring that NPCs can achieve rich performance even when computer resources 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, wherein 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; 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, wherein 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: 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; If 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; 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 less than the second number, or when p is less than q, the first number is greater than the second number.
[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: 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 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 a time interval during which the first virtual object performs an action is a first time length when the first distance is p; 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, 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 that acquires 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, wherein 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, if the first distance is smaller than the second distance, to control the first virtual object with a second behavior tree based on the first 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 when the computer program is loaded and executed by the processor, the computer program realizes a method for controlling the 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 the method for controlling the virtual object or the 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 computer device from the computer-readable storage medium and executed by the processor to cause the computer 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. [Effects 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 that controls the first virtual object based on the first distance between the first virtual object and the second virtual object, the behavior tree that controls the first virtual object is constantly in a dynamic adjustment state, i.e., NPCs closer to the second virtual object and farther away are controlled by different behavior trees, with the behavior tree used for closer NPCs consuming more resources and the behavior tree used for farther away NPCs consuming less resources, so that the total computer resource consumption by a large number of NPCs is kept in a balanced state and computer resource consumption is not excessive, thereby reducing the operating load of the computer device. At the same time, when an NPC is close to the second virtual object, performance is enhanced.
[0016] In addition, when there are multiple player objects (i.e., virtual objects controlled by players), the target distance for determining the behavior tree to control 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 explanation 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; [Figure 2] 1 is a flowchart of a method for controlling a virtual object according to an exemplary embodiment of the present application. [Figure 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. 1 is a schematic diagram of an LOD layering technique according to another exemplary embodiment of the present application; [Figure 5]FIG. 2 is a schematic diagram illustrating the performance of a first virtual object according to an exemplary embodiment of the present application. [Figure 6] FIG. 10 is a schematic diagram illustrating the performance of a first virtual object according to another exemplary embodiment of the present application; [Figure 7] FIG. 10 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 flowchart illustrating a single conditional decision according to an exemplary embodiment of the present application. [Figure 10] 10 is a flowchart of a method for controlling a virtual object according to another exemplary embodiment of the present application; [Figure 11] FIG. 1 is a block diagram of a virtual object control device according to an exemplary embodiment of the present application. [Figure 12] FIG. 1 is a block diagram of a computer device according to an exemplary embodiment of the present application. DETAILED DESCRIPTION OF THE INVENTION
[0018] Illustrative embodiments will now be described in detail, examples of which are illustrated in the drawings. When 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 illustrative examples do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as set forth in the claims.
[0019] It should be understood that "several" referred to herein refers to one or more, and "plurality" refers to two or more. "And / or" is used to describe the correlation of 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, the method of controlling the performance of AI objects involves controlling the AI objects with finite state machines or Behaviac behavior trees (one type of behavior tree).
[0022] Finite state machines are a traditional implementation of AI technology, defining multiple states for an AI object and the conditions for transitioning 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 based on certain conditions, and combines a set of states and switching conditions into a complete AI object's performance. Finite state machines have the advantage of being relatively simple in principle and implementation, but they also have obvious drawbacks. They are generally applied when there are limited states and simple transition relationships. In open-world games, where AI object performance is complex and state division is required, the number of states is large and the transition relationships between different states are complex, resulting in AI objects controlled by finite state machines having a low level of abstraction and being unintuitive.
[0023] Behaviac behavior trees are an open-source implementation of behavior trees. They implement control nodes such as selection nodes, sequence nodes, parallel nodes, and condition nodes to switch between behavior tree execution nodes. By switching between different execution nodes during behavior tree execution, AI object performance can be transformed. Behaviac behavior trees have the advantage that the service side only needs to implement simple execution and condition nodes. This allows for decoupling of service logic and behavior tree control logic, making them suitable for complex AI object performance. However, Behaviac behavior trees do not support blackboard functionality, making debugging unintuitive, and making it difficult to use parallel nodes.
[0024] In the technology related to this application, the synchronization methods for the performance of AI objects include server computation distribution, client computation + server transfer, and client computation + server synchronization.
[0025] To ensure consistent and real-time performance of AI objects in multi-player teams, a related solution is to execute AI object control on a server, which is responsible for computing the logic associated with the AI objects and then distributes and presents the results to each client (i.e., server computation distribution). For games where AI objects are expected to exhibit a wide range of behaviors, a related solution is to transfer the computation logic of the behavior tree controlling the AI objects to a client, which then performs the logic computation of the behavior tree nodes, reports the AI object computation results to the server, and finally transmits them to other clients (i.e., client computation + server transmission). Another related solution is for each client to independently perform computations and use specific technical means to ensure consistency in the computation configuration (i.e., client computation + server synchronization).
[0026] Server-based computation distribution has the advantages of accurate logic, low latency, and no issues with client cheating. However, it also has obvious drawbacks. In open-world games, if a large number of server AI calculations are performed on the server, it significantly impacts performance and is detrimental to the player experience. Therefore, this method limits the performance of AI objects to simple tasks such as patrolling, courting, and fleeing.
[0027] Client computing + server transmission has the advantage of significantly reducing the server's computing load and improving server performance, but it inevitably leaves clients vulnerable to cheating, and if the client's network is poor, it can affect the performance of AI objects on other clients. This solution also has certain limitations, making it suitable for short, one-round games.
[0028] The client operation + server synchronization solution is prone to inconsistencies between multiple client operations, which has obvious drawbacks, such as the performance of the same AI object being different on different clients, and also poses security risks. Furthermore, this solution is difficult to support the performance of more extensive AI objects, such as time systems and weather systems.
[0029] In an embodiment of the present application, a behavior tree for controlling an AI object is dynamically determined based on the distance between the AI object and the virtual object controlled by the player, with the behavior tree used for the closer AI object consuming more resources and the behavior tree used for the farther AI object consuming fewer resources, thereby ensuring that the closer AI object has good 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 explained 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 simulated environment of the real world, a semi-simulated or 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 examples, the virtual environment will be described as a 3D virtual environment.
[0032] Preferably, the virtual environment can provide a battle environment for virtual objects. For example, in an open-world game, a player controls a virtual object to roam freely in the virtual environment and can freely choose the time and manner to complete game tasks. During the roam, the virtual object controlled by the player continuously interacts with AI objects in the virtual environment. For example, in a battle royale game, at least one virtual object plays a single-round battle in the virtual environment. To survive in the virtual environment, the virtual object avoids attacks by enemy units and dangers in the virtual environment (e.g., poison gas, swamps, etc.). When the life value of the virtual object in the virtual environment reaches zero, the life of the virtual object in the virtual environment ends. The virtual object that successfully completes the route in the stage ultimately wins. For example, in a stage-clearing game, at least one virtual object plays a single-round battle in the virtual environment. By defeating a monster, the virtual object obtains permission to clear the current stage 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, or the like, 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 own shape and volume in the 3D virtual environment and occupies a portion of 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 (Composites 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 (Composites node) includes a sequence node (Sequence node), a selection node (Selector node), and a parallel node (SimpleParallel node). At least two child nodes are connected below the composite node.
[0038] A sequence node executes its subordinate nodes sequentially, and if all subordinate nodes return success (Succeeded), the sequence node itself returns success. If any subordinate node returns failure (Failed), it instructs the execution of subsequent subordinate nodes to stop. If there are no task nodes 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 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, and 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 a parallel node is independent of the return result of other parallel nodes.
[0041] A task node controls an AI object to perform a specific action. It 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 simply 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 a continuation task node must be interrupted, the UE4 behavior tree will execute the interruption using a decorator node.
[0042] The secondary nodes include a decorator node and a service node.
[0043] Decorator nodes are attached to compositing or task nodes and determine whether a subtree of a UE4 behavior tree is executed and whether the subtree is 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 only executes the conditional function. If the calculation result is true, the branch in which the decorator node is located is executed. If the calculation result is false, the branch in which the decorator node is located is not executed.
[0046] Self: A decorator node that selects Self not only executes the conditional function, but also aborts the branch in which the decorator node is located. If the result of the conditional test 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 where the decorator node is located will be executed.
[0048] · Both: A decorator node that selects Both not only performs a conditional decision function, but can also interrupt the branch in which the decorator node is located or a branch with a lower priority.
[0049] Service nodes are typically attached to compositing or task nodes, and run at defined time intervals as long as their branch is executed. Service nodes are often used to check or update the blackboard. Service nodes replace the traditional Parallel node found in other behavior tree systems. Service nodes do not have any return values and do not directly affect the execution process of UE4 behavior trees.
[0050] The Blackboard stores the data required to run a UE4 Behavior Tree, and the data required to run a UE4 Behavior Tree is called the Blackboard Value. The Blackboard works in conjunction with the UE4 Behavior Tree to control the performance of AI objects.
[0051] Next, an implementation environment for the embodiment of the present application will be described.
[0052] In an embodiment of the present application, the behavior tree that controls the performance of the first virtual object is executed on a server or a terminal. As shown in Figure 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 a branch below it is executed, updates environmental information at predetermined intervals and stores the updated environmental information on the blackboard. 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 predetermined intervals and stores the updated torch time on the blackboard. The torch time is the time from when the first virtual object (e.g., an AI object, NPC, etc.) starts executing the task branch holding 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 suspension of a branch must be determined by combining attribute settings of the decorator node, and a description thereof will be omitted here.
[0056] 1 is executed entirely on a server. The server may include at least one of a single server, multiple servers, a cloud computing platform, and a virtualization center. Illustratively, the server may include a processor and a memory, and the memory may further include a receiving module, a control module, and a sending module. The receiving module may receive a request from an application, e.g., a request from a player to control the movement of a second virtual character. The control module may control the rendering of the virtual environment. The sending module may send a response to the application, e.g., an instruction to control the movement of the second virtual character, to the application.
[0057] In one embodiment, the behavior tree shown in Figure 1 is executed entirely on a terminal, on which an application supporting the virtual environment is installed and executed. Preferably, the terminals on which the application supporting the virtual environment is installed may be the same or different device types, including at least one of a smart TV, a wearable device, an in-car terminal, a smartphone, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer 3) player, an MP4 player, a laptop portable computer, and a desktop computer.
[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, although 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 using LOD layering technology before executing the behavior tree that controls the performance of the first virtual object, and this layering process may be partly stored and executed on the server and partly stored and executed on the terminal, or the entire layering process may be stored and executed on the server, or the entire layering process may be stored and executed on the 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 computer device has limited resources, FIG. 2 shows a flowchart of a method for controlling a virtual object according to an exemplary embodiment of the present application, in which the method is performed on a server as an example, and the method 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 with anthropomorphic behavior. In an open-world game, the first virtual object is also called an AI object, which acts in the virtual environment according to its own control logic. Preferably, the activities include, for example, the AI object's self-interactions, such as patrolling its territory, fighting with AI objects that invade its territory, or resting or sleeping. Preferably, the activities further include interacting with the player-controlled virtual object, for example, the AI object continues to observe the player-controlled virtual object with curiosity, or the AI object senses tension in the player-controlled virtual object and quickly escapes.
[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 the 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 a player within a predetermined range of the first virtual object. The first behavior tree may also 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. Preferably, the first behavior tree may also be referred to as an initial behavior tree. For example, the first behavior tree may be a behavior tree in a default initial state immediately after the client starts operating. In another example, the first behavior tree may be a behavior tree of the first virtual object before the current time, where the behavior tree of the first virtual object at the current time needs to be updated. That is, the current time is a time when the behavior tree of the first virtual object needs to be updated. 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 determines to execute the branch that moves to the shade of the tree (or not execute the branch that moves to the shade of the tree), and determines whether to abort the branch that moves to the shade of the tree (or the branch with a lower priority, i.e., the branch with the torch).
[0067] In one embodiment, the server manages the first virtual objects using 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 objects using a spatial octree, each octree node records information about the space size and the first virtual objects contained therein.
[0068] In step 240, a first distance between the first virtual object and the second virtual object in the virtual environment and a second distance between the first virtual object and the third virtual object in the virtual environment are obtained.
[0069] The second virtual object is a virtual object controlled by the player, 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, so a description thereof will be 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 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. For example, 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, the longer the first distance is, the longer the time interval until the next acquisition of the first distance is, and the shorter the first distance is, the shorter the time interval until the next acquisition of the first distance is.
[0072] In another embodiment, the area surrounding the player-controlled virtual object may be divided into multiple 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 player-controlled virtual object and the distance range. For example, taking the first distance as an example, if the first distance is within a target distance range among at least two distance ranges corresponding to the second virtual object, the server may determine the next time interval for acquiring the first distance based on the time interval corresponding to the target distance range. In one embodiment, the server performs distance range division for the player-controlled virtual object using an 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, FIG. 3 shows a schematic diagram of the LOD layering technique according to an exemplary embodiment of the present application.
[0073] The server uses LOD layering technology to divide an area with the second virtual object 305 as the center into three layers. LOD level 2 (301) is the third layer that is farthest from the second virtual object 305, LOD level 1 (302) is the second layer that is next farthest from the second virtual object 305, and LOD level 0 (303) is the first layer that is 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 in the third layer is 8000 cm, the radius of the circle in the second layer is 4000 cm, and the radius of the circle in the first layer is 1000 cm. 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 2 seconds; when the first virtual object 304 is located on the second layer (LOD level 1), the time interval for acquiring the first distance is 1 second; and when the first virtual object 304 is located on the first layer, the time interval for acquiring the first distance is 0.5 seconds.
[0075] Preferably, the embodiments of the present application do not limit the number of virtual objects controlled by the player, nor limit 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 that the first virtual object is controlled 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. The negative correlation between the first distance and the resources consumed when the second behavior tree is executed should be understood to mean that the larger the first distance, the fewer resources consumed by the second behavior tree, and the smaller the first distance, 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, the more resources consumed by the behavior tree, and the more frequently the update frequency of the behavior tree, 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, which can prioritize the player's sensory experience of the first virtual object corresponding to the second virtual object, improving the player's user experience and 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 using the second behavior tree corresponding to the target distance range based on whether the first distance falls 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 to at least two second behavior trees. The closer a distance range of a second virtual object is to the distance range of the second virtual object, the higher the resources consumed when the corresponding second behavior tree is executed, and the farther a distance range of a second virtual object is from the distance range of the second virtual object, the lower the resources consumed when the corresponding second behavior tree is executed.
[0082] Illustratively, the server determines a target level at which a first virtual object is located using an LOD layering technique, and determines to control the first virtual object using a second behavior tree corresponding to the target level. As shown in FIG. 3 (a third virtual object is not shown), based on a first distance between a first virtual object 304 and a second virtual object 305, it may be determined that the first virtual object 304 is located at the first layer LOD level 0 (303), and the server determines to control the first virtual object using 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 among 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 that the first virtual object 304 is controlled 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 NPC's performance. 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] 5 is a schematic diagram illustrating the performance of a first virtual object according to an exemplary embodiment of the present application, in which 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, Figure 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 player-controlled virtual object has LOD level 0, LOD level 1, and LOD level 2. In Figure 7(A), the first virtual object 304 is currently located at LOD level 2, and the first virtual object 304 is engaged in self-interaction (such as patrolling, fighting with other NPCs, or resting / sleeping). In Figure 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 referred to as an alert state). In Figure 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 can be determined to control the first virtual object by the second behavior tree based on the first distance or the second distance.
[0090] Preferably, when the first virtual object is only within a predetermined range of the second virtual object, it can be directly determined 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, if the first virtual object does not come within a predetermined range of any second virtual object, or if the player-controlled virtual object cannot observe the first virtual object, the first virtual object may be controlled without using a behavior tree, or may simply be controlled to stand still.
[0092] As a result, by determining the behavior tree that controls the first virtual object based on the first distance between the first virtual object and the second virtual object, the behavior tree that controls the first virtual object is constantly in a dynamic adjustment state, i.e., NPCs closer to the second virtual object and those farther away are controlled by different behavior trees, with the behavior tree used for closer NPCs consuming more resources and the behavior tree used for farther away NPCs consuming less resources, so that the total computer resource consumption by a large number of NPCs is kept balanced and computer resource consumption is not excessive, thereby reducing the operating load of the computer, and at the same time, providing excellent performance when NPCs are close to the second virtual object.
[0093] In addition, when there are multiple player objects (i.e., virtual objects controlled by players), the target distance for determining the behavior tree to control 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, distance ranges are layered for virtual objects controlled by the player, and the behavior tree for controlling the NPC is determined based on the different distance ranges the NPC falls within, thereby realizing hierarchical management of NPC behavior trees, thereby achieving rich performance for NPCs at close ranges and simple performance at long distances, ensuring that closer NPCs have rich performance and reducing computer resource consumption.In addition, by determining that the first distance falls within a predetermined target distance range, it is determined that the NPC will be controlled by a second behavior tree corresponding to the target distance range, further providing a method for determining the second behavior tree based on distance, thereby enriching the method for determining the second behavior tree.
[0095] In the preferred embodiment shown in FIG. 2, taking the first distance smaller than the second distance as an example, 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 to be 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 larger 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. 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] Illustratively, with reference to the schematic diagram of LOD layering 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, and the smaller the update period, the greater the update frequency.
[0103] As described above, by switching from a first behavior tree to a second behavior tree, a method for switching the behavior tree that controls the first virtual object is provided, and the method for switching behavior trees is enriched. In addition, 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 a behavior tree and improves the efficiency of switching behavior trees.
[0104] In the preferred embodiment shown in FIG. 2, for example, if the first distance is 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 the time interval between two adjacent decisions output by the first behavior tree. For example, as shown in FIG. 1, the first update period and the second update period indicate the time interval between the time when the first behavior tree decides to execute task node 106 and the time when the first behavior tree decides to execute task node 107. The update period can also be expressed in terms of an update frequency, number of updates, or the like, calculated by simple mathematical transformation.
[0107] 3 , it should be understood that a first distance corresponds to a second update period, a first distance range in which the first distance is located corresponds to the second update period, i.e., a target level in which a first virtual object is located corresponds to the second update period. For example, the update period of LOD level 0 is the shortest, being 100 ms, the update period of LOD level 1 is the next shortest, being 500 ms, and the update period of LOD level 3 is the longest, being 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 determining and outputting the first behavior tree.
[0109] In step S42, the first behavior tree that uses the second update cycle 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 to be 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, and the service node updates the data necessary to execute the first behavior tree, and the third and fourth update periods indicate the time interval between two adjacent updates performed by the service node.
[0116] In a primary or secondary behavior tree, service nodes are usually connected to composite nodes or task nodes, and they execute at defined time intervals as long as the branch is executed. Service nodes are often used to check or update the blackboard. In UE4 behavior trees, service nodes replace the traditional parallel nodes found in other behavior tree systems. Service nodes do not have any return values and do not directly affect the execution process.
[0117] As a result, by adjusting the update period of the first behavior tree, the behavior tree controlling the first virtual object is constantly in a state of dynamic adjustment, and NPCs closer to the second virtual object and those farther away are controlled by behavior trees with different update periods, with the behavior tree used for the closer NPC having a shorter update period and the behavior tree used for the farther away NPC having a longer update period, so that the total computer resources consumed by a large number of NPCs are kept balanced and computer resources are not consumed excessively, thereby reducing the operating load of the computer. At the same time, when an NPC is close to the second virtual object, good performance is achieved and the NPC performance is updated in real time.
[0118] The above technical solution 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 ensuring normal performance of the NPC.
[0119] In the preferred embodiment shown in FIG. 2, after step 260, step S6 is further included.
[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 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, and 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, abort the branch in which the sequence node is located, or abort a branch with a lower priority 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 necessary to execute the first behavior tree, and for example, as shown in Figure 1, decorator node 104 focuses on the blackboard value of ray intensity, and at this time, only one decorator node 104 is attached to sequence node 105.
[0125] The sequence node has m decorator nodes. As shown in FIG. 8, m decorator nodes are attached to 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 to the air humidity calculated by decorator node 3 is greater than 5, and the ratio of the light intensity to 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, the value of the blackboard is updated n times in the time interval between two adjacent decisions output by the first behavior tree, for example, the previous decision is to control the first virtual object to obtain a position in the shade of a tree, and the next decision is to control the first virtual object to move to the position in the shade of a tree, 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 conditional 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 value of the blackboard, and the server makes one conditional decision based on the m calculation results, and the conditional 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 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 blackboard value 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 blackboard value 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 blackboard value after the sequence node has been 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 are interested in 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] For each decorator node notified, the server marks the sequence node once.
[0140] In step 905, j is equal to m.
[0141] The server determines whether the notification to the m decorator nodes is complete, 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 determine whether the value of the blackboard is larger or smaller than the preset value.
[0146] In step 908, a conditional decision 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 all of the first through m calculation results are true, the one conditional judgment is true, and if there is one false among the first through m calculation results, the 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, abort the branch in which the sequence node is located, and abort a branch with a lower priority 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 the sequence node based on the value of the blackboard, which is updated once.
[0151] As described above, by optimizing the condition judgment process of the decorator node within one update period, the condition judgment is performed only once within one update period, which avoids unnecessary performance loss during the 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 this application.
[0152] In the related technology of the present application, when a sequence node has multiple decorators and these decorators all focus on a single blackboard value, a significant 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, i.e., ray intensity, and when the ray intensity changes, the m decorator nodes are traversed to notify each one. Each time a decorator node is notified, the server calculates the results of the m decorators and then performs one conditional decision. In this way, when the blackboard value is modified once, m conditional decisions are made. When the blackboard value is modified n times during the current behavior tree update, m*n conditional decisions are made. The technical means according to the embodiments of the present application only require one decision, 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 as being executed on a server, and includes steps 1001 to 1009.
[0154] Step 1001 starts.
[0155] The server starts to execute the virtual object control method according to this embodiment.
[0156] In step 1002, all behavior trees that control the 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 the embodiment of the present application, the second behavior tree is a behavior tree different from the first behavior tree, i.e., 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 virtual object controlled by a player within a predetermined range of the first virtual object, and may be referred to as 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 a 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 periodically acquires a first distance between the first virtual object and the second virtual object and evaluates the level at which the first virtual object is located using LOD layering technology. The server can use LOD layering technology 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. If the first distance is 75, the server determines 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; if not, 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 the control of the first virtual object by the first behavior tree.
[0168] In step 1008, the second behavior tree is launched.
[0169] The server activates 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. In an open-world game, the first virtual object is also called an AI object, and the AI object operates 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 a player's operation request for the second virtual object 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 to perform a second number of actions.
[0178] If p is greater than q, the first number is less than the second number, or alternatively, if p is less than q, 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 larger 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 quickly 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 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 if 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 in the virtual environment according to different distances, the resources consumed by the closer NPCs are larger and the resources consumed by the farther NPCs are smaller, so that the total resources consumed by the larger 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 NPCs are closer to the second virtual object, they have more actions.
[0185] Also, 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 NPC's performance 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 the terminal), and the method includes the following three steps:
[0187] 1. Display a first virtual object, a second virtual object, and a third virtual object, where 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.
[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. In an open-world game, the first virtual object is also called an AI object, and the AI object operates 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 a player's operation request for the second virtual object 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, it is displayed that the time interval during which the first virtual object performs an action is 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 duration is greater than the second duration, or if p is less than q, the first duration is less than the second duration.
[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 between the first virtual object performing 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 between the first virtual object performing the adjacent action gradually increases.
[0194] For example, when the first distance is smaller than the second distance, if the first distance is large, the time interval between two actions, such as fighting and sleeping, of the first virtual object is 5 seconds; if the first distance is small, the time interval between four actions, such as moving to the first virtual object, observing the second virtual object, spitting on the second virtual object, and quickly running away from the second virtual object, of the first virtual object is 3 seconds.
[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 actions that the first virtual object attempts to perform and the first distance are positively correlated, i.e., 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 if 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] Therefore, by displaying different intervals for the first virtual object to perform actions in the virtual environment based on different distances, the resources consumed by the closer NPCs are larger and the resources consumed by the farther NPCs are smaller, so that the total resources consumed by the larger number of NPCs are balanced 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 NPCs are closer to the second virtual object, the performance is more fluent.
[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 NPC's performance more reasonable.
[0200] FIG. 11 shows a block diagram of a virtual object control device according to an exemplary embodiment of the present application, the device including: 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 that 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, 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, if 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.
[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 using a second behavior tree corresponding to the target distance range based on the second distance falling within a target distance range among 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 the time interval between two adjacent decisions output by the first behavior tree.
[0208] In a preferred embodiment, the determination module 1103 further determines the first behavior tree using the second update period as the second behavior tree.
[0209] In a preferred embodiment, the determination 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 the data required to execute the first behavior tree, and the third update period and the fourth update period indicate the 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 using the second behavior tree, the processing module 1104 performs a conditional decision on the m decorator nodes once after last updating target data within the kth update period of the second behavior tree, where the target data is input data required to execute the second behavior tree, where m decorator nodes are attached to one sequence node of the second behavior tree, where the sequence node returns a success value if all child nodes of the sequence node return success values, and where the decorator node determines at least one of whether to execute the branch in which the sequence node is located, abort the branch in which the sequence node is located, or abort a branch with a lower priority 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 the blackboard value is updated n times within the kth update period, where n is a positive integer, and the processing module 1104 further marks the current update number of the blackboard value in the sequence node when the blackboard value is updated i-th, 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 to notify it.
[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 for each notification to 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 in the blackboard after the sequence node has been marked m*n times.
[0218] In a preferred embodiment, the first behavior tree and the second behavior tree are both Unreal Engine UE4 behavior trees.
[0219] The 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 constantly in a dynamic adjustment state. That is, NPCs closer to the second virtual object and those farther away are controlled by different behavior trees. The behavior tree for closer NPCs consumes more resources than the behavior tree for farther away NPCs. This keeps the total computer resource consumption for a large number of NPCs in a balanced state, preventing excessive computer resource consumption and reducing the operating load of the computer. At the same time, when an NPC is closer to the second virtual object, the device provides robust 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 to control 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 computing device according to an exemplary embodiment of the present application. The computing 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 computing device 1200 further includes a basic input / output system (I / O system) 1206 that helps transfer information between elements within the computing 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 or keyboard, for inputting information by a user. The display 1208 and input devices 1209 are connected to the central processing unit 1201 via an input / output controller 1210, which is 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-readable media provide non-volatile storage for the computer device 1200. That is, the mass storage device 1207 may include a computer-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-readable media may include computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media include RAM, ROM, Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), CD-ROM, Digital Video Disc (DVD) or other optical storage, tape cassette, magnetic tape, magnetic disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that the computer 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 also be connected to a remote computing device over a network, such as the Internet, and may be running on the network 1211. That is, the computing device 1200 may be connected to the 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, which are 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 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, wherein a computer program is stored in the memory, and when the computer program is loaded and executed by the processor, the computer program realizes a method for controlling a virtual object or a method for displaying a virtual object according to the embodiment of each of the above methods.
[0228] The present application further provides a computer-readable storage medium having a computer program stored thereon, which, when loaded and executed by a processor, realizes a method for controlling a virtual object or a method for displaying a virtual object according to the above-described method embodiments.
[0229] The present application provides 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 computer device from the computer-readable storage medium, and the processor executing the computer program to cause the computer device to perform the method for controlling a virtual object or the method for displaying a virtual object according to the above method embodiments.
[0230] It should be noted that the 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 all 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 can only be obtained with full authorization.
[0231] The above numbers of the examples of the present application are for illustrative purposes only and do not indicate superiority or inferiority of the examples.
[0232] It should be 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 relevant hardware through a program, and 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, and 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.
[0234] The following additional note is added: (Supplementary Note 1) A method for controlling a virtual object executed by a computer 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, wherein 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 when the first distance is smaller than the second distance, determining 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. (Supplementary Note 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 among at least two distance ranges corresponding to the second virtual object, to control the first virtual object using a second behavior tree corresponding to the target distance range; 2. The method of claim 1, wherein each distance range corresponds to one of the second behavior trees. (Supplementary Note 3) The method comprises: 3. The method of claim 2, further comprising: when the first distance is greater than the second distance, determining, based on the second distance being within a target distance range of at least two distance ranges corresponding to the third virtual object, to control the first virtual object using a second behavior tree corresponding to the target distance range. (Supplementary Note 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 appendices 1 to 3, further comprising: a step of determining to control the first virtual object using the second behavior tree, the second behavior tree corresponding to the first distance. (Supplementary Note 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; and determining to control the first virtual object by the second behavior tree. (Supplementary Note 6) The method comprises: adjusting a third update period of a service node of the first behavior tree to a fourth update period; The method described in Appendix 5 further includes a step in which 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 the time interval between two adjacent updates performed by the service node. (Supplementary Note 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 last updating target data within a k-th update period of the second behavior tree, a step of performing a conditional decision once for the m decorator nodes, The method of any one of Supplementary Notes 1 to 3, further comprising the steps of: the target 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 branch with a lower priority among the branches in which the sequence node is located, wherein m and k are positive integers. (Supplementary Note 8) The target data includes a blackboard value, the m decorator nodes focus on the same blackboard value, and the blackboard value is updated n times within the kth update period, where n is a positive integer; The step of performing a conditional decision once for the m decorator nodes after the target data is last updated within the k-th update period of the second behavior tree includes: 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 described in Appendix 7 includes a step of obtaining m calculation results of the m decorator nodes using the values of the blackboard after the values of the blackboard are updated for the nth time, and performing a conditional judgment once based on the m calculation results. (Supplementary Note 9) When the value of the blackboard is updated for the i-th time, the step of traversing the m decorator nodes to notify and marking the sequence node with the current number of updates of the value of the blackboard includes: 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 decorator node among the m decorator nodes; After the value of the blackboard is updated n times, 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 using values from the blackboard after the sequence node has been marked m*n times. (Supplementary Note 10) The method according to any one of Supplementary Notes 1 to 3, wherein the first behavior tree and the second behavior tree are both Unreal Engine UE4 behavior trees. (Supplementary Note 11) A method for displaying a virtual object executed by a computer 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; If 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, displaying that the first virtual object performs a first number of actions when the first distance is p; When the first distance is q, displaying that the first virtual object performs a second number of actions, a step in which, 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. (Supplementary Note 12) A method for displaying a virtual object executed by a computer 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, a step in which, when p is greater than q, the first duration is greater than the second duration, or, when p is less than q, the first duration is less than the second duration. (Supplementary Note 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, wherein 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; 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 have a negative correlation. (Supplementary Note 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 Supplements 1 to 3, or the method for displaying a virtual object according to Supplementary Note 11, or the method for displaying a virtual object according to Supplementary Note 12. (Supplementary Note 15) A computer program that causes the computer device to realize the method according to any one of Supplements 1 to 3, or the method for displaying a virtual object according to Supplementary Note 11, or the method for displaying a virtual object according to Supplementary Note 12.
Claims
1. A method for controlling a virtual object executed by a computer device, A step of controlling a first virtual object using a first behavior tree, wherein the first virtual object is a non-player character (NPC), A step of obtaining a first distance between a first virtual object and a second virtual object in a virtual environment, wherein the second virtual object is a virtual object controlled by a player, A method for controlling a virtual object, comprising the steps of: when the area surrounding the second virtual object controlled by the player is divided into a plurality of distance ranges, determining to control the first virtual object by a second behavior tree corresponding to the target distance range, based on the fact that the first distance falls within a target distance range among at least two distance ranges corresponding to the second virtual object, wherein each distance range corresponds to one of the second behavior trees, and the closer the distance range is to the second virtual object, the richer the performance of the first virtual object controlled by the corresponding second behavior tree.
2. The method according to claim 1, wherein, if there is a virtual object controlled by multiple players, a target distance for determining the behavior tree that controls the first virtual object is determined by comparing the distance between the first virtual object and the second virtual object.
3. The step of determining to control the first virtual object by a second behavior tree corresponding to the target distance range, based on the fact that the first distance falls within a target distance range among at least two distance ranges corresponding to the second virtual object, A step of adjusting the first update period of the first behavior tree to a second update period based on the first distance, wherein the first update period and the second update period represent the time interval between which the first behavior tree outputs two adjacent decisions, The steps include determining the first behavior tree that uses the second update cycle as the second behavior tree, The method according to claim 1 or 2, comprising the step of deciding to control the first virtual object by the second behavior tree.
4. m decorator nodes are attached to one sequence node of the second behavior tree, and the method is: In the process of controlling the first virtual object with the second behavior tree, the step is to perform a conditional judgment once for the m decorator nodes after last updating the target data within the k-th update cycle of the second behavior tree, The method according to claim 1 or 2, wherein the target data is input data necessary to execute the second behavior tree, the sequence node returns a success value if all child nodes of the sequence node return a success value, the decorator node determines at least one of the following: whether to execute the branch where the sequence node is located, to interrupt the branch where the sequence node is located, or to interrupt a lower priority branch among the branches where the sequence node is located, and further includes a step of m, k being positive integers.
5. The target data includes a value on a blackboard, the m decorator nodes focus on the same value on the blackboard, and within the k-th update cycle, the value on the blackboard is updated n times, where n is a positive integer. The step of performing a conditional judgment once for the m decorator nodes after last updating the target data within the k-th update cycle of the second behavior tree is as follows: When the value of the blackboard is updated for the i-th time, the step of marking the current update count of the value of the blackboard on the sequence node, wherein i is a positive integer less than or equal to n, The method according to claim 4, comprising the step of obtaining m calculation results for the m decorator nodes based on the value of the blackboard after the value of the blackboard has been updated for the nth time, and performing a conditional judgment once based on the m calculation results.
6. The step of traversing the m decorator nodes to notify when the value of the blackboard is updated for the ith time, and marking the current update count of the value of the blackboard in the sequence node, The process includes the step of marking the sequence node once each time one of the m decorator nodes is notified, so that when the value of the blackboard is updated for the ith time, the sequence node is marked m times. The step of obtaining m calculation results for the m decorator nodes based on the values of the blackboard after the nth value of the blackboard has been updated is as follows: The method according to claim 5, comprising the step of obtaining m calculation results of the m decorator nodes based on the values on the blackboard, after the sequence node has been marked m*n times.
7. The method according to claim 1 or 2, wherein the type of the first behavior tree and the second behavior tree are both Unreal Engine UE4 behavior trees.
8. In the case where there are multiple virtual objects controlled by multiple players, the step of obtaining a second distance between a first virtual object and a third virtual object in the virtual environment, wherein the third virtual object is a virtual object controlled by another player, The method according to claim 1, comprising the step of determining, based on the first distance, that the first virtual object is controlled by a second behavior tree if the first distance is smaller than the second distance, wherein the smaller the first distance, the greater the complexity of the second behavior tree or the higher the update frequency of the second behavior tree.
9. A control module that controls a first virtual object by a first behavior tree, wherein the first virtual object is 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, wherein the second virtual object is a virtual object controlled by a player, A control device for a virtual object, comprising: a decision module that, when the area surrounding the second virtual object controlled by the player is divided into a plurality of distance ranges, determines to control the first virtual object by a second behavior tree corresponding to the target distance range, based on the fact that the first distance falls within a target distance range among at least two distance ranges corresponding to the second virtual object, wherein each distance range corresponds to one of the second behavior trees, and the closer the distance range is to the second virtual object, the richer the performance of the first virtual object controlled by the corresponding second behavior tree.
10. A computer program that causes a computer device to implement the method described in Claim 1.