A pathfinding method, device, storage medium and computing device for unit cluster

By updating the path destination and movement path of the unit cluster in real time and actively avoiding obstacles, the problem of obstacle jamming and abnormal behavior during the movement of the unit cluster is solved, and the naturalness and controllability of the interaction between the unit cluster and the controllable characters in the game are improved.

CN114225417BActive Publication Date: 2025-09-23SHANGHAI PERFECT WORLD SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111630971.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-28
Publication Date
2025-09-23
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

The existing DetourCrowd algorithm and Particle Swarm Optimization algorithm can easily cause units to get stuck or behave abnormally when handling unit cluster movement, affecting the controllable characters controlled by the player.

Method used

By obtaining the location information of the target unit that is about to interact with the cluster unit, the path destination of the cluster unit is updated in real time, and obstacles, including static and dynamic obstacles, are actively avoided based on the updated path destination to optimize the movement path.

Benefits of technology

This effectively avoids the problem of controllable characters being stuck by cluster units, reduces the impact of cluster unit behavior on player behavior, and makes the interaction between cluster units and controllable characters more natural.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114225417B_ABST
    Figure CN114225417B_ABST
Patent Text Reader

Abstract

The present invention provides a pathfinding method, apparatus, storage medium, and computing device for a unit cluster. The method comprises: responding to movement instructions from any unit within a unit cluster in a game scene, obtaining the location information of a target unit that will interact with the cluster unit; updating the cluster unit's path destination in real time based on the target unit's location information; and updating the cluster unit's movement path based on the updated cluster unit's path destination, so that the updated movement path actively avoids obstructions. In embodiments of the present invention, players do not need to actively avoid obstacles when controlling a controllable character unit. The cluster unit can actively circumvent the controllable character unit, preventing the controllable character from being stuck by the cluster unit and reducing the impact of the cluster unit's behavior on the controllable character's behavior.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer data processing technology, and in particular to a pathfinding method, device, storage medium and computing equipment for a unit cluster. Background Art

[0002] Currently, there are already DetourCrowd and Particle SwarmOptimization algorithms implemented using RecastNavigation. The standard DetourCrow algorithm can handle the group movement of a specified cluster of units. However, due to the presence of dynamic obstacle avoidance (RVO) between any two units within the cluster, it cannot affect units in a specified direction and the units in the cluster, which can easily lead to algorithm failure. The standard Particle Swarm Optimization algorithm is difficult to evaluate the behavior of cluster units because three parameters within the cluster—unit memory, self-awareness, and group-awareness—combine to influence the direction of unit movement. Furthermore, the player's controllable behavior can easily cause abnormal behavior among units within the cluster, making it difficult to perform correct simulations. Summary of the Invention

[0003] In view of the above problems, the present invention is proposed to provide a path-finding method, device, storage medium and computing device for unit clusters that overcome the above problems or at least partially solve the above problems. It can effectively avoid the problem of controllable characters being stuck by obstacles due to the player's failure to perform obstacle avoidance when controlling the controllable characters, reduce the impact of the cluster unit behavior on the player's behavior, and make the cluster units interact with the controllable characters controlled by the players more naturally.

[0004] According to one aspect of an embodiment of the present invention, a pathfinding method for a unit cluster is provided, comprising:

[0005] In response to a movement instruction of any cluster unit included in the unit cluster in the game scene, obtaining position information of a target unit that is about to interact with the cluster unit;

[0006] updating the path destination of the cluster unit in real time according to the location information of the target unit;

[0007] The movement path of the cluster unit is updated based on the updated path destination of the cluster unit, so that the updated movement path actively avoids blocking obstacles.

[0008] Optionally, the target unit includes other cluster units or controllable character units;

[0009] The controllable character unit is a game character controlled by a player, and the cluster unit is a unit in a non-player controlled character group.

[0010] Optionally, before responding to a movement instruction of any cluster unit included in a unit cluster in the game scene, the method further includes:

[0011] Path-finding movement mode and linear movement mode are pre-defined for controllable character units and cluster units in the game scene.

[0012] Optionally, if the cluster unit is set to a straight-line movement mode, the controllable character unit corresponds to a path-finding movement mode, and the controllable character unit responds to the player's non-manual operation instructions; if the cluster unit is set to a path-finding movement mode, the controllable character unit corresponds to a straight-line movement mode or a path-finding movement mode.

[0013] Optionally, before responding to a movement instruction of any cluster unit included in a unit cluster in the game scene, the method further includes:

[0014] Obtain the movement path of any unit in the game scene, and detect whether there is a static block on the movement path of any unit;

[0015] If it does not exist, retain the movement path of any of the units mentioned;

[0016] If so, find the legal position closest to the unit and recalculate the movement path of the unit based on the legal position.

[0017] Optionally, updating the path destination of the cluster unit in real time according to the location information of the target unit includes:

[0018] The path destination of the cluster units is updated once per game frame based on the position of the target unit.

[0019] Optionally, updating the movement path of the cluster unit based on the updated path destination of the cluster unit so that the updated movement path actively avoids blocking obstacles includes:

[0020] Calculating a new movement path of the cluster unit to avoid static obstacles based on the updated path destination of the cluster unit;

[0021] If it is analyzed that any position point on the new movement path of the cluster unit covers the position of the dynamic blocking obstacle, the movement path of the cluster unit is recalculated until the optimal movement path that avoids the dynamic blocking obstacle is calculated;

[0022] If it is analyzed that the new movement path of the cluster unit does not cover the location of the dynamic blocking obstacle, the updated movement path is retained and used as the optimal movement path of the cluster unit;

[0023] The dynamic blocking obstacles include any one of dynamic objects, controllable characters, and other cluster units in the game scene.

[0024] Optionally, after updating the movement path of the cluster unit based on the updated path destination of the cluster unit so that the updated movement path actively avoids blocking obstacles, the method further includes:

[0025] Projecting the cluster units onto a plane grid, and obtaining an obstacle avoidance direction for the cluster units to avoid obstacles based on the projection on the plane grid;

[0026] Get the movement direction of the cluster unit and its nearby units;

[0027] Based on the obstacle avoidance direction of the cluster unit and the obtained movement direction of each unit, the obstacle avoidance parameters of the cluster unit for avoiding the blocking obstacle are modified, and the obstacle avoidance parameters include at least one of the expected collision direction weight, the current motion vector weight, the lateral movement weight, and the collision time weight.

[0028] Optionally, after updating the movement path of the cluster unit based on the updated path destination of the cluster unit so that the updated movement path actively avoids blocking obstacles, the method further includes:

[0029] interacting with the target unit after the cluster unit moves to the corresponding path destination according to the updated movement path;

[0030] If it is detected during the interaction process that the distance between the cluster unit and the target unit is less than a preset distance, the position of the cluster unit is adjusted to a specified distance from the position of the target unit.

[0031] Optionally, before adjusting the position of the cluster unit to a specified distance from the position of the target unit, the method further includes:

[0032] If it is detected that the speed of the cluster unit is less than a preset threshold, the collision radius of the target unit interacting with the cluster unit is reduced to the preset collision radius;

[0033] After the speed of the cluster unit returns to its original speed, the collision radius of the target unit interacting with the cluster unit is restored to its original collision radius;

[0034] The cluster unit collides with the target unit and pushes the target unit away.

[0035] According to another aspect of an embodiment of the present invention, a pathfinding device for a unit cluster is provided, comprising:

[0036] an acquisition module adapted to respond to a movement instruction of any cluster unit included in a unit cluster in a game scene and acquire position information of a target unit that is about to interact with the cluster unit;

[0037] An updating module, adapted to update the path destination of the cluster unit in real time according to the location information of the target unit;

[0038] The avoidance module is adapted to update the movement path of the cluster unit based on the updated path destination of the cluster unit, so that the updated movement path actively avoids blocking obstacles.

[0039] According to another aspect of an embodiment of the present invention, a computer storage medium is provided, which stores computer program code. When the computer program code runs on a computing device, it causes the computing device to execute the unit cluster pathfinding method of any of the above embodiments.

[0040] According to another aspect of an embodiment of the present invention, a computing device is provided, comprising: a processor; a memory storing computer program code; when the computer program code is executed by the processor, the computing device executes the unit cluster pathfinding method of any of the above embodiments.

[0041] In an embodiment of the present invention, in response to the movement instructions of any cluster unit included in a unit cluster in a game scene, the position information of the target unit that is about to interact with the cluster unit is obtained, and then the path destination of the cluster unit is updated in real time based on the position information of the target unit, and then the movement path of the cluster unit is updated based on the updated path destination of the cluster unit, so that the updated movement path actively avoids blocking obstacles. In an embodiment of the present invention, by timely updating the path destination and movement path of the cluster unit that is about to interact with the target unit in the game scene, the timely updated movement path can avoid blocking obstacles, so that when the cluster unit moves according to the updated movement path, it can timely and effectively avoid obstacles such as other cluster units and controllable characters on the movement path. Players do not need to actively perform obstacle avoidance when controlling the controllable character unit. The cluster unit can actively bypass the controllable character unit to prevent the controllable character from being stuck by the cluster unit, thereby reducing the impact of the cluster unit behavior on the controllable character behavior.

[0042] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below.

[0043] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0045] Figure 1 A schematic flow chart of a pathfinding method for a unit cluster according to an embodiment of the present invention is shown;

[0046] Figure 2 A schematic structural diagram of a pathfinding device for a unit cluster according to an embodiment of the present invention is shown;

[0047] Figure 3 A schematic structural diagram of a pathfinding device for a unit cluster according to an embodiment of the present invention is shown;

[0048] Figure 4 A schematic structural diagram of a pathfinding device for a unit cluster according to an embodiment of the present invention is shown;

[0049] Figure 5 A schematic structural diagram of a pathfinding device for a unit cluster according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0050] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.

[0051] In order to solve the above technical problems, an embodiment of the present invention provides a pathfinding method for bit clusters. Figure 1 FIG2 shows a flow chart of a pathfinding method for a unit cluster according to an embodiment of the present invention. Figure 1 , the pathfinding method of the unit cluster includes steps S102 to S106.

[0052] Step S102 , in response to a movement instruction of any cluster unit included in the unit cluster in the game scene, obtain position information of a target unit that is about to interact with the cluster unit.

[0053] The target units of this embodiment may include other cluster units or controllable character units. Controllable character units are game characters controlled by the player, and cluster units are units in the non-player controlled character group. The embodiment of the present invention does not limit the target unit type.

[0054] Step S104 : updating the path destination of the cluster units in real time according to the location information of the target unit.

[0055] In this embodiment, as the position of the cluster unit and the position of the target unit to be interacted with move, the path destination of the cluster unit will also change accordingly. In the process of updating the path destination of the cluster unit in real time based on the position of the target unit to be interacted with, the path destination of the cluster unit can be re-determined in combination with the current position of the cluster unit and the position of the target unit. The position of the target unit can be used as the destination to be reached by the cluster unit.

[0056] Step S106 : updating the movement path of the cluster unit based on the updated path destination of the cluster unit, so that the updated movement path actively avoids blocking obstacles.

[0057] The embodiment of the present invention timely updates the path destination and movement path of the cluster unit that is about to interact with the target unit in the game scene, so that the timely updated movement path can avoid blocking obstacles. Therefore, when the cluster unit moves according to the updated movement path, it can timely and effectively avoid obstacles such as other cluster units and controllable characters on the movement path. The player does not need to actively perform obstacle avoidance when controlling the controllable character unit. The cluster unit can actively bypass the controllable character unit to avoid the controllable character being stuck by the cluster unit, thereby reducing the impact of the cluster unit behavior on the controllable character behavior.

[0058] The embodiment of the present invention can be applied to a pedestrian system, where the unit types in the game scene can be divided into a controllable character class and a unit cluster class. Each controllable character in the controllable character class can be regarded as a unit, and each cluster unit contained in each unit cluster can also be regarded as a unit. The controllable character unit in the embodiment of the present invention is a game character that can be operated by the player, and the cluster unit is a unit in the non-player-controlled character group. The unit cluster includes an NPC (Non-Player-Controlled Character) cluster, where each NPC in the NPC cluster is a cluster unit.

[0059] In one embodiment of the present invention, a pathfinding movement mode and a linear movement mode can be predefined for both controllable character units and cluster units in the game scene. Units in the pathfinding movement mode actively avoid other units, while units in the linear movement mode do not actively avoid other units.

[0060] If the cluster unit is pre-set to pathfinding movement mode, then the controllable character unit can be set to straight-line movement mode or pathfinding movement mode. If the controllable character unit is in straight-line movement mode, in response to the player's manual operation instructions, the controllable character unit is controlled by remote sensing during the player's manual operation. The player does not need to actively avoid other units to ensure a good operating feel. The cluster unit can now effectively and actively avoid the controllable character unit in pathfinding movement mode. For example, when the player controls controllable character unit A to move, cluster unit B is also moving at the same time. When the controllable character unit A controlled by the player meets cluster unit B, the movement path of cluster unit B is updated to obtain the optimal movement path that can actively avoid controllable character unit A. Cluster unit B actively avoids controllable character unit A during the movement according to the optimal movement path, such as cluster unit B bypassing controllable character unit A. The player can control controllable character unit A to move in a straight line without affecting the player's operating experience.

[0061] If the cluster units are pre-set to linear movement mode, in order to ensure that the controllable character units can effectively avoid obstacles, the controllable character units need to be set to path-finding movement mode. At this time, the controllable character units respond to the player's non-manual operation instructions and can actively avoid the cluster units. For example, when the player clicks on the target location that controllable character unit A needs to reach, controllable character unit A will follow the calculated new movement path to find the path. When controllable character unit A meets cluster unit B, the controllable character unit A's movement path is updated to obtain the optimal movement path that can actively avoid cluster unit B. Controllable character unit A actively avoids cluster unit B during the movement according to the optimal movement path, such as controlling character unit A bypassing cluster unit B, so that cluster unit B will not get stuck.

[0062] In one embodiment of the present invention, before executing step S102 to respond to the movement instruction of any cluster unit included in the unit cluster in the game scene, the legitimacy of the movement paths of all units in the game scene may be checked first.

[0063] First, the movement path of any unit in the game scene is obtained. A check is performed to see if there are any static obstacles on the movement path of any unit. If not, the movement path of any unit is retained. If so, the closest legal position to any unit is found, and the movement path of any unit is recalculated based on the legal position. In this embodiment, the movement path of any unit is recalculated based on the legal position, starting from the legal position and moving towards the destination of the path.

[0064] For example, there may be static obstacles on the path found for the controllable character in the game scene, which will cause the position of the controllable character controlled by the player to be illegal. At this time, a legal position closest to the current position of the controllable character is found near the controllable character, and A* pathfinding is performed again from this legal position towards the destination of the path, so that the movement path of the controllable character is a legal path.

[0065] For example, a static obstruction may exist on the path found for a cluster unit in a game scene, making the unit's position illegal. This embodiment of the present invention effectively ensures that all unit movement paths in the game scene are legal by finding a legal position closest to the unit's current position near the cluster unit, and then re-doing A* pathfinding from this legal position toward the path's destination. Consequently, subsequent updates to the cluster unit's destination and movement path are performed on the legal movement path.

[0066] In one embodiment of the present invention, when executing step S104 to update the cluster unit's path destination in real time based on the target unit's location information, the cluster unit's path destination may be updated once per game frame based on the target unit's location to ensure the real-time and accuracy of the cluster unit's movement path. Alternatively, the cluster unit's path destination and movement path may be updated every few frames during gameplay to conserve game memory resources.

[0067] In another embodiment of the present invention, the specific process of updating the movement path of the cluster unit based on the updated path destination of the cluster unit in step S106 so that the updated movement path actively avoids obstacles is as follows:

[0068] First, a new movement path for the cluster units is calculated based on the updated path destination, avoiding static obstacles. The location information of dynamic obstacles in the game scene is also obtained. Static obstacles can include vegetation, mountains, buildings, and so on. In this embodiment of the present invention, the A* pathfinding algorithm can be used to calculate the new movement path for the cluster units to avoid static obstacles.

[0069] Next, the system analyzes whether any point on the calculated new movement path of the cluster unit overlaps with the location of a dynamic blocking obstacle. This means that the location of the dynamic blocking obstacle overlaps with any point on the new movement path. Dynamic blocking obstacles can be dynamic objects in the game scene, such as virtual animals, or they can be controllable characters controlled by the player or other cluster units.

[0070] If the analysis shows that the new movement path of the cluster unit covers the location of the dynamic blocking obstacle, such as the starting point, destination point or any position on the new movement path of the cluster coincides with the location of the dynamic blocking obstacle, then the movement path of the cluster unit needs to be recalculated until the optimal movement path that avoids the dynamic blocking obstacle is calculated.

[0071] If the analysis shows that the cluster unit's new movement path does not cover the location of a dynamic blocking obstacle, the updated movement path is retained and used as the cluster unit's optimal movement path. This updated optimal movement path not only avoids static obstacles but also effectively avoids dynamic obstacles, improving the user's gaming experience.

[0072] For example, when a cluster unit and a controllable character unit are about to interact, and the cluster unit moves along the calculated new movement path, the player controls the controllable character unit to move dynamically and moves the controllable character unit to the current movement path of the cluster unit, thereby blocking the current movement path of the cluster unit. At this time, the path destination of the cluster unit can be updated based on the position information of the controllable character unit that is about to interact, and a new optimal movement path can be found for the cluster unit based on the updated path destination, and there are no blocking obstacles on the new optimal movement path.

[0073] For another example, cluster unit a and cluster unit b are about to interact. When cluster unit a moves along the calculated new moving path, cluster unit b moves to the current moving path of cluster unit a, blocking the current moving path of cluster unit a. At this time, the path destination of cluster unit a can be updated based on the position information of cluster unit b that is about to interact, and a new optimal moving path can be found for cluster unit a based on the updated path destination, and there are no blocking obstacles on the new optimal moving path.

[0074] The embodiment of the present invention can avoid the problem that the cluster units cannot avoid obstacles in a timely and effective manner during the movement of the cluster units because the controllable character units and other cluster units also move.

[0075] In another optional embodiment, if the cluster unit is in a straight-line movement mode and the controllable character unit is in a path-finding movement mode, that is, the controllable character unit actively avoids the cluster unit, and when the cluster unit blocks the current optimal path of the controllable character unit, a new optimal path can be recalculated for the controllable character unit. For example, after the player clicks on the target location that the controllable character unit needs to reach, the controllable character unit moves along the calculated optimal path for path-finding. During this process, the cluster unit is also moving dynamically. If the cluster unit blocks the current optimal path that the controllable character unit has calculated, it is necessary to find a new optimal movement path for the controllable character unit. This embodiment can avoid the problem that the controllable character unit cannot avoid obstacles in a timely and effective manner during the movement of the controllable character unit because the movement of the cluster unit blocks the optimal path of the controllable character unit.

[0076] In one embodiment of the present invention, after updating the movement path of the cluster unit based on the updated path destination of the cluster unit in step S106 so that the updated movement path actively avoids blocking obstacles, the cluster unit can also be projected onto a plane grid, and the obstacle avoidance direction of the cluster unit to avoid the blocking obstacle is obtained based on the projection on the plane grid. The movement directions of the cluster unit and each unit nearby are also obtained, and the obstacle avoidance parameters of the cluster unit to avoid the blocking obstacle are modified based on the obstacle avoidance direction of the cluster unit to avoid the blocking obstacle and the obtained movement directions of each unit. The obstacle avoidance direction in this embodiment can include a horizontal direction or a vertical direction. If a blocking obstacle is detected in the game scene, the cluster unit can be projected onto the plane grid, so that the obstacle avoidance direction of the cluster unit to avoid the blocking obstacle can be quickly obtained based on the projection on the plane grid.

[0077] In this embodiment, the obstacle avoidance parameters for avoiding blocking obstacles may be dynamic obstacle avoidance (RVO) parameters, including at least one of a desired collision direction weight, a current motion vector weight, a lateral movement weight, and a collision time weight (a collision TimeOfImpact weight). Modifying the obstacle avoidance parameters primarily refines the movement vector of the decision unit after a collision. For example, the horizontal direction weight of the cluster unit may be set to a smaller value, while the desired collision direction weight may be set to a larger value, thereby reducing the horizontal displacement of the cluster unit.

[0078] In one embodiment of the present invention, after executing step S106, the cluster unit can also interact with the target unit after moving to the corresponding path destination according to the updated movement path. If it is detected during the interaction that the distance between the cluster unit and the target unit is less than the preset distance, it is necessary to adjust the position of the cluster unit to a specified distance from the position of the target unit. The specified distance here is the basic distance that the cluster unit and the target unit need to maintain. By timely adjusting the cluster unit and the target unit to maintain the basic specified distance, the embodiment of the present invention can make the cluster unit appear more natural when interacting with the target unit, and ensure that the interactive behavior of the player's cluster unit and the target unit will not be too different from the real physical behavior. Of course, when the cluster unit and the target unit maintain the basic specified distance, the number of adjustment iterations can also be increased to ensure that the cluster unit and the target unit appear more natural when interacting.

[0079] In this embodiment, if the target unit is a controllable character unit, in order to prevent the cluster unit from getting stuck at the edge of the road when stationary, it is also possible to detect whether the speed of the controllable character unit is less than a preset threshold before adjusting the position of the cluster unit to a specified distance from the position of the controllable character unit. If it is detected that the speed of the controllable character unit is less than the preset threshold, the collision radius of the cluster unit interacting with the controllable character unit is reduced to the preset collision radius. After the speed of the controllable character unit returns to its original speed, the collision radius of the cluster unit interacting with the controllable character unit is restored to the original collision radius. After the controllable character unit collides with the cluster unit, the controllable character unit pushes the cluster unit away, that is, by adjusting the position of the cluster unit to a specified distance from the position of the target unit, the cluster unit and the target unit maintain a basic distance.

[0080] The embodiment of the present invention sets the collision radius of the cluster unit to a relatively small value when the speed of the controllable character unit interacting with the cluster unit is very small, so that the cluster unit can continue to move forward for a certain distance, and then instantly restores the cluster unit to the original collision radius. In this way, it can be ensured that the cluster unit moves forward for a certain distance when it is stuck. After detecting that the distance between the cluster unit and the interacting controllable character unit is less than the preset distance, the cluster unit is used to push the controllable character unit away, thereby effectively avoiding the problem of the cluster unit and the controllable character being stuck with each other.

[0081] In one embodiment of the present invention, multiple cluster units may jitter when they are close to a controllable character unit (for example, when a controllable character is close to two NPCs, the direction of the controllable character may jitter slightly), which may easily lead to poor performance of the controllable character unit. Therefore, multiple cluster units cannot be directly used as the direction of the controllable character unit in the game. In order to avoid jitter of the controllable character unit, the embodiment of the present invention can adopt a filtering algorithm or directly replace the direction of the controllable character unit with a remote sensing direction when the controllable character unit is close to multiple cluster units, so as to avoid slight jitter of the controllable character and improve the performance of the controllable character unit.

[0082] Based on the same inventive concept, an embodiment of the present invention further provides a pathfinding device for a unit cluster. Figure 2 FIG2 shows a schematic diagram of a pathfinding device for a unit cluster according to an embodiment of the present invention. Figure 2 The pathfinding device of the unit cluster includes an acquisition module 210, an update module 220 and an avoidance module 230.

[0083] The acquisition module 210 is adapted to respond to a movement instruction of any cluster unit included in the unit cluster in the game scene and acquire position information of a target unit that is about to interact with the cluster unit.

[0084] The updating module 220 is adapted to update the path destination of the cluster unit in real time according to the location information of the target unit.

[0085] The avoidance module 230 is adapted to update the movement path of the cluster unit based on the updated path destination of the cluster unit, so that the updated movement path actively avoids blocking obstacles.

[0086] In one embodiment of the present invention, the target unit includes other cluster units or controllable character units, wherein the controllable character unit is a game character controlled by a player, and the cluster unit is a unit in a non-player controlled character group.

[0087] In one embodiment of the present invention, before the acquisition module 210 responds to the movement instruction of any cluster unit contained in the unit cluster in the game scene, it can also pre-define the path-finding movement mode and the straight-line movement mode for the controllable character units and cluster units in the game scene.

[0088] In one embodiment of the present invention, if the cluster unit is set to a linear movement mode, the controllable character unit corresponds to a path-finding movement mode, and the controllable character unit responds to the player's non-manual operation instructions; if the cluster unit is set to a path-finding movement mode, the controllable character unit corresponds to a linear movement mode or a path-finding movement mode.

[0089] See also Figure 3 In one embodiment of the present invention, Figure 2 The path-finding device of the unit cluster shown also includes a detection module 240, which is suitable for obtaining the movement path of any unit in the game scene before the acquisition module 210 responds to the movement instruction of any cluster unit contained in the unit cluster in the game scene, and detecting whether there is a static obstruction on the movement path of any unit; if not, retain the movement path of any unit; if so, find the legal position closest to any unit, and recalculate the movement path of any unit based on the legal position.

[0090] In one embodiment of the present invention, the updating module 220 is further adapted to update the path destination of the cluster units once per game frame according to the position of the target unit.

[0091] In one embodiment of the present invention, the avoidance module 230 is further adapted to calculate a new movement path of the cluster unit to avoid static obstacles based on the updated path destination of the cluster unit; if it is analyzed that any position point on the new movement path of the cluster unit covers the position of a dynamic blocking obstacle, the movement path of the cluster unit is recalculated until the optimal movement path to avoid the dynamic blocking obstacle is calculated; if it is analyzed that the new movement path of the cluster unit does not cover the position of the dynamic blocking obstacle, the updated movement path is retained and used as the optimal movement path of the cluster unit; wherein the dynamic blocking obstacle includes any one of the dynamic objects, controllable characters, and other cluster units in the game scene.

[0092] See also Figure 4 In one embodiment of the present invention, the above Figure 2 The path-finding device of the controllable character shown also includes a parameter modification module 250, which is suitable for projecting the cluster unit onto a plane grid, and obtaining the obstacle avoidance direction of the cluster unit to avoid blocking obstacles based on the projection in the plane grid; obtaining the movement direction of the cluster unit and each unit nearby; and modifying the obstacle avoidance parameters of the cluster unit to avoid blocking obstacles based on the obstacle avoidance direction of the cluster unit to avoid blocking obstacles and the obtained movement directions of each unit. The obstacle avoidance parameters include at least one of the expected collision direction weight, the current motion vector weight, the lateral movement weight, and the collision time weight.

[0093] See also Figure 5 In one embodiment of the present invention, the above Figure 2 The path-finding device for the controllable character shown further includes a setting module 260 and an adjustment module 270 .

[0094] The adjustment module 270 is adapted to interact with the target unit after the cluster unit moves to the corresponding path destination according to the updated movement path; if it is detected during the interaction that the distance between the cluster unit and the target unit is less than a preset distance, adjust the position of the cluster unit to a specified distance from the position of the target unit.

[0095] The setting module 260 is adapted to reduce the collision radius of the cluster units interacting with the controllable character unit to a preset collision radius if it is detected that the speed of the controllable character unit is less than a preset threshold; after the speed of the controllable character unit returns to its original speed, restore the collision radius of the cluster units interacting with the controllable character unit to the original collision radius; the controllable character unit collides with the cluster unit and pushes the cluster unit away.

[0096] Based on the same inventive concept, an embodiment of the present invention further provides a computer storage medium storing computer program code. When the computer program code runs on a computing device, it causes the computing device to execute the unit cluster pathfinding method of any of the above embodiments.

[0097] Based on the same inventive concept, an embodiment of the present invention further provides a computing device, comprising: a processor; a memory storing computer program code; when the computer program code is executed by the processor, the computing device executes the unit cluster pathfinding method of any of the above embodiments.

[0098] Those skilled in the art will clearly understand that the specific working processes of the systems, devices, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and for the sake of brevity, they will not be further described here.

[0099] In addition, the functional units in various embodiments of the present invention may be physically independent of each other, or two or more functional units may be integrated together, or all functional units may be integrated into a single processing unit. The above-mentioned integrated functional units may be implemented in the form of hardware, software, or firmware.

[0100] Those skilled in the art will understand that if the integrated functional unit is implemented in the form of software and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention can essentially or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, which includes a number of instructions for enabling a computing device (such as a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention when running the instructions. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0101] Alternatively, all or part of the steps of implementing the aforementioned method embodiments may be accomplished by hardware associated with program instructions (such as a computing device such as a personal computer, a server, or a network device), and the program instructions may be stored in a computer-readable storage medium. When the program instructions are executed by a processor of a computing device, the computing device executes all or part of the steps of the method described in each embodiment of the present invention.

[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that within the spirit and principles of the present invention, they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some or all of the technical features therein. However, these modifications or replacements do not deviate from the scope of protection of the present invention.

Claims

1. A pathfinding method for a unit cluster, characterized in that: include: In response to a movement instruction of any cluster unit included in a unit cluster in a game scene, obtaining position information of a target unit that is about to interact with the cluster unit, wherein the target unit includes other cluster units or controllable character units, the controllable character units are game characters controlled by a player, and the cluster units are units in a group of non-player-controlled characters; updating the path destination of the cluster unit in real time according to the location information of the target unit; The movement paths of the cluster units are updated based on the updated path destinations of the cluster units, so that the updated movement paths actively avoid blocking obstacles; interacting with the target unit after the cluster unit moves to the corresponding path destination according to the updated movement path; If it is detected during the interaction process that the distance between the cluster unit and the target unit is less than a preset distance, and the target unit is a controllable character unit, the following method is executed: If it is detected that the speed of the controllable character unit is less than a preset threshold, the collision radius of the cluster units interacting with the controllable character unit is reduced to the preset collision radius; After the speed of the controllable character unit returns to its original speed, the collision radius of the cluster units interacting with the controllable character unit is restored to its original collision radius; The controllable character unit collides with the cluster unit and pushes the cluster unit away, so as to adjust the position of the cluster unit to a specified distance from the position of the target unit.

2. The method according to claim 1, characterized in that Before responding to a movement instruction of any cluster unit contained in a unit cluster in the game scene, the method further includes: Path-finding movement mode and linear movement mode are pre-defined for controllable character units and cluster units in the game scene.

3. The method according to claim 2, characterized in that If the cluster unit is set to a linear movement mode, the controllable character unit corresponds to a path-finding movement mode, and the controllable character unit responds to a player's non-manual operation command; If the cluster unit is set to the path-finding movement mode, the controllable character unit corresponds to the straight-line movement mode or the path-finding movement mode.

4. The method according to any one of claims 1 to 3, characterized in that Before responding to a movement instruction of any cluster unit contained in a unit cluster in the game scene, the method further includes: Obtain the movement path of any unit in the game scene, and detect whether there is a static block on the movement path of any unit; If it does not exist, retain the movement path of any of the units mentioned; If so, find the legal position closest to the unit and recalculate the movement path of the unit based on the legal position.

5. The method according to any one of claims 1 to 3, characterized in that Updating the path destination of the cluster unit in real time according to the location information of the target unit includes: The path destination of the cluster units is updated once per game frame based on the position of the target unit.

6. The method according to any one of claims 1 to 3, characterized in that The movement paths of the cluster units are updated based on the updated path destinations of the cluster units, so that the updated movement paths actively avoid blocking obstacles, including: Calculating a new movement path of the cluster unit to avoid static obstacles based on the updated path destination of the cluster unit; If it is analyzed that any position point on the new movement path of the cluster unit covers the position of the dynamic blocking obstacle, the movement path of the cluster unit is recalculated until the optimal movement path that avoids the dynamic blocking obstacle is calculated; If it is analyzed that the new movement path of the cluster unit does not cover the location of the dynamic blocking obstacle, the updated movement path is retained and used as the optimal movement path of the cluster unit; The dynamic blocking obstacles include any one of dynamic objects, controllable characters, and other cluster units in the game scene.

7. The method according to any one of claims 1 to 3, characterized in that After updating the movement path of the cluster unit based on the updated path destination of the cluster unit so that the updated movement path actively avoids blocking obstacles, the method further includes: Projecting the cluster units onto a plane grid, and obtaining an obstacle avoidance direction for the cluster units to avoid obstacles based on the projection on the plane grid; Get the movement direction of the cluster unit and its nearby units; Based on the obstacle avoidance direction of the cluster unit and the obtained movement direction of each unit, the obstacle avoidance parameters of the cluster unit for avoiding the blocking obstacle are modified, and the obstacle avoidance parameters include at least one of the expected collision direction weight, the current motion vector weight, the lateral movement weight, and the collision time weight.

8. A pathfinding device for a unit cluster, characterized in that: include: an acquisition module adapted to, in response to a movement instruction of any cluster unit included in a unit cluster in a game scene, acquire position information of a target unit that is about to interact with the cluster unit, wherein the target unit includes other cluster units or controllable character units, the controllable character units being game characters controlled by a player, and the cluster units being units in a group of non-player-controlled characters; An updating module, adapted to update the path destination of the cluster unit in real time according to the location information of the target unit; An avoidance module adapted to update the movement path of the cluster unit based on the updated path destination of the cluster unit, so that the updated movement path actively avoids blocking obstacles; an adjustment module, adapted to interact with the target unit after the cluster unit moves to the corresponding path destination according to the updated movement path; if it is detected during the interaction that the distance between the cluster unit and the target unit is less than a preset distance, adjust the position of the cluster unit to a specified distance from the position of the target unit; A setting module is adapted to reduce the collision radius of the cluster units interacting with the controllable character unit to a preset collision radius if it is detected that the speed of the controllable character unit is less than a preset threshold; after the speed of the controllable character unit returns to its original speed, restore the collision radius of the cluster units interacting with the controllable character unit to the original collision radius; the controllable character unit collides with the cluster unit and pushes the cluster unit away to adjust the position of the cluster unit to a specified distance from the position of the target unit.

9. A computer storage medium storing a computer program code, which, when executed on a computing device, causes the computing device to execute the unit cluster pathfinding method according to any one of claims 1 to 7.

10. A computing device comprising: processor; a memory storing computer program code; When the computer program code is executed by the processor, it causes the computing device to execute the pathfinding method for a unit cluster according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Multi-unit pathfinding method and device

    CN107185242A

  • Game control method and device, electronic equipment and storage medium

    CN112807681A