Platform jumping type real-time terrain scanning path-finding method and device and computer equipment

By introducing a platform jump-type real-time scanning terrain pathfinding method into the pathfinding algorithm, using the ray matrix and terrain matrix to determine the path node and jump control information, the problems of inaccurate pathfinding and large resource occupation in the existing technology are solved, and more efficient and accurate pathfinding effects are achieved.

CN119633386AInactive Publication Date: 2025-03-18SOUTHWEST PETROLEUM UNIV
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411798847.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-03-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing road search algorithm may obtain ground information that the character cannot reach. The line segment density is too small or the line segment launch port is blocked, resulting in incomplete terrain information, and a large number of enemies' continuous road search will occupy a large amount of resources, affecting the game's running effect.

Method used

A platform jumping real-time scanning terrain pathfinding method is provided. By determining ray-ground collision point information based on the ray matrix with the role as the center, establishing a terrain matrix, determining local map nodes and pathfinding end points, using the A* algorithm or greedy algorithm to calculate the movement path, and controlling the role movement based on the path nodes and jump control information.

Benefits of technology

It improves the effectiveness and accuracy of the wayfinding method, avoids the problem of incomplete ground information, reduces resource usage, and improves the game operation effect and quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119633386A_ABST
    Figure CN119633386A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computer graphics, and provides a platform jumping type real-time terrain scanning path-finding method and device and computer equipment. The method comprises the following steps: firstly, taking a role as a center, determining ray-ground collision point information based on a ray matrix, and establishing a terrain matrix based on the ray-ground collision point information; then, determining a local map node and a path-finding end point based on the terrain matrix, and calculating a moving path by adopting an A * algorithm or a greedy algorithm to obtain a path node; thereafter, it is determined, based on the path node, whether a hop is needed and hop control information is needed. And finally, controlling a role to move according to a path finding result based on the path node and the jump control information. By adding the detection line segments, increasing the layer number and density of the detection line segments and adding the timer to control the way-finding frequency, way-finding nodes do not need to be preset, a new way-finding thought is provided for the 2D platform game, and the game level and quality can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer graphics technology, and in particular to a platform jumping type real-time terrain scanning path finding method, device and computer equipment. Background Art

[0002] Path planning and pathfinding algorithms are extremely important components of game design, city maps, vehicle navigation, aircraft, highway networks, robots, computer routing line path design and virtual scene path management, and are related to the memory resource usage, operating speed, sustainability and operating quality of related application systems.

[0003] In the existing technology, pathfinding algorithms include A* algorithm, breadth-first search, breadth-first search, best-first search and Dijkstra, etc. In recent years, advanced technologies such as AGV simulator, artificial intelligence, deep learning, smooth algorithm, inner spiral algorithm, etc. are also widely used in pathfinding algorithms. However, the existing pathfinding algorithms may still have several defects, including: 1) it may obtain ground information that the character cannot reach; 2) when the line segment density is too small or the line segment launch port directly immerses in the scene terrain, the line segment launch port may be blocked, multiple layers of ground cannot be detected, and the terrain information is incomplete; 3) if there are a large number of enemies and the pathfinding is continuously performed in frames, it will take up a lot of resources and affect the game operation effect.

[0004] Therefore, in the related art, there is an urgent need for a method that can improve the effectiveness and accuracy of the pathfinding method. Summary of the invention

[0005] Based on this, it is necessary to provide a platform jumping real-time scanning terrain path finding method, device and computer equipment that can improve the effectiveness and accuracy of the path finding method in response to the above technical problems.

[0006] In a first aspect, the present application provides a platform jumping type real-time terrain scanning path finding method. The method comprises: Taking the character as the center, determining the ray-ground collision point information based on the ray matrix, and establishing the terrain matrix based on the ray-ground collision point information; Determine the local map nodes and the pathfinding end point based on the terrain matrix, calculate the moving path using the A* algorithm or the greedy algorithm, and obtain the path nodes; Determine whether a jump is required and jump control information based on the path node; Based on the path nodes and jump control information, the character is controlled to move according to the path finding result.

[0007] Optionally, in one embodiment of the present application, the determining of ground collision point information based on the ray matrix includes: A ray starting point matrix is ​​established with the character as the center, rays are generated based on the ray starting point matrix, and a ray matrix is ​​determined.

[0008] Optionally, in one embodiment of the present application, establishing a terrain matrix based on the ray-ground collision point information includes: Determine the standable terrain based on the ray-ground collision point information; A corresponding connected detection ray is created based on each ray and the standable terrain to obtain a detection ray matrix, and a terrain matrix is ​​established based on the ray matrix and the detection ray matrix.

[0009] Optionally, in one embodiment of the present application, the determining of the local map node and the path finding end point based on the terrain matrix, using the A* algorithm or the greedy algorithm to calculate the moving path, and obtaining the path node includes: Based on the central node of the terrain matrix, the neighboring nodes are traversed in turn, and the node weights are calculated using the A* algorithm or greedy algorithm; Path nodes and pathfinding endpoints are determined based on the node weights.

[0010] Optionally, in one embodiment of the present application, the calculation formula for calculating the node weight using the A* algorithm is:

[0011] The calculation formula for calculating node weight using the greedy algorithm is:

[0012] in, is the node weight, is the distance cost from the central node to the adjacent nodes during the pathfinding process, is the estimated cost from the neighboring node to the pathfinding end point, and x and y refer to the horizontal and vertical coordinates of the node.

[0013] Optionally, in an embodiment of the present application, the determining whether a jump is required and the jump control information based on the path node includes: Determine the distance between nodes and the slope according to the position information of the node where the character and the pathfinding end point are located; Determining whether jumping is required based on the inter-node distance and the slope slope and a preset reference distance and a preset reference slope; If jumping is required, jumping control information is determined based on information of the jumping start point and the jumping end point, and the jumping control information includes a jumping angle and a required jumping speed.

[0014] Optionally, in one embodiment of the present application, the method further includes: Monitor the character's movement effect and current movement progress in real time to determine whether the character has reached the pathfinding end point or has a movement timeout.

[0015] In a second aspect, the present application also provides a platform jumping type real-time scanning terrain path finding device. The device comprises: A terrain detection module, which is used to determine the ray-ground collision point information based on the ray matrix with the character as the center, and to establish a terrain matrix based on the ray-ground collision point information; A preliminary movement plan establishment module is used to determine the local map nodes and the path finding end point based on the terrain matrix, and use the A* algorithm or the greedy algorithm to calculate the movement path to obtain the path node; A motion judgment module, used to determine whether a jump is required and jump control information based on the path node; The motion module is used to control the character to move according to the path finding result based on the path nodes and the jump control information.

[0016] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor executes the steps of the methods described in the above embodiments.

[0017] The above-mentioned platform jumping type real-time scanning terrain pathfinding method, device and computer equipment first determine the ray-ground collision point information based on the ray matrix with the character as the center, and establish a terrain matrix based on the ray-ground collision point information. Then, determine the local map node and the pathfinding end point based on the terrain matrix, use the A* algorithm or the greedy algorithm to calculate the moving path, and obtain the path node. Then, determine whether to jump and the jump control information based on the path node. Finally, control the character to move according to the pathfinding result based on the path node and the jump control information. In other words, in view of the problems that the current pathfinding algorithm may still obtain ground information that the character cannot reach, the line segment launch port may be blocked, the multi-layer ground cannot be detected, the terrain information is incomplete, and if there are a large number of enemies and the pathfinding is continuously performed in frames, it will take up a lot of resources and affect the game operation effect. Based on the pathfinding mechanism and pathfinding effect, a real-time terrain scanning pathfinding method for platform jumping is proposed. By increasing the detection segments, increasing the number and density of detection segment layers, and adding a timer to control the pathfinding frequency, there is no need to preset pathfinding nodes. A new pathfinding idea is proposed for 2D platform games, which can effectively improve the game level and quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 A diagram of an application environment of a platform jumping type real-time scanning terrain path finding method in one embodiment; Figure 2 A schematic diagram of a flow chart of a real-time terrain scanning path-finding method for platform jumping in one embodiment; Figure 3A schematic diagram of a ray starting point matrix established with the character position as the center in one embodiment; Figure 4 A schematic diagram of a ray established with a character position as the center in one embodiment; Figure 5 is a schematic diagram of a ray matrix established with the character position as the center in one embodiment; Figure 6 A schematic diagram of a character being able to stand and not being able to stand in one embodiment; Figure 7 It is a structural block diagram of a platform jumping type real-time scanning terrain path finding device in one embodiment; Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0019] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0020] The platform jumping real-time scanning terrain path finding method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal communicates with the server through the network. The data storage system can store the data that the server needs to process. The data storage system can be integrated on the server, or it can be placed on the cloud or other network servers. Among them, the terminal can be but not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server can be implemented as an independent server or a server cluster consisting of multiple servers.

[0021] In one embodiment, Figure 2 As shown, a platform jumping type real-time scanning terrain path finding method is provided, and the method is applied to Figure 1 The server in the example is used to illustrate the following steps: S201: Taking the character as the center, determining ray-ground collision point information based on the ray matrix, and establishing a terrain matrix based on the ray-ground collision point information.

[0022] In the embodiment of the present application, first, with the character as the center, a ray matrix is ​​emitted outward, the collision relationship and collision point between the ray and the terrain surface are detected, the collision point information when the ray collides with the terrain is collected, the terrain on which the character can stand is determined, and whether the character and the terrain are connected is detected, and a terrain matrix is ​​established. Specifically, in the game space, a directed line segment is emitted with a coordinate as the starting point to detect whether there is an object in the game space that intersects with this line segment. The directed line segment is the ray. A detection line segment, i.e., a ray, is established, and the line segment attributes of the generated ray are set, including: 1) starting point coordinates; 2) ray direction vector; 3) ray length; 4) ray penetration layer. The collision relationship and collision point between the ray and the terrain surface include three types of information returned by the ray, namely: 1) a Boolean value of whether the ray intersects with the object; 2) collision point coordinates; 3) information about the object contacted by the ray. The three types of information are stored in the terrain matrix Impact(). Analyzing the collision point information includes: determining whether the ray intersects with the object and assigning a Boolean value based on the collected collision point information, and determining whether there are vertical obstacles, horizontal obstacles, cracks and high and low terrain differences.

[0023] Specifically, in one embodiment of the present application, the determining of ground collision point information based on the ray matrix includes: A ray starting point matrix is ​​established with the character as the center, rays are generated based on the ray starting point matrix, and a ray matrix is ​​determined.

[0024] In one embodiment of the present application, specifically, Figure 3 As shown, a ray starting point matrix is ​​established with the character position as the center, which is used to store the starting point coordinates of the ray matrix. The starting point coordinates are evenly distributed in a rectangular range with the character coordinates as the center point, and the horizontal and vertical spacings are fixed.

[0025] The starting point coordinates are the sum of the character coordinates and the relative coordinates (xj, yi), where the relative coordinates (xj, yi) are as follows: xj=((n+1-j)-(n-1) / 2)×Space_x yi=((m+1-i)-(m-1) / 2)×Space_y Among them, m represents the total number of rows in the matrix, and the unit is dimensionless; n represents the total number of columns in the matrix, and the unit is dimensionless; Space_x is the horizontal spacing of the matrix, and the unit is meter; Space_y is the vertical spacing of the matrix, and the unit is meter; i represents the i-th row, and the unit is dimensionless; j represents the j-th column, and the unit is dimensionless; xj and yi represent the horizontal and vertical coordinates of the starting point of the i-th row and j-th column in the starting point matrix, respectively, and the unit is meter.

[0026] like Figure 4As shown, all the starting coordinates in the starting matrix are used as the starting positions to generate rays with the same number of coordinates. The length of the ray is the vertical spacing of the matrix. The direction vector of the ray is set to be perpendicular to the horizontal plane and downward. The ray penetration is set to penetrate all layers except the terrain. All the generated rays are stored in the ray matrix vector_1() according to the position corresponding to the starting matrix, which is used to detect the terrain around the character. The complete ray matrix diagram is shown below. Figure 5 shown.

[0027] In one embodiment of the present application, establishing a terrain matrix based on the ray-ground collision point information includes: Determine the standable terrain based on the ray-ground collision point information; A corresponding connected detection ray is created based on each ray and the standable terrain to obtain a detection ray matrix, and a terrain matrix is ​​established based on the ray matrix and the detection ray matrix.

[0028] In one embodiment of the present application, first, Figure 6 As shown, the terrain is divided into two types: standable terrain and non-standable terrain. The basis for determination is whether the Boolean return value of the corresponding ray in vector_1() is true. After that, based on the collision relationship between the detection ray and the terrain surface, taking the character coordinates as the starting point, the vectors connected to each starting point coordinate and the character coordinates in the starting point matrix and their inner products (i.e. the length of the vector) are calculated in turn, and then a corresponding connectivity detection ray is created for each ray to detect its connectivity. All rays generated in this way are stored in the ray matrix vector_2() with the same matrix shape in a one-to-one correspondence format with the elements in the ray matrix vector_1().

[0029] Afterwards, the two rays in the same row and column positions in the two matrices are regarded as a group, and the data is processed in groups, where the corresponding ray in the ray matrix vector_1() is called ray 1, and the ray in the ray matrix vector_2() is called ray 2; then the Boolean return values ​​in ray 1 and ray 2 in each group are classified according to Table 1, and the data in the corresponding cells are stored as a structure in a new structure matrix. The new structure matrix is ​​called the terrain matrix Impact(), and the number of rows and columns of the terrain matrix is ​​the same as vector_()1 and vector_2(), and its row and column positions are consistent with the row and column positions of the corresponding rays 1 and ray 2.

[0030] Table 1 Analysis of the return values ​​of ray 1 and ray 2

[0031] S203: Determine the local map nodes and the path finding end point based on the terrain matrix, and use the A* algorithm or the greedy algorithm to calculate the moving path to obtain the path node.

[0032] In the embodiment of the present application, the terrain matrix is ​​used as a local map node to determine the end point of this pathfinding, that is, the elements in the terrain matrix Impact() are used as map nodes. After calling the ray matrix once, a position point closest to the final target point is found as the position point to which the character is expected to move in this pathfinding, or the node with the smallest weight among all elements of the terrain matrix is ​​used as the pathfinding end point. When the node is added to the path array, the pathfinding is considered to be completed. Use the A* algorithm or greedy algorithm to calculate the moving path and record the path nodes.

[0033] Two arrays are created to store the path nodes generated during the pathfinding process. One is the path array path(), which is used to record all the path nodes that the character moves through; the other is the pathfinding array pathing() that records the pathfinding process, which is used to store the results of each pathfinding based on the terrain matrix Impact(). Both are expressed as sequentially arranged position information. path() will not be reset each time the ray matrix is ​​called, while pathing() will be reset each time the ray matrix is ​​called. In order to avoid the result of reciprocating pathfinding on the same path, each time the surrounding nodes are traversed, the surrounding nodes must be compared with the nodes in the path() array to ensure that the same node as the one in the path array path() cannot be selected as the next center node. And after the pathfinding is completed, check whether there are two identical nodes in the path array path(). If so, delete all nodes between the two nodes to ensure that there is no backtracking in the final path().

[0034] Specifically, in one embodiment of the present application, the local map nodes and the path finding end points are determined based on the terrain matrix, and the moving path is calculated using the A* algorithm or the greedy algorithm to obtain the path nodes, including: Based on the central node of the terrain matrix, the neighboring nodes are traversed in turn, and the node weights are calculated using the A* algorithm or greedy algorithm; Path nodes and pathfinding endpoints are determined based on the node weights.

[0035] In one embodiment of the present application, starting from the center node of the terrain matrix, the elements in the matrix adjacent to the node and with a Boolean value of True are traversed, and then the weights are calculated based on the coordinate information stored in the traversed elements. Finally, the node with the smallest weight is selected from the traversed elements as the next node that can form the path. Then, with the selected node as the center node, the elements adjacent to the node and with a Boolean value of True are traversed again to find the next node that forms the path, and so on, until the end point of this path finding is selected as the last node that forms the path.

[0036] Specifically, in one embodiment of the present application, the calculation formula for calculating the node weight using the A* algorithm is:

[0037] The calculation formula for calculating node weight using the greedy algorithm is:

[0038] in, is the node weight, is the distance cost from the central node to the adjacent nodes during the pathfinding process, is the estimated cost from the neighboring node to the pathfinding end point, and x and y refer to the horizontal and vertical coordinates of the node.

[0039] In one embodiment of the present application, It is the distance cost from the node Impact(x,y) selected as the center in the pathfinding process to the neighboring node Impact(x±1,y±1) traversed with this node as the center. The values ​​of x and y in the brackets are the row and column positions of the node in the matrix. Generally, it is the product of the straight-line distance between the central node Impact(x,y) and its neighboring node Impact(x±1,y±1) and the weight g. The straight-line distance can be Euclidean distance or Manhattan distance. The Euclidean distance formula is: G(x±1,y±1)=g*||Impaction(x±1,y±1)-Impaction(x,y)|| The formula using Manhattan distance is: G(x±1,y±1)=g*[Impaction(x±1,y±1).x-Impaction(x,y).x+Impaction(x±1,y±1).y-Impaction(x,y).y] It is the estimated cost from the neighboring node Impact(x±1,y±1) to the pathfinding end point, which is generally the product of the Manhattan distance or Euclidean distance between the current node P(x,y) and the pathfinding end point P(x_end,y_end) and the weight h. The Euclidean distance formula is: H(x±1,y±1)=h*||Impaction(x_end,y_end)-Impaction(x±1,y±1)|| The formula using Manhattan distance is: H(x±1,y±1)=h*[Impaction(x_end,y_end).x-Impaction(x±1,y±1).x+Impaction(x±1,y±1).y-Impaction(x±1,y±1).y] S205: Determine whether jumping is required and jumping control information based on the path node.

[0040] In the embodiment of the present application, the path node information is analyzed, and by traversing the elements in the path array, it is determined whether the planned path requires jumping and the related jumping control information.

[0041] Specifically, in one embodiment of the present application, the determining whether a jump is required and the jump control information based on the path node includes: Determine the distance between nodes and the slope according to the position information of the character and the node where the pathfinding end point is located; Determining whether jumping is required based on the inter-node distance and the slope slope and a preset reference distance and a preset reference slope; If jumping is required, jumping control information is determined based on information of the jumping start point and the jumping end point, and the jumping control information includes a jumping angle and a required jumping speed.

[0042] In one embodiment of the present application, first, the pathfinding state and the direction of the pathfinding end are determined. If the character is in the backward pathfinding state, the next node p_end traversed each time is the previous node p_end=path(n-1) in the path array. If the character is in the forward pathfinding state (non-backward pathfinding state), the pathfinding end is the next node p_end=pathing(n+1) in the pathfinding array. Secondly, the node distance L and the slope K are determined based on the position information of the node where the character and the pathfinding end are located. The node distance L is calculated by the inner product of the two node vectors, and the calculation formula is: L=||k-path(n)|| The calculation formula of the slope K is: K=(k-path(n)).y / (k-path(n)).x After that, the distance between nodes and the slope are compared with the preset reference distance L_medium and the preset reference slope K_min to determine whether a jump is required. Generally, K_min is greater than 1, and L_medium is slightly greater than the character's step length. Specifically, the action required for the character to reach the pathfinding end can be determined according to the standards shown in Table 2.

[0043] Table 2 Determine the required movement of the character based on the position between nodes

[0044] It should be noted that whether to perform a climbing action can be determined by setting a finite-length ray perpendicular to the ground at an appropriate distance in front of the direction of the character's collision body, and judging whether a steep slope appears based on the slope between the return value of the collision position and the position relationship of the lowest section of the character model and its rate of change to determine the character's climbing action.

[0045] After that, if jumping is required, the jumping angle and the required jumping speed are determined based on the information of the jumping start point and the end point. Specifically, the jumping direction is determined. Since the calls to the physical API in the game engine generally use vectors instead of angles, a vector vector starting from the jumping start point and pointing to the jumping direction is usually obtained based on the coordinate difference between the jumping start point start_point and the end point end_point. The obtained vector is then split into a vertical vector vector_v and a horizontal vector vector_h, that is, the horizontal and vertical coordinates of the two vectors are 0, and the vertical and horizontal coordinates are the vertical and horizontal coordinates of the vector vector respectively, that is: vector_v=(0,vector.y) vector_h=(vector.x,0) vector=start_point-end_point=vector_v+vector_h The vertical vector vector_v is multiplied by a constant coefficient n greater than 1 and then added to the horizontal vector vector_h to obtain a new vector vector_new whose angle is always less than 90 degrees but greater than the original vector. The formula is as follows: vector_new=vector_h+vector_v×n Among them, n is determined based on experience and can generally be set to 2.

[0046] If the Unity3D engine is used, the Vector3.Angle module is called to directly calculate the angle between the bright spot vector and the horizontal plane. If the relevant module is not used, the angle calculation formula is: Jump_angle=arccos((vector·vector_h) / (|vector|×|vector_h|)) Wherein, Jump_angle is the jumping angle, and its unit is dimensionless.

[0047] After calculating the jumping angle, the required jumping speed is calculated by the jumping angle, the horizontal distance d_x and the vertical distance d_y between the two points. The relevant formulas are: d_x=V×cos(Jump_angle)×t d_y=V×sin(Jump_angle)×t-1 / 2×g×t^2 Wherein, V is the jumping speed, in m / s; t is the time, in s.

[0048] While traversing the path array to calculate the above parameters, the required movement operations of the character are stored in a new array in sequence, which is called the movement command array Move_command().

[0049] S207: Control the character to move according to the path finding result based on the path nodes and the jump control information.

[0050] In the embodiment of the present application, the motion script is called to control the character to move according to the path finding result based on the path node and the jump control information. The motion script is a script that controls the character's action, position, and speed. The character control script preset by the engine can be called. The aforementioned motion array and path array are called, and then the motion script is called to determine the motion type between two nodes.

[0051] In one embodiment of the present application, the method further includes: Monitor the character's movement effect and current movement progress in real time to determine whether the character has reached the pathfinding end point or has a movement timeout.

[0052] In one embodiment of the present application, in the process of calling the motion script, the character's motion effect and current motion progress are monitored in real time, whether the character has reached the target node to which it should currently go is detected in real time, and whether it can reach the end of the path finding is determined. Specifically, first, at the beginning of this step, the character starts to move from the first element in sequence according to the movement command array Move_command(), a timer specially used to record the movement time is reset to zero and then started, the current position of the character in the path-finding node is calculated, and a variable p with an initial value of 0 is used to calculate the progress of the character in the path-finding array; then, the distance between the character and the pth node is calculated in real time, when the distance is less than the specified value Min_distance, the character is regarded as arriving at the target node, and p=p+1, indicating that the character has walked to the next node in the path-finding array; at the same time, when the character moves after path-finding, after each node is passed, first search in the path array path() whether there is a node with a straight-line distance less than Min_distance from the node, if not, then add the node to the array, and store the current node at the end of the path-finding array pathing(); finally, when the character reaches the last node in the path-finding array, it is regarded as the character moving successfully and the path-finding is completed, the movement timer is stopped, and all stored values ​​except the node record array and the route array are initialized.

[0053] At the same time, the straight-line distance between the character and the final expected location is determined. If it is less than Min_distance, all pathfinding is completed; if the distance is greater than Min_distance, a new pathfinding is restarted; if the timer time exceeds a predetermined threshold Max_time, the movement is determined to be abnormal, the current movement is ended, the timer is stopped, and all stored values ​​except the node record array and the route array are initialized, and the pathfinding is restarted; if it is determined to return to the original path, move backward along the recorded nodes, and try to re-pathfind during the retreat process. If a new path is successfully obtained, the pathfinding process is restarted.

[0054] In the above platform jumping type real-time scanning terrain pathfinding method, first, with the character as the center, the ray-ground collision point information is determined based on the ray matrix, and the terrain matrix is ​​established based on the ray-ground collision point information. Afterwards, the local map node and the pathfinding end point are determined based on the terrain matrix, and the moving path is calculated using the A* algorithm or the greedy algorithm to obtain the path node. Afterwards, whether jumping is required and the jumping control information are determined based on the path node. Finally, the character is controlled to move according to the pathfinding result based on the path node and the jumping control information. In other words, in view of the current pathfinding algorithm, there may still be the possibility of obtaining ground information that the character cannot reach, the line segment launch port may be blocked, the multi-layer ground cannot be detected, and the terrain information is incomplete. If there are a large number of enemies and the pathfinding is continuously performed in frames, a large amount of resources will be occupied and the game running effect will be affected. The problem, starting directly from the pathfinding mechanism and the pathfinding effect, a platform jumping type real-time scanning terrain pathfinding method is proposed. By increasing the detection line segment, increasing the number and density of detection line segments, and adding a timer to control the pathfinding frequency, there is no need to preset the pathfinding node, and a new pathfinding idea is proposed for 2D platform games, which can effectively improve the game level and quality.

[0055] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0056] Based on the same inventive concept, the embodiment of the present application also provides a platform jumping type real-time scanning terrain path finding device for implementing the platform jumping type real-time scanning terrain path finding method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more platform jumping type real-time scanning terrain path finding device embodiments provided below can refer to the limitations of the platform jumping type real-time scanning terrain path finding method above, and will not be repeated here.

[0057] In one embodiment, Figure 7 As shown, a platform jumping type real-time scanning terrain path finding device 700 is provided, comprising: a terrain detection module 701, a motion plan preliminary establishment module 703, a motion judgment module 705 and a motion module 707, wherein: The terrain detection module 701 is used to determine the ray-ground collision point information based on the ray matrix with the character as the center, and establish the terrain matrix based on the ray-ground collision point information.

[0058] The movement plan preliminary establishment module 703 is used to determine the local map nodes and the path finding end point based on the terrain matrix, and use the A* algorithm or the greedy algorithm to calculate the movement path to obtain the path node.

[0059] The motion judgment module 705 is used to determine whether a jump is required and the jump control information based on the path node.

[0060] The movement module 707 is used to control the character to move according to the path finding result based on the path nodes and the jump control information.

[0061] In one embodiment of the present application, the terrain detection module is further used to: A ray starting point matrix is ​​established with the character as the center, rays are generated based on the ray starting point matrix, and a ray matrix is ​​determined.

[0062] In one embodiment of the present application, the terrain detection module is further used to: Determine the standable terrain based on the ray-ground collision point information; A corresponding connected detection ray is created based on each ray and the standable terrain to obtain a detection ray matrix, and a terrain matrix is ​​established based on the ray matrix and the detection ray matrix.

[0063] In one embodiment of the present application, the movement plan preliminary establishment module is also used to: Based on the central node of the terrain matrix, the neighboring nodes are traversed in turn, and the node weights are calculated using the A* algorithm or greedy algorithm; Path nodes and pathfinding endpoints are determined based on the node weights.

[0064] In one embodiment of the present application, the calculation formula for calculating the node weight using the A* algorithm is:

[0065] The calculation formula for calculating node weight using the greedy algorithm is:

[0066] in, is the node weight, is the distance cost from the central node to the adjacent nodes during the pathfinding process, is the estimated cost from the neighboring node to the pathfinding end point, and x and y refer to the horizontal and vertical coordinates of the node.

[0067] In one embodiment of the present application, the motion determination module is further used for: Determine the distance between nodes and the slope according to the position information of the character and the node where the pathfinding end point is located; Determining whether jumping is required based on the inter-node distance and the slope slope and a preset reference distance and a preset reference slope; If jumping is required, jumping control information is determined based on information of the jumping start point and the jumping end point, and the jumping control information includes a jumping angle and a required jumping speed.

[0068] In one embodiment of the present application, the motion module is further used for: Monitor the character's movement effect and current movement progress in real time to determine whether the character has reached the pathfinding end point or has a movement timeout.

[0069] Each module in the above platform jumping real-time scanning terrain pathfinding device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0070] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a platform jumping type real-time scanning terrain path finding method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0071] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0072] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0073] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0074] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0075] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0076] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0077] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0078] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A platform jumping real-time scanning terrain path finding method, characterized in that: The method comprises: Taking the character as the center, determining the ray-ground collision point information based on the ray matrix, and establishing the terrain matrix based on the ray-ground collision point information; Determine the local map nodes and the pathfinding end point based on the terrain matrix, calculate the moving path using the A* algorithm or the greedy algorithm, and obtain the path nodes; Determine whether a jump is required and jump control information based on the path node; Based on the path nodes and jump control information, the character is controlled to move according to the path finding result.

2. The platform jumping real-time scanning terrain path finding method according to claim 1, characterized in that: The method of determining the ground collision point information based on the ray matrix includes: A ray starting point matrix is ​​established with the character as the center, rays are generated based on the ray starting point matrix, and a ray matrix is ​​determined.

3. The platform jumping real-time scanning terrain path finding method according to claim 1, characterized in that: The establishing of a terrain matrix based on the ray-ground collision point information comprises: Determine the standable terrain based on the ray-ground collision point information; A corresponding connected detection ray is created based on each ray and the standable terrain to obtain a detection ray matrix, and a terrain matrix is ​​established based on the ray matrix and the detection ray matrix.

4. The platform jumping real-time scanning terrain path finding method according to claim 1, characterized in that: The local map nodes and the path finding end points are determined based on the terrain matrix, and the moving path is calculated using the A* algorithm or the greedy algorithm to obtain the path nodes, including: Based on the central node of the terrain matrix, the neighboring nodes are traversed in turn, and the node weights are calculated using the A* algorithm or greedy algorithm; Path nodes and pathfinding endpoints are determined based on the node weights.

5. The platform jumping real-time scanning terrain path finding method according to claim 4, characterized in that: The calculation formula for calculating the node weight using the A* algorithm is: The calculation formula for calculating node weight using the greedy algorithm is: in, is the node weight, is the distance cost from the central node to the adjacent nodes during the pathfinding process, is the estimated cost from the neighboring node to the pathfinding end point, and x and y refer to the horizontal and vertical coordinates of the node.

6. The platform jumping real-time scanning terrain path finding method according to claim 1, characterized in that: The determining whether a jump is required and the jump control information based on the path node includes: Determine the distance between nodes and the slope according to the position information of the node where the character and the pathfinding end point are located; Determining whether jumping is required based on the inter-node distance and the slope slope and a preset reference distance and a preset reference slope; If jumping is required, jumping control information is determined based on information of the jumping start point and the jumping end point, and the jumping control information includes a jumping angle and a required jumping speed.

7. The platform jumping real-time scanning terrain path finding method according to claim 1, characterized in that: The method further comprises: Monitor the character's movement effect and current movement progress in real time to determine whether the character has reached the pathfinding end point or has a movement timeout.

8. A platform jumping type real-time scanning terrain path finding device, characterized in that: The device comprises: A terrain detection module, which is used to determine the ray-ground collision point information based on the ray matrix with the character as the center, and to establish a terrain matrix based on the ray-ground collision point information; A preliminary movement plan establishment module is used to determine the local map nodes and the path finding end point based on the terrain matrix, and use the A* algorithm or the greedy algorithm to calculate the movement path to obtain the path node; A motion judgment module, used to determine whether a jump is required and jump control information based on the path node; The motion module is used to control the character to move according to the path finding result based on the path nodes and the jump control information.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Method and device for generating blocking information, storage medium and electronic device

    CN111714890A

  • Map path finding method, device, equipment and medium

    CN112699208A

  • Game data processing method, device and equipment and computer readable storage medium

    CN114288663A

  • Game role path planning method and device, electronic equipment and storage medium

    CN115845379A

  • Game data processing method and device, equipment and medium

    CN118416490A