A path-finding method, device, storage medium and computing device for a controllable character
By updating the path destination and movement path of the controllable character units in real time and optimizing their obstacle avoidance methods, the problem of controllable characters being easily stuck by obstacles in the existing technology is solved, and the simulation accuracy and naturalness of the cluster unit behavior are improved.
Patent Information
- Application Number
- CN202111630218.1
- 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
When processing the movement of cluster units, the existing DetourCrowd algorithm and Particle Swarm Optimization algorithm are prone to the problem of getting stuck on obstacles due to the controllable character controlled by the player not performing obstacle avoidance, and the existing technology is difficult to effectively simulate the behavior of cluster units, resulting in abnormal behavior.
By updating the path destination of the controllable character unit in real time, based on the position of the target unit, its movement path is optimized to avoid obstacles, and combined with static and dynamic obstacle detection and avoidance algorithms to ensure the legitimacy and effectiveness of the path.
It effectively avoids the problem of controllable characters getting stuck by obstacles, reduces the impact of player behavior on the behavior of cluster units, and makes the controllable characters more natural when interacting with cluster units.
Smart Images

Figure CN114259728B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer data processing technology, and in particular to a path-finding method, device, storage medium and computing equipment for a controllable character. 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 a controllable character that overcomes the above problems or at least partially solves the above problems. It can effectively avoid the problem of a controllable character being stuck by an obstacle due to the player's failure to perform obstacle avoidance when controlling the controllable character, reduce the impact of the player's behavior on the behavior of the cluster unit, and make the controllable character controlled by the player behave more naturally when interacting with the cluster unit.
[0004] According to one aspect of an embodiment of the present invention, a path-finding method for a controllable character is provided, comprising:
[0005] Determine a target unit in the game scene that is about to interact with the controllable character unit, and obtain the position of the target unit;
[0006] updating the path destination of the controllable character unit in real time according to the position of the target unit;
[0007] The movement path of the controllable character unit is updated based on the updated path destination of the controllable character unit, so that the updated movement path avoids blocking obstacles.
[0008] Optionally, the target unit includes other controllable character units or cluster 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 determining the target unit that is about to interact with the controllable character unit 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 controllable character unit responds to a manual operation instruction from the player, the controllable character unit corresponds to a linear movement mode, and the cluster unit corresponds to a pathfinding movement mode; if the controllable character unit responds to a non-manual operation instruction from the player, the controllable character unit corresponds to a pathfinding movement mode, and the cluster unit corresponds to a linear movement mode or a pathfinding movement mode.
[0013] Optionally, before determining the target unit that is about to interact with the controllable character unit 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 controllable character unit in real time according to the position of the target unit includes:
[0018] The path destination of the controllable character unit is updated once per game frame based on the position of the target unit.
[0019] Optionally, updating the movement path of the controllable character unit based on the updated path destination of the controllable character unit so that the updated movement path avoids blocking obstacles includes:
[0020] Calculate a new movement path for the controllable character unit to avoid static obstacles based on the updated path destination of the controllable character unit;
[0021] If it is found that any point on the new movement path of the controllable character unit overlaps the location of the dynamic blocking obstacle, the movement path of the controllable character unit is recalculated until the optimal movement path that avoids the dynamic blocking obstacle is calculated;
[0022] If the analysis shows that the new movement path of the controllable character 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 controllable character unit;
[0023] The dynamic blocking obstacles include any one of dynamic objects in the game scene, other controllable characters, and cluster units.
[0024] Optionally, after updating the movement path of the controllable character unit based on the updated path destination of the controllable character unit so that the updated movement path avoids obstacles, the method further includes:
[0025] Projecting the controllable character unit onto a plane grid, and obtaining an obstacle avoidance direction for the controllable character unit to avoid an obstacle based on the projection onto the plane grid;
[0026] Get the movement direction of the controllable character unit and its nearby units;
[0027] Based on the obstacle avoidance direction of the controllable character unit and the obtained movement direction of each unit, the obstacle avoidance parameters of the controllable character unit for avoiding blocking obstacles are modified. 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 controllable character unit based on the updated path destination of the controllable character unit so that the updated movement path avoids obstacles, the method further includes:
[0029] After the controllable character unit moves to the corresponding path destination according to the updated movement path, interacting with the target unit;
[0030] If it is detected during the interaction process that the distance between the controllable character unit and the target unit is less than a preset distance, the position of the controllable character unit is adjusted to a specified distance from the position of the target unit.
[0031] Optionally, before adjusting the position of the controllable character 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 controllable character unit is less than a preset threshold, the collision radius of the target unit interacting with the controllable character unit is reduced to the preset collision radius;
[0033] After the speed of the controllable character unit returns to its original speed, restoring the collision radius of the target unit interacting with the controllable character unit to its original collision radius;
[0034] The controllable character 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 path-finding device for a controllable character is provided, comprising:
[0036] a determination module adapted to determine a target unit in the game scene that is about to interact with the controllable character unit, and obtain a position of the target unit;
[0037] An updating module, adapted to update the path destination of the controllable character unit in real time according to the position of the target unit;
[0038] The avoidance module is adapted to update the moving path of the controllable character unit based on the updated path destination of the controllable character unit, so that the updated moving path avoids blocking obstacles.
[0039] According to another aspect of an embodiment of the present invention, a computer storage medium is provided, wherein the computer storage medium stores computer program code. When the computer program code is executed on a computing device, the computing device is caused to execute the path-finding method of the controllable character in 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 path-finding method of the controllable character of any of the above embodiments.
[0041] After determining the target unit that the controllable character unit is about to interact with in the game scene and obtaining the position of the target unit, the embodiment of the present invention updates the path destination of the controllable character unit in real time according to the position of the target unit, and updates the movement path of the controllable character unit based on the updated path destination of the controllable character unit, so that the updated movement path avoids blocking obstacles. By timely updating the path destination and movement path of the controllable character unit that is about to interact with the target unit in the game scene, the timely updated movement path avoids blocking obstacles, so that when the controllable character unit moves according to the updated movement path, it can timely and effectively avoid blocking obstacles on the movement path, avoiding the problem of the controllable character being stuck by blocking obstacles due to the controllable character unit controlled by the player not performing obstacle avoidance, and reducing the impact of the controllable character behavior on the behavior of the cluster units.
[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 diagram showing a flow chart of a path-finding method for a controllable character according to an embodiment of the present invention is shown;
[0046] Figure 2 A schematic structural diagram of a path-finding device for a controllable character according to an embodiment of the present invention is shown;
[0047] Figure 3 A schematic structural diagram of a path-finding device for a controllable character according to another embodiment of the present invention is shown;
[0048] Figure 4 A schematic structural diagram of a path-finding device for a controllable character according to yet another embodiment of the present invention is shown;
[0049] Figure 5 A schematic structural diagram of a path-finding device for a controllable character according to yet another 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] To solve the above technical problems, an embodiment of the present invention provides a path-finding method for a controllable character, which is applied to a game system with dynamic blocking. Figure 1 FIG2 shows a flow chart of a path-finding method for a controllable character according to an embodiment of the present invention. Figure 1 , the method includes steps S102 to S106.
[0052] Step S102: determining a target unit in the game scene that is about to interact with the controllable character unit, and obtaining a position of the target unit.
[0053] The target units of this embodiment may include other controllable character units or cluster units. The controllable character units are game characters controlled by the player, and the 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 controllable character unit in real time according to the position of the target unit.
[0055] In this embodiment, as the position of the controllable character unit and the position of the target unit to be interacted with move, the path destination of the controllable character unit will also change accordingly. In the process of updating the path destination of the controllable character unit in real time based on the position of the target unit to be interacted with, the path destination of the controllable character unit can be re-determined in combination with the current position of the controllable character 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 controllable character unit.
[0056] Step S106: updating the moving path of the controllable character unit based on the updated path destination of the controllable character unit, so that the updated moving path avoids blocking obstacles.
[0057] After determining the target unit that the controllable character unit is about to interact with in the game scene and obtaining the position of the target unit, the embodiment of the present invention updates the path destination of the controllable character unit in real time according to the position of the target unit, and updates the movement path of the controllable character unit based on the updated path destination of the controllable character unit, so that the updated movement path avoids blocking obstacles. By timely updating the path destination and movement path of the controllable character unit that is about to interact with the target unit in the game scene, the timely updated movement path avoids blocking obstacles, so that when the controllable character unit moves according to the updated movement path, it can timely and effectively avoid blocking obstacles on the movement path, avoiding the problem of the controllable character being stuck by blocking obstacles due to the player's controllable character unit not performing obstacle avoidance, and reducing the impact of the controllable character behavior on the behavior of cluster units.
[0058] The embodiments of the present invention can be applied to pedestrian systems. The unit types in the game scene can be divided into controllable character classes and unit cluster classes. 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. A controllable character refers to a game character that can be controlled by the player, and a cluster unit refers to a unit contained in a unit cluster. Unit clusters include NPC (Non-Player-Controlled Character) clusters, where each NPC in the NPC cluster is a cluster unit.
[0059] In an optional embodiment, a pathfinding movement mode and a straight-line movement mode are pre-defined for the controllable character units and cluster units in the game scene. Among them, the units in the pathfinding movement mode actively avoid other units, while the units in the straight-line movement mode do not actively avoid other units. The controllable character units are controlled by remote sensing during the player's manual operation, that is, the controllable character units respond to the player's manual operation instructions. If actively avoiding other units will make the operation feel worse, the controllable character units can be switched to the straight-line movement mode, and the cluster units correspond to the pathfinding movement mode, and the cluster units actively avoid the controllable character units. If the controllable character units respond to the player's non-manual operation instructions, the controllable character units can be switched to the pathfinding movement mode, and the cluster units correspond to any mode in the straight-line movement mode or the pathfinding movement mode. At this time, the controllable character units can avoid the cluster units, thereby reducing the impact of the controllable character behavior on the cluster unit behavior.
[0060] In one embodiment of the present invention, before executing step S102 to determine the target unit in the game scene that is about to interact with the controllable character unit, the legitimacy of the movement paths of all units in the game scene may be checked first.
[0061] 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.
[0062] For example, in a game scene, there may be static obstructions on the path found for a controllable character. This could cause the player's controlled character to be in an illegal position. This embodiment of the present invention effectively ensures that all movement paths of units in the game scene are legal by searching for a legal position closest to the controllable character's current position and then re-doing A* pathfinding from this legal position toward the path's destination. Consequently, subsequent updates to the controllable character's path and destination are based on the legal movement path and the corresponding path's destination.
[0063] Generally speaking, the positions of static obstructions in a game scene are fixed, such as vegetation, buildings, mountains, ramps, etc., and a pathfinding algorithm (such as the A* pathfinding algorithm, etc.) can be used to conveniently and effectively avoid static obstructions when calculating the unit's movement path. However, dynamic obstructions in a game scene are mobile, such as virtual characters controlled by other users, unit clusters, animals, etc. During the movement of the controllable character unit, the dynamic obstruction may also be in a moving state. Therefore, the originally calculated movement path may be blocked by the movement of the dynamic obstruction. At this time, if the controllable character unit continues to move along the original movement path, it may cause the controllable character unit or other units to be blocked and stuck. Therefore, the embodiments of the present invention can avoid these problems by updating and optimizing the movement path of the controllable character unit in the game scene.
[0064] In one embodiment of the present invention, if a controllable character unit responds to a non-manual operation command from the player, such as when the player clicks on a target location that the controllable character unit needs to reach, the controllable character unit switches to a path-finding movement mode and automatically paths to the target location. The target location can be any location on the game scene map, or it can be the location of the target unit. If it is the location of the target unit, then as the target unit moves, the target location also changes accordingly.
[0065] In this embodiment, the specific process of updating the movement path of the controllable character unit based on the updated path destination of the controllable character unit in step S106 so that the updated movement path avoids obstacles is as follows:
[0066] First, a new movement path for the controllable character is calculated based on the updated path destination of the controllable character, avoiding static obstacles. The location information of dynamic obstacles in the game scene is also obtained. Static obstacles can include vegetation, mountains, buildings, etc. In this embodiment of the present invention, an A* pathfinding algorithm can be used to calculate the new movement path for the controllable character to avoid static obstacles.
[0067] Next, the system analyzes whether any point on the calculated new movement path of the controllable character overlaps with the location of a dynamic blocking obstacle. This means that 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, other controllable characters controlled by other players, or other clustered units.
[0068] If the analysis shows that the new movement path of the controllable character 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 controllable character unit coincides with the location of the dynamic blocking obstacle, then the movement path of the controllable character unit needs to be recalculated until the optimal movement path that avoids the dynamic blocking obstacle is calculated.
[0069] If the analysis shows that the controllable character's new movement path does not cover the location of a dynamic blocking obstacle, the updated movement path is directly retained and used as the optimal movement path for the controllable character. In this way, the optimal movement path obtained after the controllable character is updated can not only avoid static obstacles, but also effectively avoid dynamic obstacles, improving the user's gaming experience.
[0070] For example, after a player clicks on a target location for a controllable character, the controllable character moves along the calculated new path. During this process, other clustered units also move dynamically. If other clustered units block the newly calculated path for the controllable character, a new optimal movement path must be found for the controllable character. This embodiment of the present invention can avoid the problem of the controllable character being unable to avoid obstacles in a timely and effective manner during the movement of the controllable character due to the movement of blocking obstacles.
[0071] In one embodiment of the present invention, after the movement path of the controllable character unit is updated based on the updated path destination of the controllable character unit in step S106 so that the updated movement path avoids the obstructing obstacle, the controllable character unit can be projected onto a plane grid, and the obstacle avoidance direction of the controllable character unit to avoid the obstructing obstacle is obtained based on the projection on the plane grid, and the movement direction of the controllable character unit and each unit in its vicinity is obtained, and then the obstacle avoidance parameters of the controllable character unit to avoid the obstructing obstacle are modified based on the obstacle avoidance direction of the controllable character unit to avoid the obstructing 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 an obstructing obstacle is detected in the game scene, the controllable character unit can be projected onto the plane grid, so that the obstacle avoidance direction of the controllable character unit to avoid the obstructing obstacle can be quickly obtained based on the projection on the plane grid.
[0072] In this embodiment, the obstacle avoidance parameters for avoiding blocking obstacles may be dynamic obstacle avoidance (RVO) parameters, including at least one parameter such as 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 serves to refine the movement vector of the controllable character unit after a collision. For example, the horizontal direction weight of the controllable character 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 controllable character.
[0073] In one embodiment of the present invention, after executing step S106, the controllable character unit moves according to the updated movement path, and interacts with the target unit after moving to the corresponding path destination. If it is detected during the interaction that the distance between the controllable character unit and the target unit is less than a preset distance, the position of the controllable character unit is adjusted to a specified distance from the position of the controllable character unit. The specified distance here is the basic distance that the controllable character unit and the target unit need to maintain. By timely adjusting the controllable character unit and the target unit to maintain a basic specified distance, the embodiment of the present invention can make the controllable character unit more natural when interacting with the target unit, and ensure that the interactive behavior between the player's controllable character and the unit cluster will not be too different from the real physical behavior.
[0074] Of course, when the controllable character unit maintains a basic specified distance from the target unit, the number of adjustment iterations can be increased to ensure that the interaction between the cluster unit and the controllable character unit behaves more naturally.
[0075] The embodiment of the present invention can update the path destination and movement path of the controllable character unit in each frame update of the game to ensure the real-time and accuracy of the movement path of the controllable character unit. Of course, the path destination and movement path of the controllable character can also be updated every few frames during the game to save game running memory resources.
[0076] In one embodiment of the present invention, after a frame of the game is updated, in order to prevent the controllable character unit from getting stuck at the edge of the road (such as any unit in the unit cluster) when it is stationary, the collision radius of the target unit interacting with the controllable character unit can be reduced to a preset collision radius when it is detected that the speed of the controllable character unit is less than a preset threshold. The target unit continues to move forward for a certain distance. After the speed of the controllable character unit returns to its original speed, the collision radius of the target unit interacting with the controllable character unit is restored to the original collision radius. At this time, after it is detected that the distance between the interacting controllable character unit and the target unit is less than the original collision radius, the position of the target unit can be adjusted to a specified distance from the position of the controllable character unit to keep a basic distance between the controllable character unit and the target unit.
[0077] In the embodiment of the present invention, when the speed of the controllable character is very small, the collision radius of the interactive target unit is set to a relatively small value, so that the target unit can continue to move forward for a certain distance, and then the target unit is instantly restored to the original collision radius. In this way, it is ensured that the target unit moves forward for a certain distance when it is stuck. After detecting that the distance between the controllable character unit and the interactive target unit is less than the preset distance, the target unit is used to push the controllable character unit away, thereby effectively avoiding the situation where the target unit and the controllable character are stuck with each other.
[0078] In another embodiment of the present invention, if the controllable character unit responds to the player's manual operation instructions, such as the player controls the controllable character unit through remote sensing, in order to avoid the problem that the controllable character unit actively avoids other units, which may easily cause the player's operating feel to deteriorate, the movement mode of the controllable character unit can be switched to a straight-line movement mode, and the cluster unit corresponds to a path-finding movement mode, and the target unit actively avoids the controllable character unit. For example, when the player controls the 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 the controllable character unit A. Cluster unit B actively avoids the controllable character unit A during the movement process according to the optimal movement path, such as cluster unit B bypassing the controllable character unit A, while the player can control the controllable character unit A to walk in a straight line, thereby not affecting the player's operating experience.
[0079] In the embodiment of the present invention, for the specific method of updating the optimal movement path for the cluster unit to actively avoid the controllable character unit, please refer to the above method for the controllable character unit to actively avoid the cluster unit, and the embodiment of the present invention will not repeat it again.
[0080] In one embodiment of the present invention, a controllable character unit may shake when it is close to multiple target units (for example, when a controllable character is close to two NPCs, the direction of the controllable character may shake slightly), which may easily lead to poor performance of the controllable character unit. Therefore, multiple target units cannot be directly used as the direction of the controllable character unit in the game. In order to avoid shaking 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 target units to avoid slight shaking of the controllable character and improve the performance of the controllable character unit.
[0081] Based on the same inventive concept, an embodiment of the present invention further provides a path-finding device for a controllable character. Figure 2 FIG2 shows a schematic diagram of a path-finding device for a controllable character according to an embodiment of the present invention. Figure 2 The path-finding device of the controllable character includes a determination module 210, an update module 220, and an avoidance module 230.
[0082] The determination module 210 is adapted to determine a target unit in the game scene that is about to interact with the controllable character unit, and obtain a position of the target unit.
[0083] The updating module 220 is adapted to update the path destination of the controllable character unit in real time according to the location of the target unit.
[0084] The avoidance module 230 is adapted to update the movement path of the controllable character unit based on the updated path destination of the controllable character unit, so that the updated movement path avoids blocking obstacles.
[0085] In one embodiment of the present invention, the target unit includes other controllable character units or cluster 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.
[0086] In one embodiment of the present invention, before the determination module 210 determines the target unit that is about to interact with the controllable character unit in the game scene, it can also pre-define a path-finding movement mode and a straight-line movement mode for the controllable character unit and cluster units in the game scene.
[0087] In one embodiment of the present invention, if the controllable character unit responds to the player's manual operation instructions, the controllable character unit corresponds to the linear movement mode, and the cluster unit corresponds to the path-finding movement mode; if the controllable character unit responds to the player's non-manual operation instructions, the controllable character unit corresponds to the path-finding movement mode, and the cluster unit corresponds to the linear movement mode or the path-finding movement mode.
[0088] See also Figure 3 In one embodiment of the present invention, the above Figure 2 The controllable character pathfinding device shown further includes a detection module 240. The detection module 240 is adapted to obtain the movement path of any unit in the game scene, detect whether there is a static blockage on the movement path of any unit, and retain the movement path of any unit if no static blockage exists. If no static blockage exists, find the closest legal position to any unit and recalculate the movement path of any unit based on the legal position before the determination module 210 determines the target unit with which the controllable character unit is about to interact.
[0089] In one embodiment of the present invention, the updating module 220 is further adapted to update the path destination of the controllable character unit once per game frame according to the position of the target unit.
[0090] In one embodiment of the present invention, the avoidance module 230 is further adapted to calculate a new movement path for the controllable character unit to avoid static obstacles based on the updated path destination of the controllable character unit; if it is analyzed that any point on the new movement path of the controllable character unit overlaps the location of a dynamic blocking obstacle, the movement path of the controllable character unit is recalculated until an optimal movement path to avoid the dynamic blocking obstacle is calculated; if it is analyzed that the new movement path of the controllable character unit does not overlap the location of the dynamic blocking obstacle, the updated movement path is retained and used as the optimal movement path for the controllable character unit; wherein the dynamic blocking obstacle includes any one of dynamic objects in the game scene, other controllable characters, and cluster units. In one embodiment of the present invention, the dynamic blocking obstacle includes any one of dynamic objects in the game scene, other controllable characters, and cluster units.
[0091] 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 updating the moving path of the controllable character unit based on the updated path destination of the controllable character unit in the avoidance module 230, so that the updated moving path avoids the blocking obstacle, and then projecting the controllable character unit onto a plane grid, obtaining the obstacle avoidance direction of the controllable character unit to avoid the blocking obstacle based on the projection in the plane grid; obtaining the moving direction of the controllable character unit and each unit in its vicinity; and modifying the obstacle avoidance parameters of the controllable character unit to avoid the blocking obstacle based on the obstacle avoidance direction of the controllable character unit to avoid the blocking obstacle and the obtained moving directions of each unit, wherein 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.
[0092] See also Figure 5 In one embodiment of the present invention, the above Figure 2 The path-finding device of the controllable character shown also includes a setting module 260 and an adjustment module 270. The adjustment module 270 is suitable for updating the moving path of the controllable character unit based on the updated path destination of the controllable character unit in the avoidance module 230, so that the updated moving path avoids blocking obstacles. After the controllable character unit moves to the corresponding path destination according to the updated moving path, it interacts with the target unit; if it is detected during the interaction process that the distance between the controllable character unit and the target unit is less than the preset distance, the position of the controllable character unit is adjusted to a specified distance from the position of the target unit.
[0093] The setting module 260 is suitable for reducing the collision radius of the target unit 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 before the adjustment module 270 adjusts the position of the controllable character unit to a specified distance from the position of the target unit; after the speed of the controllable character unit returns to its original speed, the collision radius of the target unit interacting with the controllable character unit is restored to the original collision radius; the controllable character unit collides with the target unit and pushes the target unit away.
[0094] 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 path-finding method of the controllable character in any of the above embodiments.
[0095] Based on the same inventive concept, an embodiment of the present invention also provides a computing device, including: a processor; a memory storing computer program code; when the computer program code is executed by the processor, the computing device executes the path-finding method of the controllable character in any of the above embodiments.
[0096] 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.
[0097] 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.
[0098] 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.
[0099] 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.
[0100] 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 path-finding method for a controllable character, characterized in that: include: Determine a target unit in the game scene that is about to interact with the controllable character unit, and obtain the position of the target unit; updating the path destination of the controllable character unit in real time according to the position of the target unit; The movement path of the controllable character unit is updated based on the updated path destination of the controllable character unit, so that the updated movement path avoids blocking obstacles; The target units include other controllable character units or cluster units; Wherein, the controllable character unit is a game character controlled by a player, and the cluster unit is a unit in a group of non-player controlled characters; After updating the movement path of the controllable character unit based on the updated path destination of the controllable character unit so that the updated movement path avoids obstacles, the method further includes: after the controllable character unit moves to the corresponding path destination according to the updated movement path, interacting with the target unit; if it is detected during the interaction that the distance between the controllable character unit and the target unit is less than a preset distance, adjusting the position of the controllable character unit to a specified distance from the position of the target unit; Before adjusting the position of the controllable character unit to a specified distance from the position of the target unit, the method further includes: if it is detected that the speed of the controllable character unit is less than a preset threshold, reducing the collision radius of the target unit interacting with the controllable character unit to a preset collision radius; after the speed of the controllable character unit returns to its original speed, restoring the collision radius of the target unit interacting with the controllable character unit to the original collision radius; the controllable character unit collides with the target unit and pushes the target unit away.
2. The method according to claim 1, characterized in that Before determining the target unit that is about to interact with the controllable character unit in the game scene, it also 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 controllable character unit responds to the player's manual operation instructions, the controllable character unit corresponds to the linear movement mode, and the cluster unit corresponds to the path-finding movement mode; if the controllable character unit responds to the player's non-manual operation instructions, the controllable character unit corresponds to the path-finding movement mode, and the cluster unit corresponds to the linear movement mode or the path-finding movement mode.
4. The method according to claim 1, wherein Before determining the target unit that is about to interact with the controllable character unit in the game scene, it also 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 claim 1, wherein Updating the path destination of the controllable character unit in real time according to the position of the target unit includes: The path destination of the controllable character unit is updated once per game frame based on the position of the target unit.
6. The method according to claim 1, characterized in that The movement path of the controllable character unit is updated based on the updated path destination of the controllable character unit, so that the updated movement path avoids blocking obstacles, including: Calculate a new movement path for the controllable character unit to avoid static obstacles based on the updated path destination of the controllable character unit; If it is found that any point on the new movement path of the controllable character unit overlaps the location of the dynamic blocking obstacle, the movement path of the controllable character unit is recalculated until the optimal movement path that avoids the dynamic blocking obstacle is calculated; If the analysis shows that the new movement path of the controllable character 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 controllable character unit; The dynamic blocking obstacles include any one of dynamic objects in the game scene, other controllable characters, and cluster units.
7. The method according to claim 1, characterized in that The controllable character unit's movement path is updated based on the updated path destination of the controllable character unit so that the updated movement path avoids obstacles, further comprising: Projecting the controllable character unit onto a plane grid, and obtaining an obstacle avoidance direction for the controllable character unit to avoid an obstacle based on the projection onto the plane grid; Get the movement direction of the controllable character unit and its nearby units; Based on the obstacle avoidance direction of the controllable character unit and the obtained movement direction of each unit, the obstacle avoidance parameters of the controllable character unit for avoiding blocking obstacles are modified. 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 path-finding device for a controllable character, characterized in that: include: a determination module adapted to determine a target unit in the game scene that is about to interact with the controllable character unit, and obtain a position of the target unit; An updating module, adapted to update the path destination of the controllable character unit in real time according to the position of the target unit; An avoidance module adapted to update the movement path of the controllable character unit based on the updated path destination of the controllable character unit, so that the updated movement path avoids blocking obstacles; The target units include other controllable character units or cluster units; wherein the controllable character units are game characters controlled by the player, and the cluster units are units in the non-player controlled character group; an adjustment module adapted to update the movement path of the controllable character unit based on the updated path destination of the controllable character unit by the avoidance module, so that the updated movement path avoids the obstruction, and then interact with the target unit after the controllable character unit moves to the corresponding path destination according to the updated movement path; and if it is detected during the interaction that the distance between the controllable character unit and the target unit is less than a preset distance, adjust the position of the controllable character unit to a specified distance from the position of the target unit; The setting module is suitable for reducing the collision radius of the target unit 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 before the adjustment module adjusts the position of the controllable character unit to a specified distance from the position of the target unit; after the speed of the controllable character unit returns to the original speed, the collision radius of the target unit interacting with the controllable character unit is restored to the original collision radius; the controllable character unit collides with the target unit and pushes the target unit away.
9. A computer storage medium storing a computer program code, wherein when the computer program code is executed on a computing device, the computing device is caused to execute the path-finding method for a controllable character 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 path-finding method for a controllable character according to any one of claims 1 to 7.
Citation Information
Patent Citations
Path finding method for game role
CN104784932A
Game control method and device, electronic equipment and storage medium
CN112807681A
Method and system of moving character in online game
US20170056773A1