Path finding method, device and equipment for flight unit in game and storage medium

By dividing the three-dimensional game scene into multiple connected areas and performing voxel data processing and path planning within the target connected areas, the problem of time-consuming pathfinding in existing technologies is solved, and efficient flying unit pathfinding is achieved.

CN120661924APending Publication Date: 2025-09-19DUOYI NETWORK CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510987543.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-17
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

The existing pathfinding method for flying units in 3D games requires converting all 3D models loaded on the current page into a navigation mesh and using a path search algorithm based on this, which results in a time-consuming and inefficient pathfinding process.

Method used

The three-dimensional game scene is divided into multiple connected areas. By judging whether the starting point and the end point belong to the same target connected area, the voxelized data in the target connected area is obtained. Path planning is performed based on the voxelized data, and the JPS3D algorithm is used to determine the optimal path.

Benefits of technology

It shortens the pathfinding time, improves the pathfinding efficiency, and enhances the game's responsiveness and player experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120661924A_ABST
    Figure CN120661924A_ABST
Patent Text Reader

Abstract

The invention discloses a way-finding method, device and equipment for a flight unit in a game and a storage medium. In response to the way-finding instruction, determining a starting point of the flight unit in the three-dimensional game scene and an end point to be reached, and judging whether the starting point and the end point belong to the same target connected region, the three-dimensional game scene is divided into a plurality of connected regions, different connected regions are mutually isolated, the target connected region is one of the plurality of connected regions, and the target connected region is one of the plurality of connected regions; and if the starting point and the terminal point belong to the same target connected region, voxelization data of the three-dimensional game scene in the target connected region is acquired, path planning is performed based on the voxelization data in the target connected region, and an optimal path from the starting point to the terminal point is determined. According to the method and the device, the path planning only needs to be performed based on the voxelization data of the three-dimensional game scene in the target connected region, and the voxelization data of the three-dimensional game scene in the target connected region is voxelized in advance, so that the path finding time can be shortened, and the path finding efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to technology, and in particular to a method, device, equipment and storage medium for finding a path for a flying unit in a game. Background Art

[0002] In 3D games, it's often necessary to control a flying unit's movement from a starting point to a destination. After the player selects a destination, the game program must respond by performing pathfinding using the unit's current location as the starting point, finding the optimal path, and controlling the unit's spontaneous movement toward the destination.

[0003] In a 3D game world, pathfinding for flying units is a complex problem. Existing solutions typically convert the 3D model of the virtual world into a navigation mesh in the world coordinate system, and then use a path search algorithm to search for a path from the starting point to the end point on the navigation mesh.

[0004] The existing pathfinding solution requires converting all 3D models loaded on the current page into a navigation mesh and using a path search algorithm based on this. The pathfinding process is time-consuming and inefficient. Summary of the Invention

[0005] The present invention provides a flying unit pathfinding method, device, equipment and storage medium in a game, so as to shorten the pathfinding time and improve the pathfinding efficiency.

[0006] In a first aspect, the present invention provides a method for pathfinding a flying unit in a game, comprising:

[0007] In response to the pathfinding instruction, determine the starting point of the flying unit in the three-dimensional game scene and the destination to be reached;

[0008] Determining whether the starting point and the end point belong to the same target connected area, wherein the three-dimensional game scene is divided into multiple connected areas, different connected areas are isolated from each other, and the target connected area is one of the multiple connected areas;

[0009] If the starting point and the end point belong to the same target connected area, obtaining voxel data of the three-dimensional game scene in the target connected area;

[0010] Path planning is performed based on the voxelized data within the target connected area to determine an optimal path from the starting point to the end point.

[0011] Optionally, before determining whether the starting point and the end point belong to the same target connected area, the method further includes:

[0012] Acquire all spawning points in the three-dimensional game scene, where the spawning points are pre-set location points for spawning flying units;

[0013] Grouping all the generating points based on the distances between the generating points to obtain a plurality of generating point groups;

[0014] For each of the spawn point groups, generating a clipping box in the three-dimensional game scene that includes all spawn points in the spawn point group;

[0015] Using a convex polygon overlap algorithm, determining the clipping boxes that overlap in space;

[0016] An area enclosed by a plurality of the cutting boxes that overlap in space is regarded as a connected area.

[0017] Optionally, before determining whether the starting point and the end point belong to the same target connected area, the method further includes:

[0018] For each of the connected regions, calculating an axis-aligned bounding box that encloses the connected region;

[0019] Performing voxel processing on the three-dimensional game scene within the axis-aligned bounding box to obtain voxelized data of the three-dimensional game scene within the axis-aligned bounding box;

[0020] A spatial index algorithm is used to convert all position points in the three-dimensional game scene into a spatial index data structure, wherein the spatial index data structure includes a correspondence between the position points in the three-dimensional game scene and the axis-aligned bounding boxes to which the position points belong.

[0021] Optionally, determining whether the starting point and the end point belong to the same target connected area includes:

[0022] Based on the position coordinates of the starting point, determining the axis-aligned bounding box to which the starting point belongs from the spatial index data structure using a spatial index algorithm;

[0023] Based on the position coordinates of the end point, determining the axis-aligned bounding box to which the end point belongs from the spatial index data structure using a spatial index algorithm;

[0024] Determining whether the starting point and the end point belong to the same axis-aligned bounding box;

[0025] If so, it is determined that the starting point and the end point belong to the same target connected area;

[0026] If not, it is determined that the starting point and the end point do not belong to the same target connected area.

[0027] Optionally, the flying unit pathfinding method in the game also includes:

[0028] If the starting point and the end point do not belong to the same target connected area, the path finding is terminated and a prompt message indicating that the path finding has failed is returned.

[0029] Optionally, the flying unit pathfinding method in the game also includes:

[0030] If the starting point or the end point does not belong to any of the connected areas, the path finding is terminated and a prompt message indicating path finding failure is returned; and,

[0031] If the starting point or the end point is located inside a closed three-dimensional model, pathfinding is terminated and a prompt message indicating pathfinding failure is returned.

[0032] Optionally, the flying unit pathfinding method in the game also includes:

[0033] After determining an optimal path from the starting point to the end point, controlling the flying unit to move along the optimal path;

[0034] During the movement of the flying unit, the moving paths and moving speeds of other flying units are obtained, and combined with the moving paths and moving speeds of other flying units, a dynamic obstacle avoidance algorithm is used to dynamically adjust the moving speed and direction of the flying unit.

[0035] In a second aspect, the present invention further provides a flying unit pathfinding device in a game, comprising:

[0036] The command response module is used to respond to the pathfinding command and determine the starting point and the destination of the flying unit in the three-dimensional game scene;

[0037] a determination module, configured to determine whether the starting point and the end point belong to the same target connected area, wherein the three-dimensional game scene is divided into a plurality of connected areas, different connected areas are isolated from each other, and the target connected area is one of the plurality of connected areas;

[0038] A voxelized data acquisition module, configured to acquire voxelized data of the three-dimensional game scene within the target connected area when the starting point and the end point belong to the same target connected area;

[0039] A path planning module is used to perform path planning based on the voxelized data in the target connected area to determine the optimal path from the starting point to the end point.

[0040] In a third aspect, the present invention further provides an electronic device, comprising:

[0041] one or more processors;

[0042] a storage device for storing one or more programs;

[0043] When the one or more programs are executed by the one or more processors, the one or more processors implement the flying unit pathfinding method in the game as provided in the first aspect of the present invention.

[0044] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the flying unit pathfinding method in the game provided in the first aspect of the present invention.

[0045] The present invention provides a method for finding a path for a flying unit in a game. In response to a pathfinding instruction, the method determines the starting point of the flying unit in a three-dimensional game scene and the destination to be reached, and determines whether the starting point and the destination belong to the same target connected area. The three-dimensional game scene is divided into multiple connected areas, different connected areas are isolated from each other, and the target connected area is one of the multiple connected areas. If the starting point and the destination belong to the same target connected area, voxelized data of the three-dimensional game scene in the target connected area is obtained, and path planning is performed based on the voxelized data in the target connected area to determine the optimal path from the starting point to the destination. The present invention divides the three-dimensional game scene into multiple connected areas, different connected areas are isolated from each other, and when it is determined that the starting point and the destination belong to the same target connected area, voxelized data of the three-dimensional game scene in the target connected area is obtained and path planning is performed. Since path planning only needs to be performed based on the voxelized data of the three-dimensional game scene in the target connected area, and the voxelized data of the three-dimensional game scene in the target connected area is pre-voxelized, the pathfinding time can be shortened and the pathfinding efficiency can be improved.

[0046] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0048] Figure 1 A flowchart of a flying unit pathfinding method in a game provided by the present invention;

[0049] Figure 2 A schematic diagram of a cutting box provided by the present invention;

[0050] Figure 3 A schematic diagram of a voxelization process provided by the present invention;

[0051] Figure 4 A schematic structural diagram of a flying unit path-finding device in a game provided by the present invention;

[0052] Figure 5 A schematic structural diagram of an electronic device provided by an embodiment of the present invention.

[0053] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION

[0054] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0055] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0056] Figure 1 This is a flow chart of a method for finding a path for a flying unit in a game provided by the present invention. This embodiment is applicable to fast path finding for a flying unit in a three-dimensional game scene. The method can be executed by a path finding device for a flying unit in a game provided by the present invention. The device can be implemented by software and / or hardware and is usually configured in an electronic device, which can be a user terminal or a game server, such as Figure 1 As shown in the figure, the flying unit pathfinding method in this game includes the following steps:

[0057] S101. In response to a pathfinding instruction, determine a starting point of a flying unit in a three-dimensional game scene and a destination to be reached.

[0058] In an embodiment of the present invention, a user terminal displays a three-dimensional game scene screen, and the user terminal has an interactive channel (for example, a touch screen, a mouse, a keyboard, etc.), and the user can interact with the user terminal through the interactive channel, thereby generating a path-finding instruction. For example, a user can click on a destination (end point) through a mouse or a touch screen, thereby generating a path-finding instruction. An electronic device (which can be the user terminal itself or a game server) determines the starting point of a flying unit in a three-dimensional game scene and the end point to be reached in response to the path-finding instruction. The flying unit may include characters, wild monsters, vehicles, etc. in the game scene, and the present invention is not limited thereto. For example, the starting point and the end point can be represented by coordinates in the world coordinate system of the three-dimensional game scene. The game data of the three-dimensional game scene can be loaded and displayed directly by the user terminal, or loaded by the game server. The user terminal is only responsible for display and interaction, and the embodiment of the present invention is not limited thereto.

[0059] S102: Determine whether the starting point and the end point belong to the same target connected area.

[0060] In the embodiment of the present invention, the three-dimensional game scene is divided into multiple connected areas, and different connected areas are isolated from each other. Flying units can move within a connected area, but cannot move from one connected area to another.

[0061] In an embodiment of the present invention, it is determined whether the starting point and the end point belong to the same target connected area, wherein the target connected area is one of multiple connected areas. Exemplarily, in some embodiments of the present invention, it is possible to determine whether the starting point and the end point belong to the same target connected area based on the coordinates of the starting point and the end point in the world coordinate system of the game scene. For example, the boundary equation of each connected area can be fitted. Based on the relationship between the starting point and the end point and the boundary equation, it can be determined whether the starting point and the end point are within the connected area, thereby determining the connected area to which the starting point belongs and the connected area to which the end point belongs, and determining whether the starting point and the end point belong to the same connected area.

[0062] In an embodiment of the present invention, a three-dimensional game scene can be pre-divided into multiple connected regions. In some embodiments of the present invention, the connected region division process can be executed during the game development process and can be directly called from the background during the game. In other embodiments of the present invention, the connected region division process can also be performed during real-time game play, after responding to a pathfinding instruction and before determining whether the starting point and the end point belong to the same target connected region. The present invention is not limited to this.

[0063] In some embodiments of the present invention, the connected region division process is as follows:

[0064] 1. Get all the spawn points in the 3D game scene. Spawn points are pre-set locations for spawning flying units.

[0065] In an embodiment of the present invention, all generation points in the three-dimensional game scene are obtained. The generation points are pre-set location points for generating flying units. The generated flying units will appear at the location of the generation points in the three-dimensional game scene.

[0066] 2. Based on the distance between the generation points, all the generation points are grouped to obtain multiple generation point groups.

[0067] Exemplarily, clustering may be performed based on the distance between the generation points to determine the cluster center, and the generation points whose distance from the cluster center is less than a preset distance are grouped as a generation point group.

[0068] 3. For each spawn point group, generate a clipping box in the 3D game scene that includes all spawn points in the spawn point group.

[0069] Exemplarily, after grouping the spawn points, for each spawn point group, a clipping box is generated in the three-dimensional game scene that includes all spawn points in the spawn point group. Thus, multiple clipping boxes are obtained, and each clipping box is the traversable area. Exemplarily, the clipping box can be a convex polygonal cylinder defined by a number of points on a two-dimensional plane and a height range (hmin, hmax). Figure 2 A schematic diagram of a cutting box provided by the present invention, such as Figure 2 As shown, taking the flying unit as an example, the generation point is located above the building model, and the generated clipping box ( Figure 2 The convex polygonal cylinder (shown in wireframe) may include part of the building model, and the clipping box is the passable area.

[0070] 3. Use the convex polygon overlap algorithm to determine the clipping boxes that overlap in space.

[0071] In an embodiment of the present invention, a convex polygon overlap algorithm is used to determine spatially overlapping clipping boxes. The overlap of two clipping boxes indicates that the areas corresponding to the two clipping boxes are connected, and flying units can move from one clipping box to the other. For example, in some embodiments of the present invention, the Sutherland-Hodgman clipping algorithm can be used to select a polygon as the clipping area and another polygon as the clipped object. The polygon vertices of the clipped object are clipped, and the vertices outside the clipping area are removed. This process is repeated until all vertices are processed to form a new polygon.

[0072] 4. The area enclosed by multiple spatially overlapping cutting boxes is regarded as a connected area.

[0073] Using the convex polygon overlap algorithm, we calculate spatially overlapping (interconnected) clipping boxes and define the area enclosed by these interconnected clipping boxes as a connected region. This allows us to divide the empty areas of a 3D game scene (i.e., areas without 3D models) into multiple connected regions, with each region being isolated from the others.

[0074] In some embodiments of the present invention, to more quickly determine the connected regions where the starting and ending points are located, an axis-aligned bounding box (AABB) enclosing the connected region can be pre-calculated for each connected region. Axis-aligned bounding boxes are a bounding box technique used in computer graphics and geometry processing to quickly estimate the spatial extent of an object. Their edges are always parallel to the coordinate axes and are widely used in fields such as collision detection, accelerated rendering, and spatial partitioning. The connected region is defined by the minimum and maximum values ​​of each axis in a three-dimensional world coordinate system, forming a minimum cuboid with sides parallel to the coordinate axes that encloses the connected region.

[0075] After determining the axis-aligned bounding box enclosing the connected region, the 3D game scene within the axis-aligned bounding box is voxelized to obtain voxelized data of the 3D game scene within the axis-aligned bounding box. Voxelization is the process of converting a 3D object or scene into a voxel representation. A voxel is the basic unit in 3D space, similar to a pixel in a 2D image. Each voxel can represent a specific volume, typically a cube. Figure 3 A schematic diagram of voxelization processing provided by the present invention is shown in FIG. Figure 3 As shown, after the building model is voxelized, it is transformed into a cube composed of many minimum units. It should be noted that in the actual processing process, not only the three-dimensional model is voxelized, but also other elements in the game scene need to be voxelized. In an embodiment of the present invention, in order to facilitate path finding later, each voxel can be marked. For example, if the voxel overlaps with the three-dimensional model, it is marked as "0", indicating that it is impassable. If the voxel does not overlap with the three-dimensional model, it is marked as "1", indicating that it is passable.

[0076] Furthermore, to improve subsequent pathfinding efficiency, a spatial index algorithm is used to convert all points in the three-dimensional game scene into a spatial index data structure. The spatial index data structure includes the correspondence between the points in the three-dimensional game scene and the axis-aligned bounding boxes to which they belong. A spatial index data structure is a data structure that is arranged in a certain order based on the position and shape of spatial objects or certain spatial relationships between spatial objects. It contains summary information of the spatial objects, such as the object's identity, circumscribed rectangle, and a pointer to the spatial object entity. For example, in some embodiments of the present invention, an R-Tree (Region Tree) algorithm can be used to convert all points in the three-dimensional game scene into a spatial index data structure. An R-Tree is a spatial index data structure specifically designed for efficiently storing and querying multidimensional spatial data. An R-Tree consists of nodes, each of which can contain multiple entries, which are either pointers to child nodes (internal nodes) or pointers to actual spatial objects (leaf nodes). R-Tree nodes typically do not have direct bidirectional linked lists. The structure of an R-Tree is primarily based on hierarchical relationships, rather than direct links between nodes.

[0077] The above step S102, determining whether the starting point and the end point belong to the same target connected area, includes the following sub-steps:

[0078] S1021. Based on the position coordinates of the starting point, a spatial index algorithm is used to determine the axis-aligned bounding box to which the starting point belongs from the spatial index data structure.

[0079] In an embodiment of the present invention, as described above, the spatial index data structure includes a correspondence between a location point in a 3D game scene and the axis-aligned bounding box to which the location point belongs. Therefore, the starting point's coordinates can be used as the index starting position, and a spatial index algorithm can be used to determine the axis-aligned bounding box to which the starting point belongs from the spatial index data structure.

[0080] S1022: Based on the position coordinates of the end point, determine the axis-aligned bounding box to which the end point belongs from the spatial index data structure using a spatial index algorithm.

[0081] Similarly, the position coordinates of the end point can be used as the index starting position, and the spatial index algorithm can be used to determine the axis-aligned bounding box to which the end point belongs from the spatial index data structure.

[0082] S1023: Determine whether the start point and the end point belong to the same axis-aligned bounding box.

[0083] For example, a unique identifier may be set for each axis-aligned bounding box, and by comparing the unique identifiers of the axis-aligned bounding box where the start point is located with the axis-aligned bounding box where the end point is located, it is determined whether the start point and the end point belong to the same axis-aligned bounding box. For example, if the unique identifiers of the axis-aligned bounding box where the start point is located and the axis-aligned bounding box where the end point is located are consistent, it indicates that the start point and the end point belong to the same axis-aligned bounding box; if the unique identifiers of the axis-aligned bounding box where the start point is located and the axis-aligned bounding box where the end point is located are inconsistent, it indicates that the start point and the end point do not belong to the same axis-aligned bounding box.

[0084] S1024: If yes, determine whether the starting point and the end point belong to the same target connected area.

[0085] If the start point and the end point belong to the same axis-aligned bounding box, determine whether the start point and the end point belong to the same target connected area.

[0086] S1025: If not, determine that the starting point and the end point do not belong to the same target connected area.

[0087] If the start point and the end point do not belong to the same axis-aligned bounding box, it is determined that the start point and the end point do not belong to the same target connected area.

[0088] S103: Acquire voxelized data of the three-dimensional game scene within the target connected area.

[0089] In an embodiment of the present invention, if the starting point and the end point belong to the same target connected area, it means that the end point can be reached from the starting point, and then voxelized data of the three-dimensional game scene in the target connected area is obtained. It should be noted that, as mentioned above, in an embodiment of the present invention, the voxelized data is processed by a spatial index algorithm. Therefore, the voxelized data obtained here is voxelized data in the form of a spatial index data structure. In an embodiment of the present invention, the voxelized data is pre-formed and stored in the game server backend. During the game, when the voxelized data is needed, it only needs to be retrieved from the game server backend. In this way, the game response speed can be improved, thereby improving the player's gaming experience.

[0090] S104: Perform path planning based on the voxelized data in the target connected area to determine the optimal path from the start point to the end point.

[0091] After obtaining the voxelized data within the target connected area, path planning is performed based on the voxelized data within the target connected area to determine the optimal path from the starting point to the end point. Exemplarily, in an embodiment of the present invention, the JPS3D algorithm can be used as a path planning algorithm, and the voxels in the voxelized data within the target connected area are used as nodes of the path planning algorithm to perform path planning and determine the optimal path from the starting point to the end point. Among them, the JPS3D algorithm is an extension of the Jump Point Search (JPS) algorithm in three-dimensional space. The JPS algorithm is an optimization algorithm for path planning, which is particularly suitable for shortest path search in a grid environment. It speeds up the search process by skipping obviously unnecessary checkpoints, thereby significantly improving efficiency. Compared with the traditional A* algorithm, the JPS3D algorithm can significantly reduce memory consumption and computing time when processing large-scale maps.

[0092] The optimal path is typically represented in the game server backend as a list of three-dimensional coordinates, with each coordinate corresponding to the position of a voxel in world coordinates. For example, in some embodiments of the present invention, the optimal path can also be displayed on the user terminal interface for easier viewing and enhanced gaming experience.

[0093] S105: End the pathfinding process and return a prompt indicating that the pathfinding process failed.

[0094] In the above step S102, if the starting point and the end point do not belong to the same target connected area, the path finding is terminated and a prompt message indicating that the path finding has failed is returned to the user terminal.

[0095] In some embodiments of the present invention, if the starting point or the end point does not belong to any connected area, the pathfinding process ends and a message indicating pathfinding failure is returned. For example, if a running error causes a moving object to be generated at a location that does not belong to any connected area, or if the end point selected by the user does not belong to any connected area, the pathfinding process ends and a message indicating pathfinding failure is returned to the user terminal.

[0096] In some embodiments of the present invention, if the starting point or the end point is located within a closed three-dimensional model, pathfinding is terminated and a pathfinding failure prompt is returned. For example, if a mobile object is generated within a closed three-dimensional model due to a runtime error, or if the end point selected by the user is located within a closed three-dimensional model, pathfinding is terminated and a pathfinding failure prompt is returned to the user terminal.

[0097] In some embodiments of the present invention, after determining the optimal path from the starting point to the end point, the flying unit is controlled to move along the optimal path. During the movement of the flying unit, the moving paths and moving speeds of other flying units are obtained, and combined with the moving paths and moving speeds of other flying units, a dynamic obstacle avoidance algorithm is used to dynamically adjust the moving speed and direction of the flying unit to avoid collisions between flying units and achieve natural dispersion of the flying units during movement. Exemplarily, in some embodiments of the present invention, the RVO2 (Reciprocal Velocity Obstacles 2) algorithm can be used for dynamic obstacle avoidance. RVO2 is an algorithm for predicting and avoiding collisions. By considering the relative speed and position of other units, it dynamically adjusts its own speed and direction to avoid collisions.

[0098] The present invention provides a method for finding a path for a flying unit in a game. In response to a pathfinding instruction, the method determines the starting point of the flying unit in a three-dimensional game scene and the destination to be reached, and determines whether the starting point and the destination belong to the same target connected area. The three-dimensional game scene is divided into multiple connected areas, different connected areas are isolated from each other, and the target connected area is one of the multiple connected areas. If the starting point and the destination belong to the same target connected area, voxelized data of the three-dimensional game scene in the target connected area is obtained, and path planning is performed based on the voxelized data in the target connected area to determine the optimal path from the starting point to the destination. The present invention divides the three-dimensional game scene into multiple connected areas, different connected areas are isolated from each other, and when it is determined that the starting point and the destination belong to the same target connected area, voxelized data of the three-dimensional game scene in the target connected area is obtained and path planning is performed. Since path planning only needs to be performed based on the voxelized data of the three-dimensional game scene in the target connected area, and the voxelized data of the three-dimensional game scene in the target connected area is pre-voxelized, the pathfinding time can be shortened and the pathfinding efficiency can be improved.

[0099] Figure 4 This is a schematic diagram of the structure of a flying unit pathfinding device in a game provided by the present invention. Figure 4 As shown, the flying unit pathfinding device in the game includes:

[0100] The command response module 201 is used to respond to the path-finding command and determine the starting point and the destination of the flying unit in the three-dimensional game scene;

[0101] a determination module 202 for determining whether the starting point and the end point belong to the same target connected area, wherein the three-dimensional game scene is divided into a plurality of connected areas, different connected areas are isolated from each other, and the target connected area is one of the plurality of connected areas;

[0102] A voxelized data acquisition module 203 is configured to acquire voxelized data of the three-dimensional game scene within the target connected area when the starting point and the end point belong to the same target connected area;

[0103] The path planning module 204 is configured to perform path planning based on the voxelized data within the target connected area, and determine an optimal path from the starting point to the end point.

[0104] In some embodiments of the present invention, the flying unit path-finding device in the game further includes:

[0105] A spawn point acquisition module, configured to acquire all spawn points in the three-dimensional game scene, wherein the spawn points are pre-set location points for spawning flying units;

[0106] a grouping module, configured to group all the generating points based on the distances between the generating points to obtain a plurality of generating point groups;

[0107] A clipping box generation module, configured to generate, for each of the spawn point groups, a clipping box in the three-dimensional game scene that includes all spawn points in the spawn point group;

[0108] An overlapping algorithm module, configured to determine the clipping boxes that overlap in space by using a convex polygon overlapping algorithm;

[0109] The connected region determining module is configured to define a region enclosed by a plurality of spatially overlapping cutting boxes as a connected region.

[0110] In some embodiments of the present invention, the flying unit path-finding device in the game further includes:

[0111] a bounding box determination module, configured to calculate, for each connected area, an axis-aligned bounding box that encloses the connected area before determining whether the start point and the end point belong to the same target connected area;

[0112] a voxelization processing module, configured to perform voxelization processing on the three-dimensional game scene within the axis-aligned bounding box to obtain voxelized data of the three-dimensional game scene within the axis-aligned bounding box;

[0113] An indexing algorithm module is used to convert all position points in the three-dimensional game scene into a spatial index data structure using a spatial indexing algorithm, wherein the spatial indexing data structure includes a correspondence between the position points in the three-dimensional game scene and the axis-aligned bounding boxes to which the position points belong.

[0114] In some embodiments of the present invention, the determination module 202 includes:

[0115] A first indexing submodule is configured to determine, based on the position coordinates of the starting point, an axis-aligned bounding box to which the starting point belongs from the spatial index data structure using a spatial indexing algorithm;

[0116] a second indexing submodule, configured to determine, based on the position coordinates of the endpoint, an axis-aligned bounding box to which the endpoint belongs from the spatial index data structure using a spatial indexing algorithm;

[0117] A judging submodule, configured to judge whether the starting point and the end point belong to the same axis-aligned bounding box;

[0118] a first determination submodule, configured to determine that the starting point and the end point belong to the same target connected area when the starting point and the end point belong to the same axis-aligned bounding box;

[0119] The first determination submodule is configured to determine that the starting point and the end point do not belong to the same target connected area when the starting point and the end point do not belong to the same axis-aligned bounding box.

[0120] In some embodiments of the present invention, the flying unit path-finding device in the game further includes:

[0121] The first ending module is used to end the path finding when the starting point and the end point do not belong to the same target connected area, and return a prompt message indicating that the path finding has failed.

[0122] In some embodiments of the present invention, the flying unit path-finding device in the game further includes:

[0123] A second ending module is configured to end the pathfinding when the starting point or the end point does not belong to any of the connected areas, and return a prompt message indicating that the pathfinding has failed; and

[0124] The third ending module is used to end the path finding when the starting point or the end point is located inside the closed three-dimensional model, and return a prompt message indicating that the path finding has failed.

[0125] In some embodiments of the present invention, the flying unit path-finding device in the game further includes:

[0126] a movement control module, configured to control the flight unit to move along the optimal path after determining the optimal path from the starting point to the end point;

[0127] The dynamic obstacle avoidance module is used to obtain the moving paths and moving speeds of other flying units during the movement of the flying unit, and adopt a dynamic obstacle avoidance algorithm in combination with the moving paths and moving speeds of other flying units to dynamically adjust the moving speed and direction of the flying unit.

[0128] The flying unit pathfinding device in the above-mentioned game can execute the flying unit pathfinding method in the game provided by the aforementioned embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the flying unit pathfinding method in the game.

[0129] Figure 5 A schematic diagram of the structure of an electronic device provided for an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0130] like Figure 5 As shown, the electronic device includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0131] Multiple components in the electronic device are connected to the I / O interface 15, including an input unit 16, such as a keyboard, mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, optical disk, etc.; and a communication unit 19, such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0132] The processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the pathfinding method for flying units in the game.

[0133] In some embodiments, the in-game flying unit pathfinding method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the in-game flying unit pathfinding method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to execute the in-game flying unit pathfinding method in any other appropriate manner (e.g., by means of firmware).

[0134] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0135] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0136] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0137] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0138] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0139] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.

[0140] An embodiment of the present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the flying unit pathfinding method in the game provided in any embodiment of the present application.

[0141] The computer program product may be implemented by writing computer program code for performing the operations of the present invention in one or more programming languages, or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0142] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.

[0143] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A method for finding a path for a flying unit in a game, characterized in that: include: In response to the pathfinding instruction, determine the starting point of the flying unit in the three-dimensional game scene and the destination to be reached; Determining whether the starting point and the end point belong to the same target connected area, wherein the three-dimensional game scene is divided into multiple connected areas, different connected areas are isolated from each other, and the target connected area is one of the multiple connected areas; If the starting point and the end point belong to the same target connected area, obtaining voxel data of the three-dimensional game scene in the target connected area; Path planning is performed based on the voxelized data within the target connected area to determine an optimal path from the starting point to the end point.

2. The flying unit pathfinding method in the game according to claim 1, characterized in that: Before determining whether the starting point and the end point belong to the same target connected area, the method further includes: Acquire all spawning points in the three-dimensional game scene, where the spawning points are pre-set location points for spawning flying units; Grouping all the generating points based on the distances between the generating points to obtain a plurality of generating point groups; For each of the spawn point groups, generating a clipping box in the three-dimensional game scene that includes all spawn points in the spawn point group; Using a convex polygon overlap algorithm, determining the clipping boxes that overlap in space; An area enclosed by a plurality of the cutting boxes that overlap in space is regarded as a connected area.

3. The flying unit pathfinding method in the game according to claim 1 or 2, characterized in that: Before determining whether the starting point and the end point belong to the same target connected area, the method further includes: For each of the connected regions, calculating an axis-aligned bounding box that encloses the connected region; Performing voxel processing on the three-dimensional game scene within the axis-aligned bounding box to obtain voxelized data of the three-dimensional game scene within the axis-aligned bounding box; A spatial index algorithm is used to convert all position points in the three-dimensional game scene into a spatial index data structure, wherein the spatial index data structure includes a correspondence between the position points in the three-dimensional game scene and the axis-aligned bounding boxes to which the position points belong.

4. The flying unit pathfinding method in the game according to claim 3, characterized in that: Determining whether the starting point and the end point belong to the same target connected area includes: Based on the position coordinates of the starting point, determining the axis-aligned bounding box to which the starting point belongs from the spatial index data structure using a spatial index algorithm; Based on the position coordinates of the end point, determining the axis-aligned bounding box to which the end point belongs from the spatial index data structure using a spatial index algorithm; Determining whether the starting point and the end point belong to the same axis-aligned bounding box; If so, it is determined that the starting point and the end point belong to the same target connected area; If not, it is determined that the starting point and the end point do not belong to the same target connected area.

5. The flying unit pathfinding method in a game according to claim 1 or 2, characterized in that: Also includes: If the starting point and the end point do not belong to the same target connected area, the path finding is terminated and a prompt message indicating that the path finding has failed is returned.

6. The flying unit pathfinding method in a game according to claim 1 or 2, characterized in that: Also includes: If the starting point or the end point does not belong to any of the connected areas, the path finding is terminated and a prompt message indicating path finding failure is returned; as well as, If the starting point or the end point is located inside a closed three-dimensional model, pathfinding is terminated and a prompt message indicating pathfinding failure is returned.

7. The flying unit pathfinding method in a game according to claim 1 or 2, characterized in that: Also includes: After determining an optimal path from the starting point to the end point, controlling the flying unit to move along the optimal path; During the movement of the flying unit, the moving paths and moving speeds of other flying units are obtained, and combined with the moving paths and moving speeds of other flying units, a dynamic obstacle avoidance algorithm is used to dynamically adjust the moving speed and direction of the flying unit.

8. A flying unit pathfinding device in a game, characterized in that: include: The command response module is used to respond to the pathfinding command and determine the starting point and the destination of the flying unit in the three-dimensional game scene; a determination module, configured to determine whether the starting point and the end point belong to the same target connected area, wherein the three-dimensional game scene is divided into a plurality of connected areas, different connected areas are isolated from each other, and the target connected area is one of the plurality of connected areas; A voxelized data acquisition module, configured to acquire voxelized data of the three-dimensional game scene within the target connected area when the starting point and the end point belong to the same target connected area; A path planning module is used to perform path planning based on the voxelized data in the target connected area to determine the optimal path from the starting point to the end point.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the flying unit pathfinding method in the game as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the flying unit pathfinding method in the game as described in any one of claims 1-7 is implemented.

Citation Information

Cited By

  • Entity aggregation control method and device, equipment and medium

    CN121266126A