Navigation method and electronic device for virtual objects in games

Through quad-tree meshing and A* search algorithm, the problem of inefficient virtual object pathfinding in open game scenes is solved, achieving more efficient navigation path calculation and better user experience.

CN112370788BActive Publication Date: 2024-11-19NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011258658.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-11
Publication Date
2024-11-19
Estimated Expiration
2040-11-11

AI Technical Summary

Technical Problem

The pathfinding method for virtual objects in existing game scenarios is inefficient in open game scenarios, especially due to the randomness of obstacles and the vast walkable areas, resulting in waste of computing resources and reduced accuracy.

Method used

The quad-tree meshing method is used to mesh the obstacle area and the walkable area of ​​the game scene, and the navigation path is determined through the A* search algorithm to ensure the precise positioning of the obstacle area and the optimization of the path.

Benefits of technology

It effectively alleviates the consumption of storage space by the vast walkable area, improves the precise positioning of obstacle areas and the navigation accuracy of virtual objects, and improves the user experience in the game.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112370788B_ABST
    Figure CN112370788B_ABST
Patent Text Reader

Abstract

The present invention provides a navigation method and electronic device for virtual objects in a game, the method comprising: responding to a target point setting operation for a virtual object in a game scene, determining the starting point and end point corresponding to the virtual object; starting from the node where the starting point is located, executing a pathfinding algorithm on the grid nodes of the walkable area in the game scene to obtain a target node group from the starting point to the end point; determining a navigation path based on the target node group; and controlling the virtual object to move to the end point according to the navigation path. In this method, the grid size of the leaf node in the walkable area is large, which effectively alleviates the problem of large grid storage space consumption corresponding to the vast walkable area. The grid size of the leaf node in the obstacle area is small, which ensures the precise positioning of the obstacle area. The method of determining the path point through the path search operation can ensure that the searched navigation path is more preferred, effectively improving the navigation effect of the virtual object.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of game technology, and in particular to a navigation method and electronic equipment for virtual objects in a game. Background Art

[0002] Pathfinding in games refers to allowing a character to move autonomously from one location in the scene to another along an appropriate path. Generally, the pathfinding algorithm can be divided into two steps: scene map representation and path search. Scene map representation is to abstract the actual game scene into a specific mathematical model to represent the scene structure, obstacle information, and feasible area information; path search is to execute the search algorithm on this mathematical model to obtain the final pathfinding path.

[0003] There are many methods for representing scene maps, including the two-dimensional grid method, the path point method, the navigation mesh method, and so on. The two-dimensional grid method divides the scene into two-dimensional grids of equal size. Each grid can be marked as an obstacle or not. The path finding path is based on grids, bypassing the grids marked as obstacles. The path point method abstracts the scene into a series of path points. The positions and connectivity of these path points can be designed manually, and the characters can move according to the designer's ideas when finding the path. The navigation mesh method (Navmesh) uses a set of convex polygons of different shapes and sizes to represent the entire scene, and uses polygons to cover the walkable area in the scene. Compared with the first two methods, the navigation mesh method is more flexible. For path finding in complex scenes, the navigation mesh method is often the first choice.

[0004] The path search algorithm is a search algorithm based on the scene map. Common algorithms include depth-first search, breadth-first search, Dijkstra algorithm, and A* algorithm.

[0005] There is a type of empty game scene in the game scene. The walkable area in this game scene is much larger than the obstacle area, and the obstacle area changes dynamically, that is, the position of the obstacle is random when the game scene is created. Take the sea game scene as an example. This scene is a vast sea with several islands. The sea area is wide and the positions of the islands are random.

[0006] For pathfinding in this type of empty game scene, due to the randomness of obstacles, it is impossible to prepare the navigation mesh in advance based on the navigation mesh method. In addition, since the walkable area in the empty game scene is very large, the memory overhead of calculating the navigation mesh is large, which affects the computational efficiency of pathfinding. Summary of the invention

[0007] In view of this, an object of the present invention is to provide a navigation method and electronic device for virtual objects in a game to alleviate the above-mentioned problem.

[0008] In the first aspect, an embodiment of the present invention provides a navigation method for a virtual object in a game, wherein a game scene is displayed through an electronic device, and the method comprises: responding to a target point setting operation for a virtual object in the above-mentioned game scene, determining a starting point and an end point corresponding to the virtual object; starting from the node where the starting point is located, executing a path-finding algorithm on the grid nodes in the walkable area in the game scene, and obtaining a target node group from the starting point to the end point, wherein the grid nodes are nodes in a quadtree formed by dividing the game scene according to parameter information of obstacles in the game scene, and the grid size of the leaf nodes in the obstacle area of ​​the game scene is smaller than the grid size of some leaf nodes in the walkable area; determining a navigation path from the starting point to the end point based on the target node group; wherein the navigation path is composed of path points corresponding to the target nodes in the target node group; and controlling the virtual object to move to the end point along the navigation path.

[0009] Among them, the above-mentioned grid nodes are nodes in a quadtree formed by dividing the game scene according to parameter information of the obstacles in the game scene, and are carried out through the following steps: in response to a grid creation operation for the game scene, the obstacle area of ​​the obstacles in the game scene is divided into quadtree grids with a preset maximum grid size as the side length of the root node, until the obstacle area is divided into leaf nodes with a side length equal to the preset minimum grid size.

[0010] Furthermore, in response to a grid creation operation for the game scene, a quadtree grid division is performed on the obstacle area of ​​the obstacle in the game scene with a preset maximum grid size as the side length of the root node, until the obstacle area is divided into leaf nodes with a side length equal to a preset minimum grid size, including: in response to a grid creation operation for the game scene in an initial state, a quadtree grid division is performed on the game scene with a preset maximum grid size as the side length of the root node, until it is divided into a quadtree baseline grid; wherein the game scenes in the initial state are all walkable areas; in response to an obstacle creation operation for the game scene, an obstacle is created in the game scene, and a quadtree grid division is performed on the baseline grid of the obstacle area of ​​the obstacle until it is divided into a leaf node with a side length equal to a preset minimum grid size; wherein the size of the baseline grid is between the preset maximum grid size and the preset minimum grid size.

[0011] Furthermore, the method also includes: checking whether a leaf node whose side length is equal to a preset minimum grid size is in the obstacle area; if so, marking the leaf node as a leaf node in the obstacle area; if not, and none of the leaf node's sibling nodes are in the obstacle area, deleting the leaf node and the leaf node's sibling nodes.

[0012] Furthermore, the step of checking whether a leaf node whose side length is equal to a preset minimum grid size is within the obstacle area comprises: checking whether the center point of a leaf node with a preset minimum grid size is within the obstacle area; if so, determining that the leaf node is within the obstacle area; if not, performing quadtree division on the leaf node to obtain child nodes of the leaf node, and if the center points of all the child nodes of the leaf node are not within the obstacle area, determining that the leaf node is not within the obstacle area; and if the center point of at least one child node of the leaf node is within the obstacle area, determining that the leaf node is within the obstacle area.

[0013] Furthermore, the above-mentioned step of determining the starting point and end point corresponding to the virtual object includes: dividing the node at the current position of the virtual object and the node at the position of the target point set by the target point setting operation into the minimum grid size respectively; determining the leaf node containing the center point of the virtual object as the starting point corresponding to the virtual object; determining the leaf node containing the center point of the target point as the end point corresponding to the virtual object; the method also includes: when determining the navigation path, restoring the node at the current position of the virtual object to the grid node before being divided into the minimum grid size, and restoring the node at the target point to the grid node before being divided into the minimum grid size.

[0014] Furthermore, the above-mentioned path-finding algorithm is an A* search algorithm, which determines the adjacent nodes of the current node in the following manner: based on the quadtree grid nodes of the walkable area in the game scene, search for nodes whose grid size is greater than or equal to the grid size of the current node in the adjacent direction of the current node to obtain a pending node group; use the non-leaf nodes in the pending node group as intermediate nodes, and search for leaf nodes adjacent to the current node from the intermediate nodes; use the searched leaf nodes and nodes in the pending node group except the intermediate nodes as adjacent nodes of the current node.

[0015] Furthermore, the electronic device stores the parent-child relationship of each node; the above-mentioned step of searching for nodes whose grid size is greater than or equal to the grid size of the current node in the neighboring direction of the current node to obtain a pending node group includes: obtaining the parent node of the current node and the orientation information of the current node in the parent node; for each pre-specified neighboring direction, the following operations are performed to determine the pending node: if the direction corresponding to the orientation information is opposite to the neighboring direction, the pending node is determined from the brother nodes of the current node; the grid size of the brother node is equal to the grid size of the current node; if the direction corresponding to the orientation information is the same as the neighboring direction, the adjacent node located in the neighboring direction of the parent node is used as the pending node of the current node; the grid size of the adjacent node is greater than the grid size of the current node; the pending nodes corresponding to each neighboring direction are formed into a pending node group of the current node.

[0016] Furthermore, the above-mentioned step of searching for leaf nodes adjacent to the current node from the intermediate nodes includes: in each pre-specified adjacent direction, according to a preset depth-first traversal principle, recursively traversing the child nodes in the intermediate nodes in the opposite direction to the adjacent direction until all the leaf nodes in the opposite direction to the adjacent direction are traversed; determining the leaf nodes adjacent to the current node from the traversed leaf nodes.

[0017] Furthermore, the step of controlling the virtual object to move to the end point along the navigation path includes: responding to an event in which the virtual object reaches a path point on the navigation path, reading the next path point from the navigation path, using the read path point as the current path point, and performing the following operations: determining the relative relationship between the current path point and the current position of the virtual object; and adjusting the forward direction and forward speed of the virtual object according to the relative relationship so that the virtual object moves toward the current path point.

[0018] Furthermore, the step of determining the relative relationship between the current path point and the current position of the virtual object includes: determining the interval frame number according to the forward speed of the virtual object; correcting the relative relationship between the current path point and the current position of the virtual object according to the determined interval frame number; and adjusting the forward direction and forward speed of the virtual object according to the relative relationship includes: adjusting the forward direction and forward speed of the virtual object according to the corrected relative relationship.

[0019] Furthermore, the method also includes: determining a path point radius based on the forward speed of the virtual object; if the distance between the current position of the virtual object and the current path point is less than or equal to the path point radius, determining that the virtual object has reached the current path point.

[0020] Furthermore, the step of determining the path point radius based on the forward speed of the virtual object includes: calculating the path point radius R=r+k×s, wherein r is a preset basic radius, k is a preset correction coefficient, and s is the forward speed of the virtual object.

[0021] Furthermore, the game scene is an ocean scene, and the virtual object is a virtual ship; the grid size of each node is an integer power of 2.

[0022] In a second aspect, an embodiment of the present invention further provides an electronic device, comprising a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method for navigating virtual objects in a game according to any one of the first aspects.

[0023] In a third aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method for navigating virtual objects in a game according to any one of the first aspects.

[0024] The embodiments of the present invention bring the following beneficial effects:

[0025] The embodiment of the present invention provides a navigation method and electronic device for a virtual object in a game. The method responds to a target point setting operation for a virtual object in a game scene, determines a starting point and an end point corresponding to the virtual object; starts from the node where the starting point is located, executes a path-finding algorithm on the grid nodes of a walkable area in the game scene, and obtains a target node group from the starting point to the end point; determines a navigation path from the starting point to the end point based on the target node group; wherein the navigation path is composed of path points corresponding to the target nodes in the target node group; and controls the virtual object to move to the end point according to the navigation path. In this method, the grid nodes are nodes in a quadtree formed by dividing the game scene according to parameter information of obstacles in the game scene, and the grid size of the leaf nodes in the obstacle area of ​​the game scene is smaller than the grid size of some leaf nodes in the walkable area. This division method in which the grid size of the leaf nodes in the walkable area is larger can effectively alleviate the problem of large grid storage space consumption corresponding to the vast walkable area. At the same time, the division method in which the grid size of the leaf nodes in the obstacle area is smaller can also ensure the precise positioning of the obstacle area, providing a reliable data basis for the path search operation; and, in the path search operation process, a path finding algorithm is executed on the quadtree grid nodes in the walkable area of ​​the game scene to obtain a target node group from the start point to the end point; a method of determining a navigation path based on the target node group can ensure that the searched navigation path is more preferred, effectively improving the navigation effect of the virtual object.

[0026] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description and the drawings.

[0027] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0029] Figure 1 A schematic diagram of a quadtree provided by an embodiment of the present invention;

[0030] Figure 2 A quadtree logic diagram provided by an embodiment of the present invention;

[0031] Figure 3 A flowchart of a method for navigating a virtual object in a game provided by an embodiment of the present invention;

[0032] Figure 4 A schematic diagram of adjacent nodes provided by an embodiment of the present invention;

[0033] Figure 5 A schematic diagram of another adjacent node provided by an embodiment of the present invention;

[0034] Figure 6 A schematic diagram of a parent node provided by an embodiment of the present invention;

[0035] Figure 7 A schematic diagram of a node grid size provided by an embodiment of the present invention;

[0036] Figure 8 A schematic diagram of the effect of a reference grid division provided by an embodiment of the present invention;

[0037] Fig. 9 A schematic diagram of dividing an initial game scene into reference grids provided by an embodiment of the present invention;

[0038] Fig.10 A schematic diagram of the structure of a node provided by an embodiment of the present invention;

[0039] Fig.11 A schematic diagram of a division result of creating obstacles provided by an embodiment of the present invention;

[0040] Fig.12 A flowchart of another method for navigating a virtual object in a game provided by an embodiment of the present invention;

[0041] Fig.13 A schematic diagram of dividing the starting point and end point of a virtual object into the smallest level provided by an embodiment of the present invention;

[0042] Fig.14 A flowchart for searching a north adjacent node provided by an embodiment of the present invention;

[0043] Fig.15 A schematic diagram of a node provided by an embodiment of the present invention;

[0044] Fig.16 A schematic diagram of another node provided by an embodiment of the present invention;

[0045] Fig.17 A flowchart of another method for navigating a virtual object in a game provided by an embodiment of the present invention;

[0046] Fig.18 A schematic diagram of a correction mechanism provided by an embodiment of the present invention;

[0047] Fig.19 A schematic diagram of a result of controlling the movement of a virtual object provided by an embodiment of the present invention;

[0048] Fig. 20 A schematic diagram of an ocean scene provided by an embodiment of the present invention;

[0049] Fig.21 A flowchart of a navigation method for a virtual ship in an ocean scene provided by an embodiment of the present invention;

[0050] Fig. 22 A schematic diagram of a navigation device for a virtual object in a game provided by an embodiment of the present invention;

[0051] Fig.23 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are 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 creative work are within the scope of protection of the present invention.

[0053] Pathfinding is a common requirement in the gaming industry and is widely used in many games, such as monster AI (Artificial Intelligence), player automatic mode, cutscene plots, etc. However, with the development of open world games and the improvement of players' requirements for game content, existing pathfinding methods cannot provide efficient support for large worlds and randomly generated terrain scenes. How to find an efficient method to organize scene information and provide pathfinding results is a problem that the gaming industry is concerned about.

[0054] For example, the game scene is a vast sea area with several islands. The sea area is wide and the positions of the islands are random. This scene has the following characteristics: first, the walkable area is much larger than the obstacle area; second, the obstacle area is dynamically changing, that is, the positions of the obstacles are random when the game scene is created. Therefore, the existing pathfinding methods still have some problems for this game scene, such as inefficient and inflexible scene map representation.

[0055] Specifically, for the above game scene, if the navigation mesh method is used, it is not feasible to prepare the navigation mesh of the entire scene in advance due to the randomness of the island position; although the use of a tile-based navigation mesh (Tile-NavMesh) can solve the problem of random obstacles, the pathfinding mesh covering the entire scene will lead to serious memory waste, and because the obstacles are sparse, many navigation meshes do not contribute to avoiding obstacles, which means a waste of computing resources. If the two-dimensional grid method is used, the size of the two-dimensional grid is difficult to grasp. The smaller the grid size, the more accurate the pathfinding, but the greater the computational overhead; the larger the grid size, the more resources can be saved, but the pathfinding accuracy will be greatly reduced, resulting in a low feasibility of the two-dimensional grid method. If the waypoint method is used, since the artificially arranged waypoints are difficult to fully cover all the possibilities of pathfinding on the vast sea, the feasibility of the waypoint method is extremely low.

[0056] Therefore, for pathfinding in an empty game scene, most existing pathfinding methods have the disadvantages of insufficient support for random obstacles, low computational efficiency, and large resource usage, thereby reducing the user's gaming experience. Based on this, an embodiment of the present invention provides a navigation method, device, and electronic device for virtual objects in a game. The technology can be applied to a variety of game scenes, especially to an empty game scene where the walkable area is much wider than the obstacle area and the obstacle area is dynamically changing.

[0057] To facilitate understanding of this embodiment, a navigation method for virtual objects in a game provided by an embodiment of the present invention is first introduced in detail below. The method can be applied to electronic devices, and a graphical user interface is provided by the electronic device, and the graphical user interface includes at least a game scene and a virtual object; wherein the virtual object may also be referred to as a virtual character or a game character; the game scene is an open game scene, such as an ocean scene with a vast area, random obstacle positions and sparse density, a grassland scene with sparse tree density, and an aerial scene with other fighter obstacles.

[0058] The electronic device controls the movement of the virtual object in the empty game scene; the electronic device may be a mobile phone, a computer, a notebook, a tablet computer, etc.; the graphical user interface is the scene currently being displayed in the game, including the empty game scene, the virtual object, and various obstacles, etc., wherein the various obstacles may be static obstacles, i.e., sparsely populated island obstacles established when the game scene is created, or dynamic obstacles, i.e., the remaining virtual objects that the virtual object encounters and needs to avoid collision when moving in the virtual scene. In actual applications, the electronic device may control the movement of the virtual object in the game scene through the processor in the electronic device, or may control the movement of the virtual object in the game scene through the mobile control in the graphical user interface.

[0059] In addition, the game scene displayed by the electronic device is divided into grids in a quadtree grid division manner, wherein the quadtree is a tree-like data structure commonly used for two-dimensional space division, which is expressed in the form of a grid. Regardless of the size, each grid is a node, such as Figure 1 As shown, each node of the quadtree is a square, and the largest node, that is, the largest grid outside, is called the root node, as shown in Figure 1 The root node A in the image can be further divided into multiple child nodes. When a node is subdivided to have no child nodes, the node is called a leaf node, that is, there are no other squares in the square corresponding to the leaf node, such as Figure 1 In addition, for ease of understanding, Figure 2 In the logic diagram shown, the root node A is the highest node in the logic diagram, and the leaf node A1 is the node without an arrow below it. Obviously, if a large square is divided into four small squares, then the side length of the small square must be half of the large square. Corresponding to the logic diagram, the side length is divided by 2 for each deeper layer.

[0060] For the convenience of explanation, the above game scene is divided into an obstacle area and a walkable area, wherein the walkable area is an area where the electronic device controls the virtual object to move. For example, for an ocean scene, the obstacle area includes all island obstacles at random positions in the ocean scene, and the walkable area is an area where the virtual ship (virtual object) can move to avoid island obstacles. The obstacle area and the walkable area are meshed by a quadtree meshing method, until the leaf nodes of the obstacle area and the leaf nodes of the walkable area are obtained, and the leaf nodes of the walkable area, except for the leaf nodes where the virtual object starts and ends, have a mesh size greater than or equal to the mesh size of the leaf nodes of the obstacle area, so that the large mesh size of the leaf nodes of the walkable area can effectively alleviate the problem of large grid storage space consumption corresponding to the vast walkable area. At the same time, the small mesh size of the leaf nodes of the obstacle area can also ensure the accurate positioning of the obstacle area, providing a reliable data basis for the search operation. In addition, due to the flexible division of the quadtree, it can well support randomly generated obstacles, i.e., dynamic obstacles.

[0061] like Figure 3 The flowchart of the method for navigating virtual objects in the game is shown. The execution subject of the method is an electronic device, and the game scene is displayed by the electronic device. The method includes the following steps:

[0062] Step S302, in response to a target point setting operation for a virtual object in the game scene, determines a starting point and an end point corresponding to the virtual object.

[0063] In actual applications, the user can set the target point of the virtual object in the graphical user interface provided by the electronic device. If the interface is a touch screen, the user can complete the target point setting by pressing; if the interface is a non-touch screen, the user can also complete the target point setting by clicking the mouse and / or keyboard. At this time, the starting point and end point of the virtual object can be determined according to the current position of the virtual object and the set target point. For ease of understanding, an example is given here. For an ocean scene, after the player controls the virtual ship to enter the game scene, at this time, the player can press or click a certain position in the ocean scene, that is, the target point, to determine the starting point and end point of the virtual ship according to the current position and target point of the virtual ship.

[0064] Step S304, starting from the node where the starting point is located, a path-finding algorithm is executed on the grid nodes of the walkable area in the game scene to obtain a target node group from the starting point to the end point.

[0065] Among them, the grid nodes in the embodiment of the present application are nodes in a quadtree formed by dividing the game scene according to the parameter information of the obstacles in the game scene, and the grid size of the leaf nodes in the obstacle area of ​​the game scene is smaller than the grid size of some leaf nodes in the walkable area.

[0066] For the game scene after the quadtree division, after the starting point and the end point of the virtual object are determined, the path search operation is also performed through the preset path finding algorithm, wherein the path finding algorithm can be a k-nearest neighbor algorithm, A* algorithm or breadth-first search algorithm based on the quadtree grid, or an improved algorithm of the corresponding algorithm. Among them, taking the A* algorithm as an example, the conventional A* algorithm mainly simplifies the area to be searched into small squares. For example, in a conventional two-dimensional grid, the grid size is consistent and is often organized in a two-dimensional array. By searching all adjacent grids of the current grid (current node), all reachable nodes of the current node are obtained, and a group of child nodes are generated until the end point is found, and a node group from the starting point to the end point is obtained, such as Figure 4 Schematic diagram of adjacent nodes shown, wherein all adjacent grids of grid A include: grids in eight directions of east (East, E for short), west (W for short), south (S for short), north (N for short), southeast (SE for short), northeast (NE for short), southwest (SW for short) and northwest (NW for short) adjacent to grid A, and the size of each grid is the same as the size of grid A.

[0067] In the embodiment of the present invention, since the game scene is divided into quadtrees, the grid sizes of the nodes adjacent to the current node may be the same or different. Figure 5As shown, for all the adjacent nodes of node A, the grid sizes of the N nodes in the north direction and the E nodes in the east direction are obviously larger than the grid size of node A. Based on the conventional A* algorithm, this embodiment modifies the method of determining the reachable neighbor nodes of the current node to adapt to the game scene after quadtree division. As a possible implementation method, the above-mentioned pathfinding algorithm determines the adjacent nodes of the current node based on the parent-child relationship between the grid nodes in the walkable area in the game scene in the process of determining the adjacent nodes of the current node, so as to achieve that the determined adjacent nodes are leaf nodes as much as possible, so that the storage space occupied by the target node group is small and the navigation path determined based on this target node group is more reasonable.

[0068] Step S306, determining a navigation path from the start point to the end point based on the target node group; wherein the navigation path is composed of path points corresponding to the target nodes in the target node group.

[0069] The above-mentioned target node group is a node list with an order composed of target nodes. Considering that each node corresponds to a grid area with a relatively large area, in the process of determining the navigation path, converting each target node into a point position, i.e., a path point, will be more conducive to accurately representing the navigation path. As a possible implementation method, the center point of the target node can be used as the path point corresponding to the target node. Of course, other points in the target node can also be used as the path point corresponding to the target node, and the embodiment of the present invention does not limit this.

[0070] The navigation paths corresponding to the above-mentioned path points are the ordered connections of these path points, and the specific connection method of the connection can be a straight line connection or a curve fitting method.

[0071] Step S308, controlling the virtual object to move to the end point along the navigation path.

[0072] In actual applications, the movement process of virtual objects such as virtual ships is different from that of characters. Due to water resistance, wind speed and wind force, virtual ships cannot stop suddenly, move quickly or turn quickly. Therefore, when controlling the virtual ship to move along the navigation path, its position and speed can be set instead of directly, and the player or user operation can be simulated. Based on this, command controls for virtual objects can be displayed in the graphical user interface. For example, when the user triggers a turn command, the virtual object is controlled by the processor in the server or electronic device to perform a turn operation; when the user triggers a start command or a stop command, the virtual object is controlled to start or stop, thereby ensuring that the virtual object moves naturally and smoothly along the navigation path, thereby improving the user's gaming experience.

[0073] An embodiment of the present invention provides a navigation method for a virtual object in a game. In response to a target point setting operation for a virtual object in a game scene, a starting point and an end point corresponding to the virtual object are determined; starting from the node where the starting point is located, a path-finding algorithm is executed on the grid nodes of a walkable area in the game scene to obtain a target node group from the starting point to the end point; a navigation path from the starting point to the end point is determined based on the target node group; and the virtual object is controlled to move to the end point along the navigation path. In this method, the grid nodes are nodes in a quadtree formed by dividing the game scene according to parameter information of obstacles in the game scene, and the grid size of the leaf nodes in the obstacle area of ​​the game scene is smaller than the grid size of some leaf nodes in the walkable area. This division method in which the grid size of the leaf nodes in the walkable area is larger can effectively alleviate the problem of large grid storage space consumption corresponding to the vast walkable area. At the same time, the division method in which the grid size of the leaf nodes in the obstacle area is smaller can also ensure the precise positioning of the obstacle area, providing a reliable data basis for the path search operation; and, in the path search operation process, a path finding algorithm is executed on the quadtree grid nodes in the walkable area of ​​the game scene to obtain a target node group from the start point to the end point; a method of determining a navigation path based on the target node group can ensure that the searched navigation path is more preferred, effectively improving the navigation effect of the virtual object.

[0074] In one possible embodiment, the method further includes a game scene division process, that is, the grid nodes are nodes in a quadtree formed by dividing the game scene according to the parameter information of the obstacles in the game scene, and are performed by the following steps: responding to a grid creation operation for the game scene, using a preset maximum grid size as the side length of the root node, and performing quadtree grid division on the obstacle area of ​​the obstacles in the game scene until the obstacle area is divided into leaf nodes with a side length equal to a preset minimum grid size. In this way, the grid size of the obstacle area can be ensured to be relatively small, thereby making the obstacle area determined subsequently more accurate.

[0075] The above-mentioned game scene division process may also include: (1) responding to a grid creation operation for the game scene in the initial state, dividing the game scene into quadtree grids with a preset maximum grid size as the side length of the root node until it is divided into a quadtree base grid; wherein the game scenes in the initial state are all walkable areas; (2) responding to an obstacle creation operation for the game scene, creating an obstacle in the game scene, and dividing the base grid of the obstacle area of ​​the obstacle into quadtree grids until the side length of the leaf node is equal to the preset minimum grid size; wherein the size of the above-mentioned base grid is between the preset maximum grid size and the preset minimum grid size.

[0076] The above grid creation process is divided into two steps. First, the game scene without obstacles is gridded. At this time, all areas in the game scene in the initial state are walkable areas. Therefore, the grid division at this stage uses the preset maximum grid size as the edge length of the root node to divide the game scene into quadtree grids until it is divided into the quadtree base grid. The number of levels from the maximum grid to the base grid can be determined according to the size of the game scene.

[0077] After completing the grid division in the game scene in the above initial state, if the game scene creates obstacles, for example, one or more islands are created as obstacles in the ocean game scene. Then continue to perform quadtree grid division on the obstacle area where the obstacles are located, that is, perform quadtree grid division on the reference grid in the obstacle area until the edge length of the leaf node is equal to the preset minimum grid size. The number of levels between the reference grid and the preset minimum grid can be determined according to the size of the obstacle area.

[0078] The number of levels between the above grids is used to represent the number of times the grid is divided. The more times the grid is divided, the greater the difference in the number of levels between the two types of grids. For example, if the side length of the largest grid is a, then the side length of the next grid is a / 2, and the side length of the next grid is a / 2 / 2. Corresponding to the logic diagram, the lower the level, the more 2 is divided. For the convenience of calculation (in order to make sure that it is still an integer no matter how it is divided by 2), a is set to a power of 2. Based on this, the preset maximum grid size in this embodiment is set to 2. maxL , maxLevel is the preset maximum number of levels, that is, the number of levels of the logical diagram; then the next level is 2 maxL , the next level is 2 maxL So no matter which level you go down to, the side length can be written as 2 m The m is the level. For the largest square, m = maxLevel.

[0079] Theoretically, the quadtree can be infinitely divided downwards. The more it is divided, the smaller the side length of the bottom square will be. In order to control this minimum side length, the minimum level minLevel is introduced. For the smallest square allowed to be divided, m = minLevel. The above minimum grid size can be the size corresponding to the minimum level minLevel, or it can be larger than the size corresponding to the minimum level minLevel.

[0080] The above-mentioned reference grid corresponds to the reference level baseLevel. The so-called reference grid means that before dividing the obstacles, all squares are pre-divided into baseLevel to obtain a two-dimensional uniform grid, but the actual structure is a quadtree grid. In other words, before dividing the obstacles, all small squares are recursively divided until the side length of all leaf nodes is equal to 2. baseL For example, the grid division process in (1) above is adopted. Through the reference grid, the path finding accuracy can be guaranteed while reducing the storage space occupied by the grid nodes, making the path finding path more natural.

[0081] Since each node of the quadtree is a square, for the convenience of description, Figure 6 As shown in the figure, the four child nodes of a parent node can be divided into four nodes, namely, northeast, southeast, northwest and southwest, according to their spatial division areas. The four nodes are called brother nodes, that is, the child nodes with the same parent node are called brother nodes. Therefore, the division of quadtree nodes is a process of generating child nodes from a node. The four child nodes divide the two-dimensional space contained in the parent node into four parts. Obviously, the side length of the square of the child node is half of the side length of the square of the parent node, as shown in the figure. Figure 7 The side length of the root node A is L. After the first division, the side lengths of the child node A2 and the leaf node A1 are both L / 2. When the child node A2 is further divided, the side length of the child node A21 is L / 2 / 2, i.e. L / 2. 2 =L / 4, therefore, for the convenience of calculation, in the embodiment of the present invention, the grid size of each node is an integer power of 2, that is, L=2 level , where level represents the power.

[0082] For example, for a game scene with a size of 16384×16384, since 16384=2 14 Therefore, when the game scene is divided into grids by quadtree, in order to ensure that the square corresponding to the maximum level maxlevel covers the entire game scene, maxlevel = 14; assuming that the minimum allowed division is 64, that is, 2 6 Therefore, minlevel should be set to 6. The size of the reference grid can be selected between 2 14 and 2 6 Other integer powers of 2 between, for example: 2 7 , 2 8 , 2 9 , 2 10 Any one of the above.

[0083] For ease of understanding, an example is given here. Figure 8 As shown, the grid covered by diagonal lines represents the obstacle H. Figure 8 In 8-a, the size of the grid where points B and C are located is relatively large. If the navigation path is ACB, it can be seen that the line connecting the navigation path is relatively steep at point C, and the turning angle is relatively large. If the virtual object drives along this navigation path, the walking process is obviously unnatural and rather stiff. Figure 8 Figure 8-b is the result of further grid division based on Figure 8-a. For the same obstacle H, the point C in the navigation path ACB obtained based on the grid division method of Figure 8-b is closer to the obstacle side, making the navigation path ACB of Figure 8-b smoother and shorter than the navigation path in Figure 8-a. Therefore, compared with Figure 8-a, the path of the virtual object in Figure 8-b is obviously more natural. In addition, Figure 8 In 8-c, the grid division is further performed on the basis of 8-b. The size of the leaf nodes in the walkable area is the same as the grid size of the leaf nodes in the area where the obstacle H is located. The grid obtained based on the quadtree grid division method degenerates into a conventional two-dimensional grid. At this time, the nodes are searched by the preset A* search algorithm, and the navigation path of the virtual object is A-C13-C2-C3-B. Compared with 8-b, 8-c improves the grid division accuracy, but increases the amount of calculation. Therefore, in terms of grid division, it is necessary to divide the grid reasonably according to the accuracy requirements of the actual application. Fig. 9 As shown, the walkable area is composed of an initial grid size of 2 maxLevel Start dividing until the final grid size is 2 baseLevel The base grid.

[0084] If the obstacle is a dynamic obstacle, it is necessary to divide and restore the grid based on the dynamic obstacle after the position changes, specifically including: dividing the grid where the dynamic obstacle is currently located into the minimum grid size, and restoring the grid where the dynamic obstacle was located before the position changed to the size before division, such as restoring to the reference grid size.

[0085] The quadtree grid division method in the above game scene can further quadtree grid division the reference grid of the obstacle area according to the position and shape of the created obstacle after the obstacle is created in the game scene, that is, the reference grid in the obstacle area is recursively divided into leaf nodes, and the side length of the leaf node is the preset minimum grid size, that is, 2 minlevel , thus improving the division accuracy of the obstacle area.

[0086] After the obstacle area is divided, in order to ensure the accuracy of the grid division in the obstacle area as much as possible, after the above (2) is executed, the grid nodes corresponding to the obstacle area can also be checked to check whether these grid nodes are indeed in the obstacle area. Based on this, the above method also includes: checking whether the leaf node of the preset minimum grid size is in the obstacle area; if so, marking the leaf node as a leaf node of the obstacle area; if not, and the brother nodes of the leaf node are also not in the obstacle area, deleting the leaf node and the brother nodes of the leaf node, and only retaining the parent node of the leaf node.

[0087] As a possible implementation, the step of checking whether a leaf node of a preset minimum grid size is within an obstacle area includes: checking whether a center point of a leaf node of a preset minimum grid size is within an obstacle area; if so, determining that the leaf node is within the obstacle area; if not, performing quadtree division on the leaf node to obtain child nodes of the leaf node, and if center points of all child nodes of the leaf node are not within the obstacle area, determining that the leaf node is not within the obstacle area; and if the center point of at least one child node of the leaf node is within the obstacle area, determining that the leaf node is within the obstacle area.

[0088] like Fig.10 As shown, taking a leaf node as an example, if the center point O of the leaf node is in the obstacle area, the leaf node is marked as a leaf node of the obstacle area, and the leaf node covers the obstacles in the obstacle area by default; if the center point O of the leaf node is not in the obstacle area, the leaf node can be further divided into a quadtree to obtain the four child nodes of the leaf node, and it is determined whether the four center points X1, X2, X3 and X4 of the four child nodes are in the obstacle area. If X1, X2, X3 and X4 are not in the obstacle area, that is, the center point O of the leaf node and the center points X1, X2, X3 and X4 of the four child nodes are not in the obstacle area, then it is considered that the leaf node is not in the obstacle area, that is, it does not cover the obstacle; on the contrary, if one of X1, X2, X3 and X4 is in the obstacle area, for example, point X1 is in the obstacle area, and the center point O, points X2, X3 and X4 are not in the obstacle area, then it is still determined that the leaf node is in the obstacle area, that is, the leaf node covers the obstacle. As shown Fig.11 The figure shows a schematic diagram of the process of dividing the base grid of the obstacle area into quadtree grids. By dividing the obstacle area, the grid size in the obstacle area is made smaller, the position of the obstacle can be located more accurately, and a reliable data basis is provided for the path search operation.

[0089] exist Figure 3Based on the above, the embodiment of the present invention also provides another navigation method for virtual objects in the game. The method is executed by an electronic device, and the process of determining the starting point and the end point of the virtual object is described in detail. This embodiment takes the A* search algorithm as an example for explanation. Fig.12 As shown, the method comprises the following steps:

[0090] Step S1202, in response to a target point setting operation for a virtual object in the game scene, the node at the current location of the virtual object and the node at the location of the target point set by the target point setting operation are divided into minimum grid sizes respectively. The minimum grid size is a preset size, which can be any value between a smaller than the reference grid size and a larger than the size corresponding to the minimum level. Of course, as a special case, the minimum grid size can also be equal to the size corresponding to the minimum level.

[0091] Specifically, if the node at the current location of the virtual object is a node with a larger grid size, when performing a path search operation, the center of the node at the current location of the virtual object is used as the first path point. At this time, the first path point (starting point) may have a large error from the actual position of the virtual object; similarly, for the above-mentioned target point (that is, the end point set by the target point setting operation), if the grid size of the node at the target point is larger, if the center of the node is used as the end point, there may also be a certain error with the target point setting operation, thereby reducing the accuracy of the navigation path obtained by the path search operation. When the virtual object is controlled to move along the navigation path, the virtual object may move unnaturally, affecting the user experience.

[0092] Therefore, the above step S1202 divides the node at the current location of the virtual object and the node at the location of the target point set by the target point setting operation into the minimum grid size, respectively, to improve the accuracy of the starting point and the end point. For example: for a node of size 1024x1024, no matter where the virtual ship is at the node at the current location, the first path point is the center of the node, then the actual location of the virtual ship may be far away from the center of the node, resulting in a large error between the first path point and the location of the virtual ship. When the 1024x1024 node is divided into the preset minimum grid size, such as the node size is 8x8 at this time, it is obvious that the error between the first path point being the center of the node and the location of the virtual ship is significantly reduced. The above step divides the leaf node at the current location of the virtual object and the leaf node at the location of the target point into nodes of the preset minimum grid size.

[0093] For ease of understanding, an example is given here. Fig.13 As shown, Fig.13The current location of the virtual object in the figure on the left of the middle arrow is point A, and the target point set by the target point setting operation is point B, where both point A and point B are located at a node with a larger grid size. When performing a path search operation, the first path point is the center O1 of the node where point A is located, and the last path point is the center O2 of the node where point B is located. When controlling the virtual object to move along the navigation path, the virtual object may turn around and walk back from point A, and then move forward to the center O2 of the node where point B is located after reaching the center O1 of the node where point A is located, thereby causing a poor gaming experience for the user. Before the path search operation, the node where point A is located and the node where point B is located are respectively divided into nodes of a preset minimum grid size (for example, the size corresponding to the minimum level minlevel), such as Fig.13 As shown in the figure to the right of the middle arrow, at this time, the center O of the leaf node where point A is located 11 As the first path point, i.e. the starting point, compared with the center point O1 in the figure on the left side of the arrow, the first path point O 11 The error with the actual position of the virtual object, point A, is small. Similarly, the center of the target point, point B, is O 21 It also caters to the actual position corresponding to the target point setting operation. When controlling the virtual object to travel from point A to point B, the current position of the virtual object, point A, is at point O. 11 The point is the center of the circle, and the radius is r (half the length of the leaf node), so it is considered that point A and point O are in the circle. 11 If the points coincide, the virtual object can be controlled to move directly from the current position A to the center O of the target point B. 21 Drive to point O without turning back to point O 11 Similarly, when the virtual object drives to point B, because the distance O 21 If the point is smaller than the radius r, it is also considered to have reached the target point and the driving stops. Therefore, the navigation path obtained in the figure to the right of the arrow has a small or no error and appears more natural and not stiff, which improves the navigation accuracy of the virtual object and further improves the user's gaming experience.

[0094] Step S1204, determining the leaf node containing the center point of the virtual object as the starting point corresponding to the virtual object; and determining the leaf node containing the center point of the target point as the end point corresponding to the virtual object.

[0095] Step S1206, starting from the node where the starting point is located, the preset A* path search algorithm is executed on the quadtree grid nodes of the walkable area in the game scene to obtain the target node group from the starting point to the end point.

[0096] The preset A* path search algorithm determines the adjacent nodes of the current node in the following way: (1) based on the quadtree grid nodes of the traversable area in the game scene, in the adjacent direction of the current node (including Figure 4 (1) In the eight directions shown, search for nodes whose grid size is greater than or equal to the grid size of the current node to obtain a pending node group; (2) use the non-leaf nodes in the pending node group as intermediate nodes, and search for leaf nodes adjacent to the current node from the intermediate nodes; (3) use the searched leaf nodes and nodes in the pending node group except the intermediate nodes as adjacent nodes of the current node. Repeat the above (1)-(3) in each adjacent direction to obtain all adjacent nodes of the current node.

[0097] It should be noted that the A* path-searching algorithm preset here obtains all adjacent leaf nodes of the current node by searching for nodes with a grid size greater than or equal to the grid size of the current node in the vicinity of the current node. Therefore, the preset A* path-searching algorithm is different from the conventional A* algorithm. Compared with the conventional A* algorithm, the preset A* path-searching algorithm finds adjacent nodes more accurately, so that the navigation path determined based on the target node group is more accurate, which improves the accuracy of the virtual object in avoiding obstacles. Therefore, when the virtual object is controlled to move along the navigation path, the correctness of the virtual object's moving direction is guaranteed, avoiding the virtual object from moving to a position outside the end point, causing a poor gaming experience for the user.

[0098] In actual applications, the electronic device stores the parent-child relationship of each node. For the current node where the current path point is located, the electronic device can obtain the parent node of the current node. Since the four child nodes of the parent node are in different directions, the orientation information of the current node in the parent node is fixed. Based on this, the above-mentioned step of searching for nodes whose grid size is greater than or equal to the grid size of the current node in the neighboring direction of the current node to obtain the pending node group includes: obtaining the parent node of the current node and the orientation information of the current node in the parent node; for each pre-specified neighboring direction of the current node, the following operations are performed to determine the pending node: if the direction corresponding to the orientation information of the current node is opposite to the neighboring direction, the pending node is determined from the sibling nodes of the current node. Since they are the same parent node, the grid size of the sibling nodes is equal to the grid size of the current node at this time; if the direction corresponding to the orientation information of the current node is the same as the neighboring direction, the adjacent node in the neighboring direction of the parent node of the current node is used as the pending node of the current node. Since the adjacent node is the neighboring node of the parent node, the grid size of the neighboring node is greater than the grid size of the current node at this time. The above process is repeated for each neighboring direction. Finally, the pending nodes corresponding to each neighboring direction are grouped into the pending node group of the current node. For ease of understanding, the example of searching for the adjacent node on the north side of the current node whose size is greater than or equal to that of the current node is used here. Fig.14 As shown, the search process is as follows:

[0099] Step S142, determine whether the current node has a parent node. If there is no parent node, the current node is a root node. At this time, the current node has no adjacent node on the north side, so the search process ends; if the current node has a parent node, execute step S144.

[0100] Step S144, determine whether the current node is the southwest or southeast child node of the parent node. If not, execute step S146; if yes, the northern neighboring node of the current node is its brother node, and the northwest or northeast child node of the parent node can be obtained according to the corresponding relationship, and the search process ends. Figure 6 As shown, if the current node is the southeast child node of the parent node, then its northern adjacent node is the northeast child node, which can be directly obtained through the sibling relationship of the same parent node.

[0101] Step S146, using a recursive method, obtain the node node adjacent to the north of the parent node of the current node.

[0102] Step S148, determine whether node does not exist or node has no child nodes. If node exists and has child nodes, execute step S1410; if node does not exist, then the current node has no northern neighbor node, and the node found is empty. If node exists and has no child nodes, then node is the neighbor node of the current node, that is, node is found, and the search process ends. Fig.15 As shown, the current node N is the northeast child node of its parent node. At this time, first obtain the parent node of the current node N by going up one level, and then find and obtain the northern adjacent node of the parent node. If the node has no child nodes, then the node is the northern adjacent node of the current node N.

[0103] Step S1410, determine whether the current node is the northwest or northeast child node of the parent node. If not, the desired northern adjacent node does not exist and the search process ends; if yes, execute step S1412.

[0104] Step S1412, obtain the southwest or southeast child node of the node. Specifically, if the current node is the northwest or northeast child node of the parent node, then Figure 6 As shown in the figure, the southwestern or southeastern child node of the node is the northern neighboring node of the current node. For ease of understanding, an example is given here. Fig.16 As shown, Fig.16 In 16-a, if the node node has a child node, the northern adjacent node of the current node is not the node node, but must be within the node node range. Since the current node is the northeast child node of its parent node, the southeast child node M of the node node is searched. Therefore, searching for its parent node through the current node N is a search up one level at a time, and searching for its southeast child node M through the node node is a search down one level at a time. Therefore, the idea of ​​the recursive method in the embodiment of the present invention is: if the parent node is searched upward n times, then its northern adjacent node is searched downward n times for the child node. If the depth of the child node is not enough n, the child node of the northern adjacent node found last time is used as the northern adjacent node of the current node. If the depth of the child node exceeds n, then only n times of downward search are performed at this time, thereby ensuring that the size of the obtained adjacent node is greater than or equal to the size of the current node. Fig.16 As shown in 16-b, although node M can be divided into four child nodes, the northern adjacent node of the current node should be the southeast child node M of node node. Since the northern adjacent node of the current node N is being searched for, all the southern child nodes of the child nodes of node M should be found. That is, the final result should be as follows: Fig.16 As shown in 16-c.

[0105] For the non-leaf nodes in the pending node group, i.e. the above-mentioned intermediate nodes, there are also sub-nodes inside this type of intermediate node, and it is necessary to continue to search for the adjacent nodes of the current node in the intermediate node. The specific search method includes: in each pre-specified adjacent direction, according to the preset depth-first traversal principle, recursively traverse the sub-nodes in the intermediate node in the opposite direction of the adjacent direction, until the leaf nodes in the opposite direction of the adjacent direction are traversed, and the leaf nodes adjacent to the current node are determined from the traversed leaf nodes. For example, for the adjacent nodes on the north side of the current node found above, each adjacent node is respectively depth-first traversed, and the sub-nodes in the southwest and southeast directions of each adjacent node are recursively accessed until the leaf node is accessed. Since the node size may be different, multiple leaf nodes that meet the conditions may be accessed during the traversal process. These leaf nodes are all adjacent nodes on the north side of a given node, and the next path point corresponding to the current node in the adjacent direction, i.e., the target node, is determined from the multiple leaf nodes that meet the conditions.

[0106] Step S1208, determining a navigation path from the start point to the end point based on the target node group; wherein the navigation path is composed of path points corresponding to the target nodes in the target node group.

[0107] Step S1210 , restoring the node at the current position of the virtual object to the grid node before being divided into the minimum grid size, and restoring the node at the position of the target point to the grid node before being divided into the minimum grid size.

[0108] Specifically, after the navigation path is determined, the node where the center point of the virtual object is located and the node where the center point of the target point is located are restored respectively, so that the node at the current location of the virtual object is the grid node before being divided into the minimum grid size and the leaf node at the target point position is the grid node before being divided into the minimum grid size. Through this restoration operation, the problem of continuous consumption of storage space caused by grid division of the starting point and the end point due to each path search operation can be effectively alleviated.

[0109] Step S1212, control the virtual object to move to the end point according to the navigation path. The navigation method of the virtual object in the above game reduces the error of the starting point and the end point corresponding to the virtual object by dividing the node at the current position of the virtual object and the node at the target point set by the target point setting operation into the minimum grid size, thereby improving the precise positioning of the starting point and the end point of the virtual object; when the search operation is completed and the navigation path is obtained, the node at the current position of the virtual object and the node at the target point are restored to the grid nodes before the minimum grid size, thereby avoiding the influence of the search operation on the grid structure, and effectively alleviating the problem of large grid storage space consumption corresponding to the vast walkable area by making the grid size of the leaf node of the walkable area large.

[0110] exist Figure 3 Based on the above, an embodiment of the present invention also provides another method for navigating a virtual object in a game, which focuses on the process of controlling the virtual object to move to the end point along the navigation path. Fig.17 As shown, the method comprises the following steps:

[0111] Step S1702, in response to a target point setting operation for a virtual object in the game scene, determines the starting point and the end point corresponding to the virtual object.

[0112] Step S1704, starting from the node where the starting point is located, a path-finding algorithm is executed on the grid nodes of the walkable area in the game scene to obtain a target node group from the starting point to the end point.

[0113] Step S1706, determining a navigation path from the start point to the end point based on the target node group; wherein the navigation path is composed of path points corresponding to the target nodes in the target node group.

[0114] For the above steps S1702 to S1706, reference may be made to the aforementioned method embodiment, and the embodiment of the present invention will not be described in detail here.

[0115] Step S1708, in response to the event that the virtual object reaches a waypoint on the navigation path, read the next waypoint from the navigation path, use the read waypoint as the current waypoint, and execute steps S1710 to S1712.

[0116] Through the aforementioned path search operation, the navigation path of the virtual object from the starting point to the end point can be obtained, and the navigation path consists of a series of path points (i.e., target nodes). When controlling the virtual object to move along the navigation path, since the relative position of each path point and the virtual object is different, when the virtual object moves to each path point, a path point event corresponding to the path point needs to be generated, so that when the virtual object reaches the path point, the actual position and the position of the path point are as close as possible, thereby ensuring that the movement of the virtual object is natural and not stiff.

[0117] Among them, the path point event is different from the conventional setting position and speed parameters. Here, the path point event simulates the player (user) operation. For example, for the first path point, it is necessary to control the virtual object to start in the preset direction. Therefore, the first path point event needs to include a start instruction and a preset direction from the first path point to the second path point. During the movement, the second path point read is used as the current path point. At this time, the current path point event includes: an acceleration instruction, which is used to control the virtual object to accelerate to the current path point; a deceleration instruction, which is used to decelerate when the virtual object is very close to the current path point; a steering instruction, which is used to control the rotation direction of the virtual object when the moving direction of the virtual object deviates from the current path point, so that the virtual object moves toward the current path point. If the virtual object is a virtual ship, the moving direction is the bow direction, that is, starting from the current actual position of the ship, a ray is drawn according to the forward direction of the virtual ship, and by judging whether the current path point is on the ray, the moving direction of the virtual ship is measured to be toward the current path point, so as to ensure that when the virtual ship reaches the current path point, the actual position is as close to the current path point as possible.

[0118] Step S1710, determining the relative relationship between the current path point and the current position of the virtual object.

[0119] In practical applications, the actual position of the virtual object may be far away from the read current path point (i.e., the next path point). In this case, the error distance between the virtual object and the current path point will be relatively large, resulting in the virtual object being unable to actually move to the current path point. Therefore, during the movement process, it is necessary to determine the relative relationship between the read current path point and the current position of the virtual object, so as to correct the virtual object's forward direction and forward speed according to the relative relationship, thereby ensuring that when the virtual object reaches the current path point, the actual position is as close to the current path point as possible.

[0120] Specifically, when the virtual object moves toward the current path point, the interval frame number is determined according to the forward speed of the virtual object; and the relative relationship between the current path point and the current position of the virtual object is corrected according to the determined interval frame number. The interval frame number of the virtual object is determined according to the following formula:

[0121]

[0122] Where N represents the interval frame number, and speed represents the forward speed of the virtual object. Therefore, the faster the forward speed of the virtual object, the fewer the interval frame number, the more frequent the correction, and thus the more correct the moving direction of the virtual object. Fig.18 As shown, if no correction is made, there will be a large error distance between the actual position of the virtual object and the path point position, i.e., the target position; after multiple corrections, the actual position of the virtual object is as close as possible to the target position, i.e., the path point, thereby ensuring that the virtual object moves naturally and not stiffly, improving navigation accuracy, and enhancing the user's gaming experience.

[0123] Step S1712: adjusting the moving direction and moving speed of the virtual object according to the relative relationship so that the virtual object moves toward the current path point.

[0124] Specifically, the relative relationship is corrected through the above-mentioned interval frame number, and the forward direction and forward speed of the virtual object are adjusted based on the corrected relative relationship, so that the forward direction of the virtual object is always toward the current path point, and the forward speed is controlled within a preferred speed range to avoid accidents caused by the forward speed of the virtual object. For example, in the case of a virtual object turning, if the forward speed and forward direction are not corrected, the virtual object may have an unsatisfactory turning effect due to the forward direction and forward speed. Even if the forward direction can be changed, an unsatisfactory turning effect may occur due to the forward speed being too fast. Therefore, it is necessary to adjust the forward direction and forward speed of the virtual object through the corrected relative relationship to ensure that the virtual object arrives at each path point in a natural and unstiff state, and the actual position reached is as close as possible to the corresponding path point, thereby improving the navigation accuracy of the virtual object.

[0125] In a possible embodiment, the method further includes: determining a path point radius based on a forward speed of the virtual object; and determining that the virtual object has reached the current path point if the distance between the current position of the virtual object and the current path point is less than or equal to the path point radius.

[0126] Specifically, considering that virtual objects such as virtual ships cannot change their direction on the spot, that is, they will still move forward a certain distance during the turning process, and the navigation accuracy of virtual ships on the sea does not need to be very precise, the actual position of the virtual object can be as close to the position of the waypoint as possible without completely overlapping. Therefore, the radius of the current waypoint can be determined according to the forward speed of the virtual object. When the distance between the actual position of the virtual object and the current waypoint is less than or equal to the radius of the waypoint, it is assumed that the virtual object has reached the current waypoint, that is, the actual position of the virtual object is very close to the position of the current waypoint.

[0127] The path point radius is calculated according to the following formula:

[0128] R=r+k×s (2)

[0129] Among them, r is the preset basic radius (for example, half of the edge length of the current node), k is the preset correction coefficient, and s is the forward speed of the virtual object. It should be noted that the path point radius R here is the reserved distance for the virtual object to turn, so that the actual position and the path point position are as close as possible. Therefore, the path point radius R is greater than 0 at the minimum, and s can be half of the forward speed of the virtual object. Therefore, the greater the forward speed of the virtual object, the larger the path point radius, and thus the larger the reserved distance for the virtual object to turn, such as Fig.19 As shown, the left figure is a schematic diagram of controlling the driving of the virtual object based on a preset basic radius r, and the right figure is a schematic diagram of controlling the driving of the virtual object based on the above-mentioned path point radius R. In the right figure, during the driving process, as long as the distance between the virtual object and the path point is within R, that is, the center of the virtual object is in the area where the dotted circle is located, it is considered that the virtual object has passed the path point and can continue to drive to the next path point. This method can ensure that the virtual object turns in a better state, and the actual position reached is as close as possible to the position of the path point.

[0130] For ease of understanding, a virtual ship is used as an example. Fig. 20 As shown, for a certain sea area in an ocean scene, it is divided into grids through a quadtree, where the area covered by the diagonal line is the area where the island is located, and the leaf nodes involved in the edge position of the area where the island is located are filled with dot graphs. The nodes filled with these dot graphs and the area where the island is located constitute an obstacle area. These areas are not walkable, and the area outside the obstacle area is a walkable area. The navigation path of the virtual ship consists of a series of path points from the starting point to the end point. The grid containing the path points is the target node in the navigation path. Here, the path points are represented by mesh circles in the walkable area. In the process of controlling the movement of the virtual ship, the virtual ship can be moved in accordance with each path point, so that the virtual ship can move naturally without being stiff during navigation, thereby improving the user's gaming experience. Fig.21 As shown in the figure, the specific control and movement process of the virtual ship is as follows:

[0131] Step S2102, obtaining a navigation path of the virtual ship through a path search operation, wherein the navigation path is a path point list, and the path point list stores a series of path points from the starting point to the end point of the virtual ship.

[0132] During the movement process, each waypoint in the waypoint list is read and the corresponding waypoint event is executed to control the virtual ship to move to the waypoint in a natural driving state. Therefore, during the driving process, when the virtual ship reaches the current waypoint, it is necessary to read the next waypoint in the path list until the last waypoint, i.e. the end point, is read, and the virtual ship is controlled to stop to end the navigation process.

[0133] Step S2104, determine whether there is a next waypoint in the navigation path; if so, execute step S2106; if not, it is considered that the virtual ship has reached the end point, and the virtual ship executes a stop operation according to the waypoint event of the end point.

[0134] Step S2106, read the next waypoint from the navigation path, use the read waypoint as the current waypoint, execute the waypoint event corresponding to the current waypoint, control the virtual ship to turn, so that the virtual ship's forward direction is aligned with the current waypoint.

[0135] Step S2108: After the virtual ship completes the turn, it stops turning and controls the virtual ship to move toward the current path point according to the forward direction and forward speed.

[0136] In this process, the interval frame number is determined according to the forward speed of the virtual ship, and the relative relationship between the current path point and the current position of the virtual object is corrected according to the determined interval frame number, that is, the forward direction of the virtual ship is corrected so that the virtual ship can correctly travel to the current path point, and the actual position reached is as close as possible to the position of the current path point, thereby improving the navigation accuracy of the virtual ship.

[0137] In addition, the radius of the waypoint is determined according to the forward speed of the virtual ship; when the distance between the actual position of the virtual ship and the current waypoint is less than or equal to the radius of the waypoint, it is determined that the virtual ship has arrived at the current waypoint, and the next waypoint of the current waypoint in the waypoint list is read, and the above control process is repeated until the virtual ship reaches the last waypoint, that is, the end point.

[0138] Step S2110, after the virtual ship reaches the current path point, the current path point is deleted from the path point list of the navigation path, and the above steps S2104 to S2110 are repeated until the virtual ship reaches the last path point, and the virtual ship is controlled to stop to end the navigation process.

[0139] Therefore, the navigation method of the virtual object in the above game, by adding a direction correction mechanism during the movement of the virtual object, reduces the movement error while ensuring that the virtual object moves along the navigation path, and ensures that the movement of the virtual object is natural and not stiff, thereby improving the user's gaming experience. In addition, in the above method, since the quadtree is a common data structure for scene management, the AOI (Area of ​​Interest) function can be further expanded, saving the cost of redeveloping the function and facilitating promotion and implementation in practical applications.

[0140] Corresponding to the above method embodiment, the embodiment of the present invention also provides a navigation device for virtual objects in a game, which displays the game scene through an electronic device. Fig. 22 As shown, the device includes: a starting point and end point determination module 221, a target node group determination module 222, a navigation path determination module 223 and a movement module 224 connected in sequence, wherein the functions of each module are as follows:

[0141] The starting point and end point determination module 221 is used to respond to the target point setting operation for a virtual object in the game scene, and determine the starting point and end point corresponding to the virtual object; wherein the above-mentioned grid nodes are nodes in a quadtree formed by dividing the game scene according to the parameter information of the obstacles in the game scene, and the grid size of the leaf nodes in the obstacle area of ​​the game scene is smaller than the grid size of some leaf nodes in the walkable area.

[0142] The target node group determination module 222 is used to execute a path finding algorithm on the quadtree grid nodes of the walkable area in the game scene starting from the node where the starting point is located, and obtain a target node group from the starting point to the end point;

[0143] A navigation path determination module 223 is used to determine a navigation path from a starting point to an end point based on a target node group; wherein the navigation path is composed of path points corresponding to target nodes in the target node group;

[0144] The moving module 224 is used to control the virtual object to move to the end point along the navigation path.

[0145] An embodiment of the present invention provides a navigation device for a virtual object in a game, which responds to a target point setting operation for a virtual object in a game scene, determines a starting point and an end point corresponding to the virtual object; starts from the node where the starting point is located, executes a path-finding algorithm on the quadtree grid nodes of a walkable area in the game scene, and obtains a target node group from the starting point to the end point; determines a navigation path from the starting point to the end point based on the target node group; and controls the virtual object to move to the end point along the navigation path. In this method, the grid nodes are nodes in a quadtree formed by dividing the game scene according to parameter information of obstacles in the game scene, and the grid size of the leaf nodes in the obstacle area of ​​the game scene is smaller than the grid size of some leaf nodes in the walkable area. This division method of the leaf nodes in the walkable area with a larger grid size can effectively alleviate the problem of large grid storage space consumption corresponding to the vast walkable area. At the same time, the division method of the leaf nodes in the obstacle area with a smaller grid size can also ensure the precise positioning of the obstacle area and provide a reliable data basis for the path search operation; and, in the path search operation, since the grid size of the leaf node is smaller than the grid size of its parent node, the method of searching for the leaf node in the neighbor direction and then determining the path point can ensure that the searched navigation path is more preferred, effectively improving the navigation effect of the virtual object.

[0146] Furthermore, the above-mentioned starting point and end point determination module 221 is also used to: divide the node at the current location of the virtual object and the node at the location of the target point set by the target point setting operation into the minimum grid size respectively; determine the leaf node containing the center point of the virtual object as the starting point corresponding to the virtual object; determine the leaf node containing the center point of the target point as the end point corresponding to the virtual object; the device is also used to: when determining the navigation path, restore the node at the current location of the virtual object to the grid node before being divided into the minimum grid size, and restore the node at the location of the target point to the grid node before being divided into the minimum grid size.

[0147] Furthermore, taking the A* search algorithm as an example of a pathfinding algorithm, the A* pathfinding algorithm determines the adjacent nodes of the current node in the following manner: based on the quadtree grid nodes of the walkable area in the game scene, search for nodes whose grid size is greater than or equal to the grid size of the current node in the adjacent direction of the current node to obtain a pending node group; use the non-leaf nodes in the pending node group as intermediate nodes, and search for leaf nodes adjacent to the current node from the intermediate nodes; use the searched leaf nodes and nodes in the pending node group except the intermediate nodes as adjacent nodes of the current node.

[0148] Furthermore, the electronic device stores the parent-child relationship of each node. The above-mentioned searching for nodes whose grid size is greater than or equal to the grid size of the current node in the neighboring direction of the current node to obtain the pending node group includes: obtaining the parent node of the current node and the orientation information of the current node in the parent node; for each pre-specified neighboring direction, performing the following operations to determine the pending node: if the direction corresponding to the orientation information is opposite to the neighboring direction, determining the pending node from the sibling nodes of the current node; the grid size of the sibling node is equal to the grid size of the current node; if the direction corresponding to the orientation information is the same as the neighboring direction, using the adjacent node located in the neighboring direction of the parent node as the pending node of the current node; the grid size of the adjacent node is greater than the grid size of the current node; and forming the pending nodes corresponding to each neighboring direction into the pending node group of the current node.

[0149] Furthermore, the above-mentioned search for leaf nodes adjacent to the current node from the intermediate nodes includes: in each pre-specified adjacent direction, according to a preset depth-first traversal principle, recursively traversing the child nodes in the intermediate nodes in the opposite direction to the adjacent direction until all the leaf nodes in the opposite direction to the adjacent direction are traversed; determining the leaf nodes adjacent to the current node from the traversed leaf nodes.

[0150] Furthermore, the above-mentioned device also includes a grid division module, which is connected to the starting point and end point determination module 221, and is used to: respond to the grid creation operation for the game scene, use the preset maximum grid size as the side length of the root node, and perform quadtree grid division on the obstacle area of ​​the obstacle in the game scene, until the obstacle area is divided into a leaf node with a side length equal to the preset minimum grid size. Further, the grid division module is also used to respond to the grid creation operation for the game scene in the initial state, use the preset maximum grid size as the side length of the root node, and perform quadtree grid division on the game scene until it is divided into a quadtree reference grid; wherein the game scene in the initial state is a walkable area; in response to the obstacle creation operation for the game scene, create an obstacle in the game scene, and perform quadtree grid division on the reference grid of the obstacle area of ​​the obstacle until the side length of the leaf node is equal to the preset minimum grid size; wherein the size of the reference grid is between the preset maximum grid size and the preset minimum grid size.

[0151] Furthermore, the above-mentioned grid division module is also used to: check whether the leaf node of the preset minimum grid size is in the obstacle area; if so, mark the leaf node as a leaf node in the obstacle area; if not, and none of the leaf node’s sibling nodes are in the obstacle area, delete the leaf node and its sibling nodes.

[0152] Furthermore, the above-mentioned grid division module is also used to: check whether the center point of the leaf node of the preset minimum grid size is within the obstacle area; if so, determine that the leaf node is within the obstacle area; if not, perform quadtree division on the leaf node to obtain the child nodes of the leaf node, if the center points of the child nodes of the leaf node are not within the obstacle area, determine that the leaf node is not within the obstacle area; if the center point of at least one child node of the leaf node is within the obstacle area, determine that the leaf node is within the obstacle area.

[0153] Furthermore, the above-mentioned moving module 224 is also used to: respond to the event that the virtual object reaches a waypoint on the navigation path, read the next waypoint from the navigation path, use the read waypoint as the current waypoint, and perform the following operations: determine the relative relationship between the current waypoint and the current position of the virtual object; adjust the forward direction and forward speed of the virtual object according to the relative relationship so that the virtual object moves toward the current waypoint.

[0154] Furthermore, the moving module 224 is also used to: determine the frame interval according to the forward speed of the virtual object; correct the relative relationship between the current path point and the current position of the virtual object according to the determined frame interval; and adjust the forward direction and forward speed of the virtual object according to the corrected relative relationship.

[0155] Furthermore, the above device is also used to: determine the radius of the path point based on the forward speed of the virtual object; if the distance between the current position of the virtual object and the current path point is less than or equal to the path point radius, determine that the virtual object has reached the current path point.

[0156] Furthermore, the above device is also used to calculate the path point radius R=r+k×s, wherein r is a preset basic radius, k is a preset correction coefficient, and s is the forward speed of the virtual object.

[0157] Furthermore, the game scene is an ocean scene, the virtual object is a virtual ship, and the grid size of each node is an integer power of 2.

[0158] The navigation device for virtual objects in a game provided by an embodiment of the present invention has the same technical features as the navigation method for virtual objects in a game provided by the above-mentioned embodiment, and therefore can solve the same technical problems and achieve the same technical effects.

[0159] An embodiment of the present invention further provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the navigation method of the virtual object in the above game.

[0160] See also Fig.23As shown, the electronic device includes a processor 230 and a memory 231, wherein the memory 231 stores machine executable instructions that can be executed by the processor 230, and the processor 230 executes the machine executable instructions to implement the navigation method of the virtual object in the above game.

[0161] Further, Fig.23 The electronic device shown further includes a bus 232 and a communication interface 233 , and the processor 230 , the communication interface 233 and the memory 231 are connected via the bus 232 .

[0162] Among them, the memory 231 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 233 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 232 can be an ISA (Industrial Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Enhanced Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.23 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0163] The processor 230 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 230. The above processor 230 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 231, and the processor 230 reads the information in the memory 231 and completes the steps of the method of the above embodiment in combination with its hardware.

[0164] This embodiment further provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the navigation method of the virtual object in the above game.

[0165] The computer program product of the navigation method, device and electronic device of the virtual object in the game provided by the embodiment of the present invention includes a computer-readable storage medium storing a program code, and the instructions included in the program code can be used to execute the method described in the previous method embodiment. The specific implementation can be referred to the method embodiment, which will not be repeated here. The above technology involves concepts such as "arrival" and "direction to a certain point". Converted into a mathematical model, arrival means that two points coincide (the positions are exactly the same), and the direction to a certain point means that the point is on the ray. However, in computer practice, these mathematical models are too ideal. For example, the positions of two points are exactly the same. Since the positions are saved as floating point numbers, the positions of A (0, 0.00001) and B (0, 0.0000002) are not the same. But such a small gap can actually be considered the same. So in order to avoid this situation, the coincidence of A and B is often regarded as A in a circle with B as the center and a radius of r.

[0166] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0167] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0168] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the 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, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. 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.

[0169] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0170] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A navigation method for a virtual object in a game, characterized in that: Displaying a game scene by an electronic device, the method comprising: In response to a target point setting operation for a virtual object in the game scene, determining a starting point and an end point corresponding to the virtual object; Starting from the node where the starting point is located, a pathfinding algorithm is executed on the grid nodes of the walkable area in the game scene to obtain a target node group from the starting point to the end point, wherein the grid nodes are nodes in a quadtree formed by dividing the game scene according to parameter information of obstacles in the game scene, and the grid size of the leaf nodes in the obstacle area in the game scene is smaller than the grid size of some leaf nodes in the walkable area; Determining a navigation path from the starting point to the end point based on the target node group; wherein the navigation path is composed of path points corresponding to the target nodes in the target node group; Controlling the virtual object to move to the end point along the navigation path; The step of determining the starting point and the end point corresponding to the virtual object comprises: Divide the node at the current location of the virtual object and the node at the location of the target point set by the target point setting operation into the minimum grid size respectively; A leaf node containing the center point of the virtual object is determined as the starting point corresponding to the virtual object; and a leaf node containing the center point of the target point is determined as the end point corresponding to the virtual object.

2. The method for navigating a virtual object in a game according to claim 1, characterized in that: The grid nodes are nodes in a quadtree formed by dividing the game scene according to parameter information of obstacles in the game scene, and are performed by the following steps: In response to a grid creation operation for the game scene, the obstacle area of ​​the obstacles in the game scene is divided into quadtree grids with a preset maximum grid size as the side length of the root node until the obstacle area is divided into leaf nodes with a side length equal to the preset minimum grid size.

3. The method for navigating a virtual object in a game according to claim 2, characterized in that: In response to a grid creation operation for the game scene, a quadtree grid division is performed on an obstacle area of ​​an obstacle in the game scene with a preset maximum grid size as the side length of a root node until the obstacle area is divided into leaf nodes with a side length equal to a preset minimum grid size, including: In response to a grid creation operation for the game scene in the initial state, the game scene is divided into quadtree grids with a preset maximum grid size as the side length of the root node until it is divided into a reference grid of the quadtree; wherein the game scene in the initial state is a walkable area; In response to an obstacle creation operation for the game scene, an obstacle is created in the game scene, and a reference grid of an obstacle area of ​​the obstacle is divided into quadtree grids until the length of the edge of the leaf node is equal to a preset minimum grid size; The size of the reference grid is between the preset maximum grid size and the preset minimum grid size.

4. The method for navigating a virtual object in a game according to claim 2, characterized in that: The method further comprises: Check whether the leaf node of the preset minimum grid size is within the obstacle area; If yes, mark the leaf node as a leaf node of the obstacle area; If not, and none of the sibling nodes of the leaf node are within the obstacle area, the leaf node and the sibling nodes of the leaf node are deleted.

5. The method for navigating a virtual object in a game according to claim 4, characterized in that: The step of checking whether the leaf node of the preset minimum grid size is within the obstacle area comprises: Check whether the center point of the leaf node of the preset minimum grid size is within the obstacle area; If yes, determining that the leaf node is within the obstacle area; If not, perform quadtree division on the leaf node to obtain the child nodes of the leaf node. If the center points of the child nodes of the leaf node are not in the obstacle area, determine that the leaf node is not in the obstacle area; if the center point of at least one child node of the leaf node is in the obstacle area, determine that the leaf node is in the obstacle area.

6. The method for navigating a virtual object in a game according to claim 1, characterized in that: The method further includes: when the navigation path is determined, restoring the node at the current location of the virtual object to the grid node before being divided into the minimum grid size, and restoring the node at the location of the target point to the grid node before being divided into the minimum grid size.

7. The method for navigating a virtual object in a game according to claim 1, characterized in that: The path finding algorithm is an A* search algorithm, which determines the adjacent nodes of the current node in the following way: Based on the quadtree grid nodes of the walkable area in the game scene, searching for nodes whose grid size is greater than or equal to the grid size of the current node in the neighboring direction of the current node to obtain a pending node group; Taking non-leaf nodes in the pending node group as intermediate nodes, searching for leaf nodes adjacent to the current node from the intermediate nodes; The searched leaf nodes and nodes in the pending node group except the intermediate nodes are used as adjacent nodes of the current node.

8. The method for navigating a virtual object in a game according to claim 7, characterized in that: The electronic device stores the parent-child relationship of each node; The step of searching for nodes whose mesh size is greater than or equal to the mesh size of the current node in the neighboring direction of the current node to obtain a pending node group includes: Obtaining the parent node of the current node and the position information of the current node in the parent node; For each pre-specified adjacent direction, the following operations are performed to determine the pending node: if the direction corresponding to the orientation information is opposite to the adjacent direction, the pending node is determined from the sibling nodes of the current node; the grid size of the sibling node is equal to the grid size of the current node; if the direction corresponding to the orientation information is the same as the adjacent direction, the adjacent node located in the adjacent direction of the parent node is used as the pending node of the current node; the grid size of the adjacent node is larger than the grid size of the current node; The pending nodes corresponding to the adjacent directions are combined into a pending node group of the current node.

9. The method for navigating a virtual object in a game according to claim 7, characterized in that: The step of searching the intermediate nodes for a leaf node adjacent to the current node comprises: In each pre-specified adjacent direction, according to a preset depth-first traversal principle, recursively traverse the child nodes in the intermediate node in the opposite direction to the adjacent direction until all leaf nodes in the opposite direction to the adjacent direction are traversed; Determine the leaf nodes adjacent to the current node from the traversed leaf nodes.

10. The method for navigating a virtual object in a game according to claim 1, characterized in that: The step of controlling the virtual object to move to the end point along the navigation path includes: In response to an event that the virtual object reaches a waypoint on the navigation path, read a next waypoint from the navigation path, use the read waypoint as a current waypoint, and perform the following operations: Determining a relative relationship between the current path point and the current position of the virtual object; The forward direction and forward speed of the virtual object are adjusted according to the relative relationship so that the virtual object moves toward the current path point.

11. The method for navigating a virtual object in a game according to claim 10, characterized in that: The step of determining the relative relationship between the current path point and the current position of the virtual object comprises: determining the interval frame number according to the forward speed of the virtual object; correcting the relative relationship between the current path point and the current position of the virtual object according to the determined interval frame number; The step of adjusting the forward direction and the forward speed of the virtual object according to the relative relationship includes: adjusting the forward direction and the forward speed of the virtual object according to the corrected relative relationship.

12. The method for navigating a virtual object in a game according to claim 10, characterized in that: The method further comprises: determining a waypoint radius based on a forward speed of the virtual object; If the distance between the current position of the virtual object and the current path point is less than or equal to the path point radius, it is determined that the virtual object has reached the current path point.

13. The method for navigating a virtual object in a game according to claim 12, characterized in that: The step of determining the radius of the path point based on the forward speed of the virtual object comprises: The path point radius R=r+k×s is calculated, wherein r is a preset basic radius, k is a preset correction coefficient, and s is the forward speed of the virtual object.

14. The method for navigating a virtual object in a game according to any one of claims 1 to 13, characterized in that: The game scene is an ocean scene, and the virtual object is a virtual ship; the grid size of each node is an integer power of 2.

15. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the navigation method of the virtual object in the game as claimed in any one of claims 1 to 14.

16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by the processor, the computer-executable instructions prompt the processor to implement the method for navigating a virtual object in a game as described in any one of claims 1 to 14.