Npc following position positioning method and device and computer equipment

By constructing an effective detection grid area in the 3D game, selecting suitable navigation grid edges and calculating vertical distances, the shortest grid edge is used as the NPC's following position, thus solving the problem of low NPC following and positioning efficiency and improving the game experience.

CN115944922BActive Publication Date: 2026-02-17BEIJING PIXEL SOFTWARE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211649400.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-21
Publication Date
2026-02-17
Estimated Expiration
2042-12-21

AI Technical Summary

Technical Problem

Existing technologies are inefficient at locating NPCs following player characters in 3D games, especially outside the edges of the navigation grid. This results in high computational resource consumption, long waiting times, and negatively impacts the gaming experience.

Method used

By obtaining the player character's position information outside the navigation grid, an effective detection grid area is constructed. Navigation grid edges that overlap with this area and have a suitable height range are selected, and the grid edge with the shortest vertical distance is calculated as the NPC's following position.

Benefits of technology

It effectively reduces the computational resource consumption and time spent on NPC following location, improves positioning efficiency, achieves a fast NPC automatic following effect, and enhances the game player experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115944922B_ABST
    Figure CN115944922B_ABST
Patent Text Reader

Abstract

The application provides an NPC following position positioning method and device and a computer device, and relates to the technical field of three-dimensional games. The application determines an effective detection grid area of a target player character in a two-dimensional map grid range of a current game scene by acquiring character position information of the target player character when the target player character is beyond a navigation grid coverage range of the current game scene, extracts a plurality of expected grid edges from all navigation grid edges of the current game scene, the expected grid edges at least partially overlap with the effective detection grid area and character height data is in a corresponding effective edge height range, and then determines a to-be-positioned grid edge with the shortest vertical distance from the target player character to each expected grid edge by traversing the plurality of expected grid edges. A vertical point position of the to-be-positioned grid edge corresponding to the target player character is taken as an expected following position of a target NPC, so that the automatic following effect of the NPC is quickly realized, and the game experience of a game player is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of three-dimensional games, in particular to an NPC following position positioning method and device and a computer device. BACKGROUND

[0002] With the continuous development of science and technology, three-dimensional games are vigorously developed because they can moderately reduce people's mental stress and relieve people's mood. In the running process of three-dimensional games, in order to provide better player character movement experience for game players, the movement operation of the player character is no longer dependent on the realization of the navigation mesh, but instead uses a collision detection method. For NPCs (Non-Player Character) in three-dimensional games, in order to ensure server and client consistency and prevent external hanging requirements, the NPC movement operation still needs to rely on the realization of the navigation mesh.

[0003] At present, there is usually a scene requirement of NPC following the movement of a game player character in the running process of most three-dimensional games. When the game player controls the movement of the player character, the player character is often moved outside the coverage range of the navigation mesh. At this time, the NPC needs to find a path to follow to the closest position of the player character on the edge of the navigation mesh to effectively maintain the automatic following effect of the NPC. The existing scheme for determining the closest position of the player character on the edge of the navigation mesh outside the coverage range of the navigation mesh needs to compare all navigation network edges with the position information of the player character to determine a navigation network edge closest to the player character from a plurality of navigation network edges, and then solve the NPC following position closest to the player character on the determined navigation network edge. However, it is worth noting that this following position determination scheme has the problems of large consumption of operation resources, long time consumption of following position positioning, and low efficiency of following position positioning in the case of a large number of navigation mesh edges. It cannot quickly realize the automatic following effect of the NPC, and affects the game experience of the game player. SUMMARY

[0004] Therefore, the purpose of the present application is to provide an NPC following position positioning method and device and a computer device, which can directly select the navigation mesh edge closest to the player character from a plurality of navigation mesh edges to position the closest point position when the player character is not in the coverage range of the navigation mesh, thereby effectively reducing the operation resource consumption and time consumption of the following position positioning process, and improving the efficiency of the following position positioning, so as to quickly realize the automatic following effect of the NPC and improve the game experience of the game player.

[0005] In order to achieve the above purpose, the technical scheme adopted by the embodiments of the present application is as follows:

[0006] In a first aspect, the present application provides a method for following a position of a player character, comprising:

[0007] obtaining character position information of a target player character when the target player character is out of a navigation mesh coverage range of a current game scene;

[0008] determining an effective detection mesh area of the target player character in a two-dimensional map mesh range of the current game scene according to a preset character detection distance and the character position information, wherein the target player character is projected at a region center position of the effective detection mesh area;

[0009] extracting a plurality of target mesh edges from all mesh edges of the current game scene, wherein a projection position of each target mesh edge at least partially overlaps with the effective detection mesh area;

[0010] extracting a plurality of expected mesh edges from the plurality of target mesh edges, wherein a height position data of the character position information of each expected mesh edge is within a corresponding effective edge height range;

[0011] determining a to-be-positioned mesh edge from the plurality of expected mesh edges according to the character position information, wherein a vertical distance from the target player character to the to-be-positioned mesh edge is the shortest, and a vertical point position of the to-be-positioned mesh edge corresponding to the target player character is an expected following position of a target NPC following the target player character.

[0012] In an optional implementation, the step of determining the effective detection mesh area of the target player character in the two-dimensional map mesh range of the current game scene according to the preset character detection distance and the character position information comprises:

[0013] constructing a circular detection area with the character projection position in the two-dimensional map mesh range of the current game scene as a center and with the character detection distance as a radius according to the character position information and the character detection distance;

[0014] solving an inscribed rectangle area of the circular detection area to obtain the effective detection mesh area.

[0015] In an optional implementation, the step of extracting the plurality of target mesh edges from all mesh edges of the current game scene, wherein a projection position of each target mesh edge at least partially overlaps with the effective detection mesh area comprises:

[0016] traversing all the unit grids in the effective probe grid area, and for each unit grid traversed, querying whether there is a position corresponding edge segment of the unit grid traversed in the pre-stored map grid index data, wherein the map grid index data is used to record the position corresponding relationship between the line segment projection positions of all the edge segments respectively segmented by all the navigation grid edges in the two-dimensional map grid range and each unit grid in the two-dimensional map grid range;

[0017] In the case of querying at least one edge segment corresponding to the position of the unit grid traversed, the navigation grid edge to which each queried edge segment belongs is taken as one of the target grid edges.

[0018] In an optional implementation, the step of extracting the height position data of the character position information from the plurality of target grid edges includes:

[0019] traversing the plurality of target grid edges, and for each target grid edge traversed, detecting whether the height position data of the character position information is within the effective edge height range of the target grid edge traversed, wherein the vertex height data of the first edge vertex and the second edge vertex of each target grid edge is between the lower limit value and the upper limit value of the corresponding effective edge height range;

[0020] In the case of detecting that the height position data of the character position information is within the effective edge height range of the target grid edge traversed, the target grid edge traversed is taken as one of the expected grid edges.

[0021] In an optional implementation, the step of traversing the plurality of expected grid edges to determine the to-be-positioned grid edge with the shortest vertical distance from the target player character to each expected grid edge according to the character position information includes:

[0022] traversing the plurality of expected grid edges, and for each expected grid edge traversed, determining the projection vertical distance and the vertical projection point position of the projection edge segment between the two vertex projection positions according to the vertex projection positions of the first edge vertex and the second edge vertex of the expected grid edge in the two-dimensional map grid range and the character projection position of the character position information in the two-dimensional map grid range of the current game scene;

[0023] detecting whether the projection vertical distance is less than the current minimum vertical projection distance, and in the case of detecting that the projection vertical distance is less than the current minimum vertical projection distance, assigning the current minimum vertical projection distance with the projection vertical distance;

[0024] After traversing all the expected grid edges, the expected grid edge corresponding to the vertical projection point position matched with the final minimum vertical projection distance is taken as the grid edge to be positioned.

[0025] In an optional implementation, the step of taking the vertical point position of the grid edge to be positioned corresponding to the target player character as the expected following position of the target NPC following the target player character comprises:

[0026] According to the vertex position information of the first edge vertex and the second edge vertex of the grid edge to be positioned respectively, target point height data of a point projection position coinciding with the vertical projection point position of the grid edge to be positioned is determined on the grid edge to be positioned;

[0027] The target point height data and the vertical projection point position are positionally combined to obtain the vertical point position of the grid edge to be positioned corresponding to the target player character;

[0028] It is detected whether the projection vertical distance corresponding to the vertical point position exceeds the character detection distance;

[0029] In a case where it is detected that the projection vertical distance corresponding to the vertical point position does not exceed the character detection distance, the obtained vertical point position is taken as the expected following position of the target NPC.

[0030] In an optional implementation, the method further comprises:

[0031] For each game scene, vertex height identification is performed on the first edge vertex and the second edge vertex of each navigation grid edge of the game scene to obtain an effective edge height range of the navigation grid edge, wherein the vertex height data of the first edge vertex and the second edge vertex of each navigation grid edge is between the lower limit value and the upper limit value of the corresponding effective edge height range.

[0032] According to the unit grid size of the two-dimensional map grid range of the game scene, each navigation grid edge of the game scene is divided into a plurality of edge line segments, so that the projection line segment of each edge line segment in the two-dimensional map grid range occupies a unit grid.

[0033] A line segment projection position of all edge line segments in the two-dimensional map grid range and a position correspondence relationship between each unit grid in the two-dimensional map grid range are established to obtain map grid index data of the game scene.

[0034] In a second aspect, the application provides an NPC following position positioning device, which comprises:

[0035] A player position obtaining module is configured to obtain role position information of a target player character when the target player character is beyond a navigation mesh coverage range of a current game scene;

[0036] A detection area determining module is configured to determine, according to a preset character detection distance and the role position information, an effective detection mesh area of the target player character within a two-dimensional map mesh range of the current game scene, wherein the target player character is projected at a region center position of the effective detection mesh area;

[0037] An overlapping edge extracting module is configured to extract, from all navigation mesh edges of the current game scene, a plurality of target mesh edges whose projection positions at least partially overlap with the effective detection mesh area;

[0038] An effective edge extracting module is configured to extract, from the plurality of target mesh edges, a plurality of desired mesh edges whose height position data of the role position information are within a corresponding effective edge height range;

[0039] A following position positioning module is configured to determine, according to the role position information, a to-be-positioned mesh edge with a shortest vertical distance from the target player character among the plurality of desired mesh edges by traversing the plurality of desired mesh edges, and take a vertical point position corresponding to the target player character of the to-be-positioned mesh edge as a desired following position of a target NPC following the target player character.

[0040] In an optional implementation, the device further includes:

[0041] An edge height range determining module is configured to, for each game scene, perform vertex height identification on a first edge vertex and a second edge vertex of each navigation mesh edge of the game scene to obtain an effective edge height range of the navigation mesh edge, wherein the vertex height data of the first edge vertex and the second edge vertex of each navigation mesh edge are both between a lower limit value and an upper limit value of an edge height of the corresponding effective edge height range;

[0042] An edge line segment dividing module is configured to divide each navigation mesh edge of the game scene into a plurality of edge line segments according to a unit mesh size of a two-dimensional map mesh range of the game scene, so that a projection line segment of each edge line segment in the two-dimensional map mesh range occupies one unit mesh;

[0043] A map index constructing module is configured to establish a position correspondence relationship between line segment projection positions of all edge line segments in the two-dimensional map mesh range and each unit mesh in the two-dimensional map mesh range to obtain map mesh index data of the game scene.

[0044] In a third aspect, the present application provides a computer device, comprising a processor and a memory, wherein the memory stores a computer program capable of being executed by the processor, and the processor is capable of executing the computer program to implement the NPC following position positioning method according to any one of the preceding embodiments.

[0045] In this case, the beneficial effects of the embodiments of the present application can include the following:

[0046] The present application determines the effective detection grid area of the target player character in the two-dimensional map grid range of the current game scene by acquiring the character position information of the target player character when the target player character is beyond the navigation grid coverage range of the current game scene, and extracts a plurality of target grid edges from all navigation grid edges of the current game scene, which have at least partial overlap with the effective detection grid area, then extracts a plurality of expected grid edges from the plurality of target grid edges, in which the height position data of the character position information is in the corresponding effective edge height range, and then determines the to-be-positioned grid edge with the shortest vertical distance from the target player character to each expected grid edge by traversing the plurality of expected grid edges, and takes the vertical point position corresponding to the target player character of the to-be-positioned grid edge as the expected following position of the target NPC, so that in the case that the player character is not in the navigation grid coverage range, the navigation grid edge substantially adjacent to the player character is directly selected from the numerous navigation grid edges for closest point position positioning, thereby effectively reducing the operation resource consumption and time consumption of the NPC following position positioning process, and improving the following position positioning efficiency, and then quickly realizing the automatic following effect of the NPC, and improving the game experience of the game player.

[0047] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the following preferred embodiments are described in detail below, and the accompanying drawings are described as follows. BRIEF DESCRIPTION OF DRAWINGS

[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.

[0049] Figure 1 The composition schematic diagram of the computer device provided by the embodiments of the present application is shown in the following figure:

[0050] Figure 2 The flowchart of the NPC following position positioning method provided by the embodiments of the present application is shown in the following figure:

[0051] Figure 3 The flowchart of the NPC following position positioning method provided by the embodiments of the present application is shown in the following figure: Figure 2a flowchart of sub-steps included in step S220 in FIG. 2;

[0052] Figure 4 For Figure 2 a flowchart of sub-steps included in step S230 in FIG. 2;

[0053] Figure 5 For Figure 2 a flowchart of sub-steps included in step S240 in FIG. 2;

[0054] Figure 6 For Figure 2 a flowchart of sub-steps included in step S250 in FIG. 2;

[0055] Figure 7 a flowchart of the NPC following position positioning method provided by the embodiment of the present application;

[0056] Figure 8 a component diagram of the NPC following position positioning device provided by the embodiment of the present application;

[0057] Figure 9 a component diagram of the NPC following position positioning device provided by the embodiment of the present application.

[0058] Icon: 10-computer device; 11-memory; 12-processor; 13-communication unit; 100-NPC following position positioning device; 110-player position acquisition module; 120-detection area determination module; 130-overlapping edge extraction module; 140-valid edge extraction module; 150-following position positioning module; 160-edge height range determination module; 170-edge line segment segmentation module; 180-map index construction module. DETAILED DESCRIPTION

[0059] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. The components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations.

[0060] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts fall within the scope of protection of the present application.

[0061] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0062] In the description of this application, it should be understood that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product is in use, or the orientation or positional relationship commonly understood by those skilled in the art. They are used only for the convenience of describing this application and simplifying the description, and are not intended to indicate or imply that the equipment or component referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application.

[0063] In the description of this application, it should also be understood that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. Those skilled in the art will understand the specific meaning of the above terms in this application based on the specific circumstances.

[0064] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.

[0065] Please refer to Figure 1 , Figure 1is a constituent schematic diagram of a computer device 10 provided in the embodiment of the present application. In the embodiment of the present application, the computer device 10 can be a mobile terminal directly running a certain three-dimensional game, or a game server or other terminal device in communication connection with the mobile terminal running the three-dimensional game, wherein the mobile terminal can be, but is not limited to, a smart phone, a tablet computer, a notebook computer, etc. The computer device 10 can acquire the character position information of a player character when the player character exceeds the coverage range of a navigation mesh in a current game scene during the running of a three-dimensional game, and directly selects, from a plurality of navigation mesh edges corresponding to the current game scene, a navigation mesh edge substantially adjacent to the character position information of the player character to perform closest point position positioning, so as to effectively reduce the consumption of computing resources and the time consumption of the follow-up position positioning of the NPC in the process of the follow-up position positioning of the NPC, and improve the follow-up position positioning efficiency, thereby quickly realizing the automatic follow-up effect of the NPC and improving the game experience of the game player.

[0066] In the embodiment, the computer device 10 can include a memory 11, a processor 12, a communication unit 13 and an NPC follow-up position positioning apparatus 100. The memory 11, the processor 12 and the communication unit 13 are electrically connected to each other directly or indirectly to realize the transmission or interaction of data. For example, the memory 11, the processor 12 and the communication unit 13 can be electrically connected to each other through one or more communication buses or signal lines.

[0067] In the embodiment, the memory 11 can be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM) and the like. The memory 11 is used to store a computer program, and the processor 12 can execute the computer program correspondingly after receiving an execution instruction.

[0068] In the embodiment, the memory 11 is further configured to store grid edge data of all edges of each of the at least one game scene, wherein the grid edge data of a single navigation grid edge includes vertex position information of a first edge vertex and a second edge vertex of the corresponding navigation grid edge in a three-dimensional coordinate space, and an effective edge height range of the corresponding navigation grid edge. The vertex position information can include vertex height data, horizontal plane lateral position data and horizontal plane longitudinal position data of the corresponding edge vertex in the three-dimensional coordinate space, which can be represented by a three-dimensional coordinate (x, y, z), wherein x represents the horizontal plane lateral position data of the corresponding edge vertex, y represents the vertex height data of the corresponding edge vertex, and z represents the horizontal plane longitudinal position data of the corresponding edge vertex. The lower limit value of the edge height range is less than the minimum height data in the vertex height data of the first edge vertex and the second edge vertex of the corresponding navigation grid edge, and the upper limit value of the edge height range is greater than the maximum height data in the vertex height data of the first edge vertex and the second edge vertex of the corresponding navigation grid edge, i.e. the vertex height data of the first edge vertex and the second edge vertex of each target grid edge is between the lower limit value and the upper limit value of the corresponding effective edge height range. In an implementation form of the embodiment, the lower limit value of the edge height of the same target grid edge is 1 less than the corresponding minimum height data, and the upper limit value of the edge height of the same target grid edge is 1 greater than the corresponding maximum height data.

[0069] In the embodiment, the memory 11 is further configured to store map grid index data corresponding to each of the at least one game scene, wherein the map grid index data is used to record the line segment projection position of each edge segment segmented from each navigation grid edge in the two-dimensional map grid range of the game scene and the position correspondence between each unit grid in the two-dimensional map grid range. The two-dimensional map grid can be obtained by grid division processing of the two-dimensional map of the corresponding game scene in the horizontal plane (i.e. XOZ plane in the three-dimensional coordinate space), and the size of the unit grid in the two-dimensional map grid range can be 1 m / unit grid. Each projection line segment of the plurality of edge segments segmented from a single navigation grid edge occupies a unit grid in the two-dimensional map grid range, i.e. each edge segment corresponding to the same navigation grid edge has a corresponding unit grid in the two-dimensional map grid range. A single unit grid in the two-dimensional map grid range can correspond to a certain edge segment of a plurality of navigation grid edges, i.e. the projection line segments of the plurality of navigation grid edges can coincide at the same unit grid. A single unit grid in the two-dimensional map grid range can correspond to a certain edge segment of a single navigation grid edge. A single unit grid in the two-dimensional map grid range can not correspond to any edge segment.

[0070] In the embodiment, the processor 12 can be an integrated circuit chip with signal processing capability. The processor 12 can be a general processor, including at least one of a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc. The general processor can be a microprocessor or the processor can also be any conventional processor or the like, which can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments.

[0071] In the embodiment, the communication unit 13 is configured to establish a communication connection between the computer device 10 and other electronic devices through a network, and transmits and receives data through the network, where the network includes a wired communication network and a wireless communication network. For example, the computer device 10 can obtain, through the communication unit 13, role position information of a player role in a three-dimensional game in a three-dimensional coordinate space (which can be represented by three-dimensional coordinates (xa, ya, za), where xa represents horizontal transverse position data of the corresponding player role in the three-dimensional coordinate space, ya represents height position data of the corresponding player role in the three-dimensional coordinate space, and za represents horizontal longitudinal position data of the corresponding player role in the three-dimensional coordinate space).

[0072] In the embodiment, the NPC following position positioning apparatus 100 can include at least one software function module capable of being stored in the memory 11 in the form of software or firmware or stored in an operating system of the computer device 10. The processor 12 can be configured to execute executable modules stored in the memory 11, such as software function modules and computer programs included in the NPC following position positioning apparatus 100. The computer device 10 can directly select, through the NPC following position positioning apparatus 100, a navigation grid edge substantially adjacent to a player role from a plurality of navigation grid edges when the player role is not in the navigation grid coverage range, to perform closest point position positioning, so as to effectively reduce the consumption of computing resources and the time consumption of position positioning in the NPC following position positioning process, improve the following position positioning efficiency, and then quickly realize the automatic following effect of the NPC, and improve the game experience of the game player.

[0073] It can be understood that, Figure 1 It can be understood that, Figure 1more or less components than those shown, or configurations with different configurations and / or components than those shown. Figure 1 Figure 1 The components shown in the various embodiments can be implemented in hardware, software, or a combination thereof.

[0074] In the present application, in order to ensure that the computer device 10 can directly select the closest point position of the navigation grid edge substantially adjacent to the player character from a plurality of navigation grid edges when the player character is not within the navigation grid coverage range, so as to effectively reduce the consumption of computing resources and the time consumption of the position positioning process of the NPC following, improve the efficiency of the position positioning of the NPC following, and then quickly realize the automatic following effect of the NPC, and improve the game experience of the game player, the present application embodiment provides an NPC following position positioning method to achieve the foregoing purposes. The NPC following position positioning method provided by the present application will be described in detail below.

[0075] Please refer to Figure 2 , Figure 2 is one of the flowcharts of the NPC following position positioning method provided by the present application. In the present application embodiment, the NPC following position positioning method can include steps S210-S250.

[0076] Step S210, obtaining the character position information of the target player character when the target player character is out of the navigation grid coverage range of the current game scene.

[0077] In the present embodiment, the computer device 10 can obtain the actual character position information of the target player character in the current game scene in real time, compare the obtained actual character position information with the cubic space range representing the navigation grid coverage range of the current game scene, and determine that the actual character position information at this time is the character position information of the target player character when the target player character is out of the navigation grid coverage range of the current game scene when the actual character position information is out of the cubic space range.

[0078] Step S220, determining the effective detection grid area of the target player character in the two-dimensional map grid range of the current game scene according to a preset character detection distance and the character position information.

[0079] In the present embodiment, the character detection distance is used to represent the maximum detection distance for detecting the closest point position on the surrounding navigation grid edge of the target player character. The region center position of the effective detection grid area where the target player character is projected is the character projection position (which can be represented by two-dimensional coordinates (xa, za)) of the target player character in the two-dimensional map grid range, that is, the character position information of the target player character. ​

[0080] Optionally, please refer to Figure 3 Figure 3 is Figure 2 The flowchart of the sub-steps included in step S220. In the embodiment of the present application, the effective detection grid area can be a rectangular area, at this time, the step S220 can include sub-step S221 to sub-step S222 to accurately determine the rectangular effective detection grid area of the target player character in the current game scene.

[0081] Sub-step S221, according to the character position information in the two-dimensional map grid range of the current game scene, the character projection position and the character detection distance, a circular detection area is constructed with the character projection position as the center and the character detection distance as the radius.

[0082] Sub-step S222, the circumscribed rectangular area of the circular detection area is solved to obtain the effective detection grid area.

[0083] In the embodiment, there are four vertices (xa-x1, za), (xa+x1, za), (xa, za-z1), (xa, za+z1) on the edge of the circular detection area, the circumscribed rectangular area of the circular detection area can be circumscribed by four corner points (xa-x1, za-z1), (xa+x1, za-z1), (xa-x1, za+z1) and (xa+x1, za+z1), and the constructed effective detection grid area can be circumscribed by four corner point coordinates (ROUNDUP(xa-x1, 0), ROUNDUP(za-z1, 0)), (ROUNDUP(xa+x1, 0), ROUNDUP(za-z1, 0)), (ROUNDUP(xa-x1, 0), ROUNDUP(za+z1, 0)) and (ROUNDUP(xa+x1, 0), ROUNDUP(za+z1, 0)), wherein x1 and z1 are both the character detection distance, at this time, the grid index array of each of the plurality of unit grids substantially existing in the effective detection grid area is [ROUNDUP(xa-x1, 0):ROUNDUP(xa+x1, 0), ROUNDUP(za-z1, 0):ROUNDUP(za+z1, 0)], and the total number of unit grids substantially existing in the effective detection grid area is {ROUNDUP(xa+x1, 0)-ROUNDUP(xa-x1, 0)+1}*{ROUNDUP(za+z1, 0)-ROUNDUP(za-z1, 0)+1}, wherein the ROUNDUP(, 0) function is the rounding up function, and the 0 in the rounding up function is used to represent that 0 decimal places need to be retained.

[0084] ​Therefore, the target player character in the current game scene can be accurately determined by performing the above sub-step S221 to sub-step S222.

[0085] Step S230, extracting a plurality of target grid edges from all navigation grid edges of the current game scene, which have at least partially overlapped with the projection position of the effective detection grid region.

[0086] In the embodiment, after obtaining the effective detection grid region of the target player character in the current game scene, the computer device 10 can extract a plurality of target grid edges from all navigation grid edges of the current game scene, so that the corresponding whole edge projection position of each target grid edge in the two-dimensional map grid range can effectively occupy at least one unit grid in the effective detection grid region. At this time, the target grid edge is the navigation grid edge which is substantially adjacent to the target player character in the horizontal plane.

[0087] Please refer to Figure 4 , Figure 4 is Figure 2 Step S230 in the embodiment of the present application includes a flowchart of the sub-steps. In the embodiment of the present application, the step S230 can include sub-step S231 to sub-step S232, so as to filter the navigation grid edge which is substantially adjacent to the target player character in the horizontal plane from the plurality of navigation grid edges corresponding to the current game scene.

[0088] Sub-step S231, traversing all unit grids in the effective detection grid region, and for each unit grid traversed, querying whether the position corresponding edge line segment of the traversed unit grid exists in the pre-stored map grid index data.

[0089] In the embodiment, the map grid index data corresponding to the current game scene is used to record the position corresponding relationship between the line segment projection position of each edge line segment divided by all navigation grid edges in the current game scene in the two-dimensional map grid range and each unit grid in the two-dimensional map grid range, wherein the line segment projection position of each edge line segment in the two-dimensional map grid range occupies one unit grid, and the same unit grid can be occupied by the line segment projection position of one edge line segment of different navigation grid edges. Therefore, the computer device 10 can traverse all unit grids in the effective detection grid region, and query whether each unit grid traversed is occupied by the line segment projection position of one or more edge line segments of the navigation grid edge, so as to determine which navigation grid edge exists in the plurality of navigation grid edges corresponding to the current game scene which is detected by the effective detection grid region.

[0090] Sub-step S232, in the case of querying at least one edge line segment corresponding to the unit grid position traversed, taking the navigation grid edge to which each edge line segment queried belongs as a target grid edge.

[0091] In the embodiment, when the computer device 10 traverses to a single unit grid within the effective detection grid area corresponding to at least one edge line segment, it means that the navigation grid edge to which each edge line segment corresponding to the unit grid belongs is substantially detected by the effective detection grid area, and the navigation grid edge to which each edge line segment corresponding to the unit grid belongs can be substantially adjacent to the target grid edge of the target player character in the horizontal plane; when the computer device 10 traverses to a single unit grid within the effective detection grid area and does not correspond to any edge line segment, it means that the unit grid is not occupied by the whole edge projection position of any navigation grid edge.

[0092] Therefore, the application can filter the navigation grid edge substantially adjacent to the target player character in the horizontal plane from the plurality of navigation grid edges corresponding to the current game scene by executing the above-mentioned sub-step S231 to sub-step S232.

[0093] Step S240, extracting a plurality of expected grid edges in which the height position data of the character position information is in the corresponding effective edge height range from the plurality of target grid edges.

[0094] In the embodiment, after the computer device 10 filters the target grid edge substantially adjacent to the target player character in the horizontal plane from the plurality of navigation grid edges corresponding to the current game scene, the target grid edge having the effective edge height range including the height position data of the character position information can be filtered from the plurality of target grid edges according to the height position data (i.e., ya) of the character position information and the effective edge height range of each target grid edge, and the filtered target grid edge is taken as the expected grid edge substantially adjacent to the target player character in the three-dimensional coordinate space of the current game scene.

[0095] Optionally, please refer to Figure 5 , Figure 5 is Figure 2 the flowchart of the sub-step included in step S240 in

[0096] Sub-step S241, traversing the plurality of target grid edges, and detecting whether the height position data of the character position information is in the effective edge height range of the target grid edge traversed for each target grid edge traversed.

[0097] The vertex height data of each of the first edge vertex and the second edge vertex of each target mesh edge is between the lower limit value and the upper limit value of the corresponding valid edge height range. The vertex position information of the first edge vertex of a single target mesh edge can be three-dimensional coordinates (xp1, yp1, zp1), the vertex position information of the second edge vertex of the target mesh edge can be three-dimensional coordinates (xp2, yp2, zp2), and the valid edge height range of the target mesh edge is [min(yp1, yp2)-1]~[max(yp1, yp2)+1]. xp1 represents the horizontal transverse position data of the first edge vertex, yp1 represents the vertex height data of the first edge vertex, zp1 represents the horizontal longitudinal position data of the first edge vertex, xp2 represents the horizontal transverse position data of the second edge vertex, yp2 represents the vertex height data of the second edge vertex, and zp2 represents the horizontal longitudinal position data of the second edge vertex.

[0098] In the case where the height position data of the character position information is detected to be in the valid edge height range of the target mesh edge that is traversed, the target mesh edge that is traversed is taken as a desired mesh edge in substep S242.

[0099] In the embodiment, when the height position data of the target player character exists in the valid edge height range of a certain target mesh edge that is traversed by the computer device 10, it indicates that the target mesh edge is substantially adjacent to the target player character in the vertical direction in the three-dimensional coordinate space, and the target mesh edge can be taken as a desired mesh edge that is substantially adjacent to the target player character in the three-dimensional coordinate space. When the height position data of the target player character does not exist in the valid edge height range of a certain target mesh edge that is traversed by the computer device 10, it indicates that the target mesh edge is substantially away from the target player character in the vertical direction in the three-dimensional coordinate space.

[0100] Therefore, the application can filter the navigation mesh edges that are substantially adjacent to the target player character in the three-dimensional coordinate space from the plurality of navigation mesh edges corresponding to the current game scene by executing the above substeps S241-S242.

[0101] In step S250, the plurality of desired mesh edges are traversed to determine a to-be-positioned mesh edge in which the vertical distance from the target player character is the shortest according to the character position information, and the vertical point position corresponding to the target player character in the to-be-positioned mesh edge is taken as a desired following position of the target NPC following the target player character.

[0102] In the embodiment, after the computer device 10 filters out the navigation grid edges (i.e. expected grid edges) substantially closest to the target player character in the three-dimensional coordinate space from the navigation grid edges corresponding to the current game scene, the computer device 10 can filter out the expected grid edge with the shortest projection vertical distance of the character position information of the target player character in the horizontal plane from the plurality of expected grid edges, as the to-be-positioned grid edge with the shortest vertical distance to the target player character in the three-dimensional coordinate space, and determine the character projection point position of the character position information of the target player character projected onto the to-be-positioned grid edge as the vertical point position corresponding to the target player character of the to-be-positioned grid edge. At this time, the vertical point position is the target point position closest to the target player character in the navigation grid coverage range of the current game scene, and the target point position is the expected following position of the target NPC following the target player character. The projection vertical distance is used to represent the vertical distance value of the character projection position (which can be represented by two-dimensional coordinates (xa, za)) of the character position information in the horizontal plane to the whole edge projection line segment (which can be represented by a line segment between two-dimensional coordinates (xp1, zp1) and two-dimensional coordinates (xp2, zp2)) of the corresponding expected grid edge in the horizontal plane.

[0103] Optionally, referring to Figure 6 , Figure 6 is Figure 2 the flowchart of the sub-steps included in step S250. In the embodiment, the step of "determining the to-be-positioned grid edge with the shortest vertical distance of the target player character to each expected grid edge according to the character position information" in step S250 can include sub-step S251 to sub-step S253, so as to filter out the navigation grid edge closest to the target player character in the three-dimensional coordinate space from the plurality of navigation grid edges corresponding to the current game scene.

[0104] In sub-step S251, the plurality of expected grid edges are traversed, and for each expected grid edge traversed, the projection vertical distance and the vertical projection point position of the projection edge line segment between the character projection position and the two vertex projection positions are determined according to the vertex projection positions of the first edge vertex and the second edge vertex of the expected grid edge in the two-dimensional map grid range and the character projection position of the character position information in the two-dimensional map grid range of the current game scene.

[0105] In the embodiment, for a single desired grid edge, the vertical projection point position is the specific projection position (which can be represented by two-dimensional coordinates (xp3, zp3)) of the character projection point position (vertical point position) of the corresponding desired grid edge in the horizontal plane. When calculating the projection vertical distance corresponding to the desired grid edge, the computer device 10 can determine the first projection vector (xp2-xp1, zp2-zp1) of the first vector (xp2-xp1, yp2-yp1, zp2-zp1) pointing from the first edge vertex to the second edge vertex in the horizontal plane based on the vertex projection positions (i.e., two-dimensional coordinates (xp1, zp1) and two-dimensional coordinates (xp2, zp2)) of the first edge vertex and the second edge vertex in the two-dimensional map grid range, and determine the second projection vector (xa-xp1, za-zp1) of the second vector pointing from the first edge vertex to the character projection position (which can be represented by two-dimensional coordinates (xa, za)) of the character position information based on the vertex projection position of the first edge vertex and the character projection position of the character position information, and then obtain the distance between the vertical projection point position and the vertex projection position of the first edge vertex in the whole edge projection line segment (i.e., the projection edge line segment) of the desired grid edge by performing vector dot multiplication operation on the first projection vector and the second projection vector, and then determine the projection vertical distance of the projection edge line segment between the character projection position and the two vertex projection positions based on the vector length of the second projection vector by using the Pythagorean theorem, and determine the vertical projection point position (xp3, zp3) on the desired grid edge based on the first projection vector and the vertex projection position of the first edge vertex by using the vector proportional enlargement principle.

[0106] In the sub-step S252, it is detected whether the projection vertical distance is less than the current minimum vertical projection distance, and in the case where it is detected that the projection vertical distance is less than the current minimum vertical projection distance, the current minimum vertical projection distance is assigned with the projection vertical distance.

[0107] In the embodiment, the specific value of the current minimum vertical projection distance recorded by the computer device 10 when traversing to the first desired grid edge is the preset distance value.

[0108] In the sub-step S253, in the case where all the desired grid edges are traversed, the desired grid edge corresponding to the vertical projection point position matched with the final minimum vertical projection distance is taken as the grid edge to be positioned.

[0109] In the embodiment, when the computer device 10 traverses all the expected grid edges, the final minimum vertical projection distance is actually the closest projected vertical distance of the plurality of navigation grid edges to the target player character in the horizontal plane, and at this time, the expected grid edge corresponding to the vertical projection point position matched with the minimum vertical projection distance can be taken as the to-be-positioned grid edge.

[0110] Therefore, the application can filter the navigation grid edge closest to the target player character in the three-dimensional coordinate space from the plurality of navigation grid edges corresponding to the current game scene by executing the above-mentioned sub-step S251 to sub-step S253.

[0111] In this case, in an embodiment of the embodiment, the step of taking the vertical point position of the to-be-positioned grid edge corresponding to the target player character as the expected following position of the target NPC following the target player character can include:

[0112] determining target point height data of a point projection position coinciding with the vertical projection point position of the to-be-positioned grid edge on the to-be-positioned grid edge according to the vertex position information of the first edge vertex and the second edge vertex of the to-be-positioned grid edge;

[0113] positionally combining the target point height data and the vertical projection point position to obtain the vertical point position of the to-be-positioned grid edge corresponding to the target player character;

[0114] taking the obtained vertical point position as the expected following position of the target NPC.

[0115] The target point height data (which can be represented by yp3) of the target point on the first vector that can be projected to the vertical projection point position can be effectively determined based on the vertex projection position and the vertical projection point position of the first edge vertex of the to-be-positioned grid edge by using the vector equal proportion magnification principle on the basis of the first vector corresponding to the to-be-positioned grid edge, and at this time, the vertical point position of the to-be-positioned grid edge can be represented by three-dimensional coordinates (xp3, yp3, zp3).

[0116] Therefore, the application can directly select a certain point position closest to the player character as the expected following position of the target NPC from the navigation grid edge substantially close to the player character by executing the above-mentioned specific step flow of selecting the expected following position.

[0117] In another embodiment of the embodiment, the step of taking the vertical point position of the to-be-positioned grid edge corresponding to the target player character as the expected following position of the target NPC following the target player character can include:

[0118] According to the vertex position information of the first edge vertex and the second edge vertex of the to-be-positioned grid edge, target point height data of a point on the to-be-positioned grid edge is determined, where a point projection position coincides with a vertical projection point position of the to-be-positioned grid edge;

[0119] The target point height data is positionally combined with the vertical projection point position to obtain a vertical point position of the to-be-positioned grid edge corresponding to the target player character;

[0120] It is detected whether a projection vertical distance corresponding to the vertical point position exceeds the character detection distance;

[0121] In a case where it is detected that the projection vertical distance corresponding to the vertical point position does not exceed the character detection distance, the obtained vertical point position is taken as an expected following position of the target NPC.

[0122] Therefore, by performing the specific step flow of selecting the expected following position, a point position closest to a player character and substantially within a character detection range of the player character can be selected as an expected following position of an NPC from a grid edge of a navigation grid substantially close to the character position information of the player character.

[0123] In this case, by performing the steps S210-S250, character position information of a player character exceeding a coverage range of a navigation grid in a current game scene can be obtained during a three-dimensional game running process, and a grid edge of a navigation grid substantially close to the character position information of the player character can be directly selected from a plurality of grid edges of the navigation grid corresponding to the current game scene for closest point position positioning, so as to effectively reduce the consumption of operation resources and the time consumption of position positioning during NPC following position positioning, improve the efficiency of following position positioning, and thus quickly realize automatic following of the NPC and improve the game experience of a game player.

[0124] Optionally, please refer to Figure 7 , Figure 7 is a flowchart of an NPC following position positioning method provided by an embodiment of the application. In the embodiment of the application, compared with the NPC following position positioning method shown in Figure 2 , the NPC following position positioning method shown in Figure 7 may further include steps S260-S280, so as to effectively reduce the consumption of operation resources and the time consumption of position positioning during NPC following position positioning, improve the efficiency of following position positioning, and thus quickly realize automatic following of the NPC and improve the game experience of a game player.

[0125] Step S260, for each game scene, vertex height identification is performed on the first edge vertex and the second edge vertex of each navigation mesh edge of the game scene, to obtain an effective edge height range of the navigation mesh edge.

[0126] In this embodiment, the vertex height data of the first edge vertex and the second edge vertex of each navigation mesh edge is between the lower limit value and the upper limit value of the corresponding effective edge height range. The computer device 10 can create an edge data list file (for example, an EdgeDataList file in the format of edgedatas.bytes) for each game scene, to record the effective edge height range of each navigation mesh edge, the vertex position information of the first edge vertex and the vertex position information of the second edge vertex in the corresponding game scene through the edge data list file.

[0127] Step S270, according to the unit mesh size of the two-dimensional map mesh range of the game scene, each navigation mesh edge of the game scene is divided into a plurality of edge line segments, so that the projection line segment of each edge line segment in the two-dimensional map mesh range occupies one unit mesh.

[0128] Step S280, the position correspondence relationship between the line segment projection position of each edge line segment in the two-dimensional map mesh range and each unit mesh in the two-dimensional map mesh range is established, to obtain the map mesh index data of the game scene.

[0129] In this embodiment, the computer device 10 can create a map mesh index file (for example, an EdgeMapData file in the format of edgemapdatas.bytes) for each game scene, to effectively record the projection position correspondence relationship between each unit mesh and the plurality of edge line segments corresponding to each navigation mesh edge of the corresponding game scene through the map mesh index file.

[0130] When the computer device 10 needs to determine the projection position corresponding relationship of a single navigation grid edge, the computer device 10 can directly perform down-rounding operation on the vertex projection positions of the first edge vertex and the second edge vertex of the navigation grid edge, to obtain the grid index arrays [INT(xp1), INT(zp1)] and [INT(xp2), INT(zp2)] of the cell grid corresponding to the projection positions of the first edge vertex and the second edge vertex of the navigation grid edge in the two-dimensional map grid range, and then fit the fitting curve "K*x+b=z" of the whole edge projection line segment of the navigation grid edge in the horizontal plane by using the vertex projection positions of the first edge vertex and the second edge vertex, and then substitute INT(xp1)+1 to INT(xp2) into the fitting curve one by one to solve the array longitudinal index values corresponding to INT(xp1)+1 to INT(xp2) respectively, and combine the array longitudinal index values and the array transverse index values corresponding to the fitting curve to form the grid index array representing the cell grid occupied by the edge line segment of the navigation grid edge.

[0131] In this case, the computer device 10 can record the number of whole edge projection line segments and the edge identifier of the navigation grid edge involved in each cell grid in the two-dimensional map grid range of the corresponding game scene in a single map grid index file, to obtain the map grid index data corresponding to the game scene.

[0132] Therefore, the present application can establish the projection position corresponding relationship between the navigation network edge and the two-dimensional map grid of each game scene that may be involved in the three-dimensional game running process in advance by executing the steps S260-S280, thereby effectively reducing the consumption of operation resources and the time consumption of the NPC following position positioning process, improving the following position positioning efficiency, and further quickly realizing the automatic following effect of the NPC and improving the game experience of the game player.

[0133] In the present application, in order to ensure that the computer device 10 can execute the NPC following position positioning method by using the NPC following position positioning device 100, the present application realizes the functions by dividing the NPC following position positioning device 100 into functional modules. The specific components of the NPC following position positioning device 100 provided by the present application are described as follows.

[0134] Please refer to Figure 8 , Figure 8is one of the component schematic diagrams of the NPC following position positioning device 100 provided in the embodiments of the present application. In the embodiments of the present application, the NPC following position positioning device 100 can include a player position obtaining module 110, a detection area determining module 120, an overlapping edge extracting module 130, an effective edge extracting module 140, and a following position positioning module 150.

[0135] The player position obtaining module 110 is configured to obtain the character position information of the target player character when the target player character is out of the navigation mesh coverage range of the current game scene.

[0136] The detection area determining module 120 is configured to determine, according to the preset character detection distance and the character position information, an effective detection mesh area of the target player character in the two-dimensional map mesh range of the current game scene, wherein the target player character is projected at a region center position of the effective detection mesh area.

[0137] The overlapping edge extracting module 130 is configured to extract, from all the navigation mesh edges of the current game scene, a plurality of target mesh edges whose projection positions at least partially overlap with the effective detection mesh area.

[0138] The effective edge extracting module 140 is configured to extract, from the plurality of target mesh edges, a plurality of desired mesh edges whose height position data of the character position information is in the corresponding effective edge height range.

[0139] The following position positioning module 150 is configured to traverse the plurality of desired mesh edges to determine, according to the character position information, a to-be-positioned mesh edge with the shortest vertical distance from the target player character to each desired mesh edge, and take the vertical point position corresponding to the target player character of the to-be-positioned mesh edge as the desired following position of the target NPC following the target player character.

[0140] Optionally, please refer to Figure 9 , Figure 9 is the second component schematic diagram of the NPC following position positioning device 100 provided in the embodiments of the present application. In the embodiments of the present application, the NPC following position positioning device 100 can further include an edge height range determining module 160, an edge line segment dividing module 170, and a map index constructing module 180.

[0141] The edge height range determining module 160 is configured to, for each game scene, perform vertex height identification on a first edge vertex and a second edge vertex of each navigation mesh edge of the game scene to obtain an effective edge height range of the navigation mesh edge, wherein the vertex height data of each of the first edge vertex and the second edge vertex is between a lower limit value and an upper limit value of the edge height of the corresponding effective edge height range.

[0142] The edge segment dividing module 170 is configured to divide each navigation grid edge of the game scene into a plurality of edge segments according to a unit grid size of the two-dimensional map grid range of the game scene, so that a projection line segment of each edge segment in the two-dimensional map grid range occupies one unit grid.

[0143] The map index constructing module 180 is configured to establish a position correspondence between a line segment projection position of each projection line segment of all edge segments in the two-dimensional map grid range and each unit grid in the two-dimensional map grid range, to obtain map grid index data of the game scene.

[0144] It should be noted that the NPC following position positioning device 100 provided in the embodiments of the present application has the same basic principle and technical effects as the NPC following position positioning method. For brevity, the description of the NPC following position positioning device 100 is not mentioned in some parts of the embodiments, and reference can be made to the description of the NPC following position positioning method.

[0145] In the embodiments provided in the present application, it should be understood that the disclosed device and method can also be implemented in other manners. The device embodiments described above are only schematic. For example, the flowcharts and block diagrams in the drawings show the possible implementation architectures, functions and operation of the device, method and computer program product according to the embodiments of the present application. In this regard, each block in the flowcharts and block diagrams can represent a module, a program segment or a part of code, which contains one or more executable instructions for implementing the specified logic function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in a different order than that noted in the drawings. For example, two consecutive blocks can actually be executed in parallel, and sometimes they can be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and the combination of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.

[0146] In addition, each functional module in the various embodiments of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part. When the functions are realized in the form of a software functional module and sold or used as an independent product, the software functional module can be stored in a readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of a software product, and the computer software product is stored in a readable storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the various embodiments of the present application. The aforementioned readable storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0147] To sum up, in the NPC following position positioning method, device and computer equipment provided by the embodiments of the present application, by acquiring the character position information of the target player character when the target player character is beyond the navigation grid coverage range of the current game scene, determining the effective detection grid area of the target player character within the two-dimensional map grid range of the current game scene, and extracting a plurality of target grid edges from all the navigation grid edges of the current game scene, the projection position of which at least partially overlaps with the effective detection grid area, then extracting a plurality of expected grid edges from the plurality of target grid edges, the height position data of the character position information of which is within the corresponding effective edge height range, and then determining the to-be-positioned grid edge with the shortest vertical distance from the target player character to each expected grid edge by traversing the plurality of expected grid edges, and taking the vertical point position corresponding to the target NPC of the to-be-positioned grid edge as the expected following position of the target NPC, the navigation grid edge substantially adjacent to the player character is directly screened from the numerous navigation grid edges for closest point position positioning in the case that the player character is not within the navigation grid coverage range, so as to effectively reduce the operation resource consumption and time consumption of the NPC following position positioning process, and improve the following position positioning efficiency, and then quickly realize the automatic following effect of the NPC, and improve the game experience of the game player.

[0148] The above is only various embodiments of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method of locating a NPC following position, characterized by, The method comprises: acquiring role position information of a target player role when the target player role is beyond the coverage range of a navigation mesh of a current game scene; determining, according to a preset role detection distance and the role position information, an effective detection mesh area of the target player role within a two-dimensional map mesh range of the current game scene, wherein the target player role is projected at a region center position of the effective detection mesh area; extracting, based on pre-stored map mesh index data, a plurality of target mesh edges from all navigation mesh edges of the current game scene, wherein the projection position of the target mesh edges at least partially overlaps with the effective detection mesh area, and the map mesh index data is used to record the position correspondence between the line segment projection position of all line segments respectively segmented by all navigation mesh edges within the two-dimensional map mesh range and each unit mesh within the two-dimensional map mesh range; extracting, from the plurality of target mesh edges, a plurality of expected mesh edges in which the height position data of the role position information is within the corresponding effective edge height range, wherein the vertex height data of the first edge vertex and the second edge vertex of each target mesh edge is between the lower limit value and the upper limit value of the edge height of the corresponding effective edge height range; traversing the plurality of expected mesh edges to determine, according to the role position information, a to-be-positioned mesh edge with the shortest vertical distance from the target player role to each expected mesh edge, and taking the vertical point position corresponding to the target player role of the to-be-positioned mesh edge as an expected following position of a target NPC following the target player role.

2. The method of claim 1, wherein, The step of determining, according to a preset role detection distance and the role position information, an effective detection mesh area of the target player role within a two-dimensional map mesh range of a current game scene comprises: constructing a circular detection region with the role projection position within the two-dimensional map mesh range of the current game scene as the center and the role detection distance as the radius according to the role projection position and the role detection distance; solving the circumscribed rectangular region of the circular detection region to obtain the effective detection mesh area.

3. The method of claim 1, wherein, The step of extracting, based on pre-stored map mesh index data, a plurality of target mesh edges from all navigation mesh edges of the current game scene, wherein the projection position of the target mesh edges at least partially overlaps with the effective detection mesh area, comprises: traversing all unit meshes within the effective detection mesh area, and for each traversed unit mesh, querying whether there is a position corresponding line segment in the pre-stored map mesh index data; in the case that at least one line segment corresponding to the position of the traversed unit mesh is queried, taking the navigation mesh edge to which each queried line segment belongs as a target mesh edge.

4. The method of claim 1, wherein, The step of extracting, from the plurality of target mesh edges, a plurality of expected mesh edges in which the height position data of the role position information is within the corresponding effective edge height range, comprises: traversing the plurality of target mesh edges, and for each traversed target mesh edge, detecting whether the height position data of the role position information is within the effective edge height range of the traversed target mesh edge; In a case where it is detected that the height position data of the character position information is within the valid edge height range of the target grid edge that is traversed, the target grid edge that is traversed is taken as one of the expected grid edges.

5. The method of claim 1, wherein, The step of traversing a plurality of expected grid edges and determining, according to the character position information, the to-be-positioned grid edge with the shortest vertical distance from the target player character to each expected grid edge, comprises: traversing a plurality of expected grid edges, and for each expected grid edge that is traversed, determining, according to the vertex projection positions of the first edge vertex and the second edge vertex of the expected grid edge in the two-dimensional map grid range and the character projection position of the character position information in the two-dimensional map grid range of the current game scene, the projection vertical distance and the vertical projection point position of the projection edge segment between the character projection position and the two vertex projection positions; detecting whether the projection vertical distance is less than the current minimum vertical projection distance, and in a case where it is detected that the projection vertical distance is less than the current minimum vertical projection distance, assigning the current minimum vertical projection distance with the projection vertical distance; in a case where all expected grid edges are traversed, taking the expected grid edge corresponding to the final minimum vertical projection distance as the to-be-positioned grid edge.

6. The method of claim 5, wherein, The step of taking the vertical point position of the to-be-positioned grid edge corresponding to the target player character as the expected following position of the target NPC following the target player character, comprises: determining, according to the vertex position information of the first edge vertex and the second edge vertex of the to-be-positioned grid edge, the target point height data of the point on the to-be-positioned grid edge at which the point projection position coincides with the vertical projection point position of the to-be-positioned grid edge; combining the target point height data and the vertical projection point position to obtain the vertical point position of the to-be-positioned grid edge corresponding to the target player character; detecting whether the projection vertical distance corresponding to the vertical point position exceeds the character detection distance; in a case where it is detected that the projection vertical distance corresponding to the vertical point position does not exceed the character detection distance, taking the obtained vertical point position as the expected following position of the target NPC.

7. The method according to any one of claims 1 to 6, characterized in that, The method further comprises: for each game scene, performing vertex height identification on the first edge vertex and the second edge vertex of each navigation grid edge of the game scene to obtain the valid edge height range of the navigation grid edge, wherein the vertex height data of the first edge vertex and the second edge vertex of each navigation grid edge is between the lower edge height limit value and the upper edge height limit value of the corresponding valid edge height range; dividing each navigation grid edge of the game scene into a plurality of edge segments according to the unit grid size of the two-dimensional map grid range of the game scene, so that the projection line segment of each edge segment in the two-dimensional map grid range occupies one unit grid; establishing a position correspondence relationship between the line segment projection positions of all edge segments in the two-dimensional map grid range and each unit grid in the two-dimensional map grid range to obtain the map grid index data of the game scene.

8. An NPC follow position positioning apparatus characterized by, The device comprises: The player position acquisition module is configured to acquire character position information of the target player character when the target player character is beyond a navigation mesh coverage range of a current game scene; The detection area determination module is configured to determine, according to a preset character detection distance and the character position information, an effective detection mesh area of the target player character within a two-dimensional map mesh range of the current game scene, wherein the target player character is projected at a region center position of the effective detection mesh area; The overlapping edge extraction module is configured to extract, based on pre-stored map mesh index data, a plurality of target mesh edges from all navigation mesh edges of the current game scene, wherein the map mesh index data is used to record a position correspondence relationship between a line segment projection position of each segmented line segment of all navigation mesh edges within the two-dimensional map mesh range and each unit mesh within the two-dimensional map mesh range; The effective edge extraction module is configured to extract, from the plurality of target mesh edges, a plurality of desired mesh edges in which height position data of the character position information is within a corresponding effective edge height range, wherein vertex height data of a first edge vertex and a second edge vertex of each target mesh edge is between a lower edge height limit value and an upper edge height limit value of the corresponding effective edge height range; The following position positioning module is configured to determine, by traversing the plurality of desired mesh edges, a to-be-positioned mesh edge in which a vertical distance from the target player character is the shortest, and to set a vertical point position corresponding to the target player character of the to-be-positioned mesh edge as a desired following position of a target NPC following the target player character.

9. The apparatus of claim 8, wherein, The device further comprises: The edge height range determination module is configured to, for each game scene, identify vertex height of a first edge vertex and a second edge vertex of each navigation mesh edge of the game scene to obtain an effective edge height range of the navigation mesh edge, wherein vertex height data of the first edge vertex and the second edge vertex of each navigation mesh edge is between a lower edge height limit value and an upper edge height limit value of the corresponding effective edge height range; The edge line segment segmentation module is configured to segment each navigation mesh edge of the game scene into a plurality of edge line segments according to a unit mesh size of a two-dimensional map mesh range of the game scene, so that a projection line segment of each edge line segment within the two-dimensional map mesh range occupies one unit mesh; The map index construction module is configured to establish a position correspondence relationship between a line segment projection position of each projection line segment of all edge line segments within the two-dimensional map mesh range and each unit mesh within the two-dimensional map mesh range to obtain map mesh index data of the game scene.

10. A computer device, comprising: The device comprises a processor and a memory, the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the NPC following position positioning method in any one of claims 1-7.

Citation Information

Patent Citations

  • Control method, control device and control equipment for non-player character and storage medium

    CN109731332A

  • Game device, game control method and game control program

    JP2009233207A