NPC position synchronization method, apparatus and device, and storage medium
By determining the leader NPCs in the metaverse and transmitting the position information of ordinary NPCs in the form of direction angles and distances, the problems of large data volume and high network delay during position synchronization of NPC groups are solved, achieving more efficient data transmission and smoother user experience.
Patent Information
- Application Number
- CN202411717243.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-02-28
AI Technical Summary
In the metaverse, when the location of the NPC group is synchronized, the amount of data transmitted is large, resulting in high network bandwidth consumption, which may cause excessive server load or insufficient bandwidth, increase network latency, and affect user experience.
By determining the leader NPC on the server and transmitting the position information of the ordinary NPC in the form of direction angles and distances, rather than transmitting the specific coordinate position, the data transmission amount is reduced. At the same time, after receiving the client, the coordinate position of the ordinary NPC is calculated through the direction vector of the leader NPC.
It reduces the data transmission amount and network latency during NPC location synchronization, reduces bandwidth consumption, and improves user experience.
Smart Images

Figure CN119544775A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an NPC position synchronization method, device, equipment and storage medium. Background Art
[0002] The concept of the metaverse is a 3D platform where users can participate in an increasingly mature virtual world. The metaverse is user-centric and is seen as a continuation of the development of the Internet. One of the core elements of the metaverse is to provide a realistic immersive experience where users can play games, shop, and even work. In the metaverse, in addition to users, there are also a large number of non-player characters (NPCs).
[0003] NPCs can enhance this sense of immersion, making players feel more truly in a vibrant virtual world. NPCs are often used to advance the storyline, provide users with mission backgrounds and goals, and can also introduce new users to the geographical, political, and social environment of the metaverse world and provide tutorials or operating guides. There are also some NPCs that are part of the world themselves and also have the function of interacting with user characters while maintaining a certain degree of groupness, such as flocks of geese arranged in different shapes, herds of running bison, etc. NPC groups are usually composed of a large number of NPC individuals. In order to ensure that players see consistent situations in the same world, when the positions of NPC individuals change, the positions of these NPC individuals need to be synchronized on the client to ensure that the interaction between users and NPC individuals is real-time and accurate.
[0004] The position of an NPC individual is in the format of (x, y, z), where x, y, and z are all in float format, each occupying 4 bytes. Each time the position of an NPC individual is synchronized, the position of the NPC individual in the NPC group needs to be sent from the server to the client. The transmission of an NPC individual position requires 12 bytes; if there are a large number of NPC individuals in the NPC group, a large number of bytes will be occupied when synchronizing the position. Accordingly, a large amount of bandwidth will be consumed, which may cause the server to be overloaded or the bandwidth to be insufficient. In addition, a large amount of location data is frequently transmitted between the server and the client, which may increase network latency, causing freezes and delays in the application, affecting the user experience. Summary of the invention
[0005] The present application provides an NPC position synchronization method, apparatus, device and storage medium, which are used to reduce the amount of data transmitted during NPC position synchronization, reduce network latency and improve user experience.
[0006] In a first aspect, the present application provides an NPC position synchronization method, the method comprising:
[0007] The server determines a leader NPC from the NPC group;
[0008] For any common NPC in the NPC group, the server calculates the direction angle between the common NPC and the leader NPC and the distance between the common NPC and the leader NPC based on the coordinate position of the common NPC, the coordinate position of the leader NPC and the direction vector of the leader NPC; the common NPC is a non-leader NPC;
[0009] The server sends the position information of each NPC in the NPC group and the direction vector of the leader NPC to the client; wherein the position information of the leader NPC in the NPC group is expressed as a coordinate position, and the position information of each ordinary NPC in the NPC group consists of the direction angle with the leader NPC and the distance from the leader NPC.
[0010] When the server synchronizes the position of the NPC group to the client, it first determines the leader NPC from the NPC group. It can be assumed that the distance between other NPCs in the NPC group and the leader NPC is within a certain range; then the direction angle and distance between the ordinary NPCs in the NPC group and the leader NPC are calculated, and the direction angle and distance are transmitted to the client as the position information of the ordinary NPC; compared to sending the coordinate position of each NPC in the NPC group to the client, this application only sends the coordinate position of the leader NPC to the client, and the remaining ordinary NPCs transmit the direction angle and distance with the leader NPC as position information to the client. In this way, the amount of data transmitted during NPC position synchronization can be reduced, thereby reducing the bandwidth and network latency occupied during NPC position synchronization, and improving user experience.
[0011] In a possible design, before calculating the direction angle between the ordinary NPC and the leader NPC, the following steps are also included:
[0012] The server determines an obstacle avoidance speed set corresponding to each NPC based on the obstacle avoidance principle; any obstacle avoidance speed in the obstacle avoidance speed set can prevent the NPC from colliding with other NPCs in the NPC group;
[0013] For any NPC in the NPC group, the server determines the target speed of the NPC from the obstacle avoidance speed set of the NPC; determines the coordinate position of the NPC based on the target speed of the NPC, and the target speed of the NPC satisfies that the distance between the NPC and the leader NPC is less than the control distance.
[0014] In a possible design, the server determines the target speed of the NPC from the obstacle avoidance speed set of the NPC, including:
[0015] For any obstacle avoidance speed in the obstacle avoidance speed set of the NPC, if the updated speed direction vector obtained by adding the speed direction vector included in the obstacle avoidance speed and the preset offset angle vector still belongs to the obstacle avoidance speed set, then the obstacle avoidance speed is determined as the target speed of the NPC; the preset offset angle vector is used to ensure that the distance between the NPC and the leader NPC is less than the control distance.
[0016] The updated speed direction vector obtained by adding the speed direction vector included in the obstacle avoidance speed to the preset offset angle vector still belongs to the obstacle avoidance speed set, which can not only ensure that the NPC will not collide with other NPCs after moving at the obstacle avoidance speed, but also ensure that the distance between the NPC and the leader NPC after moving at the obstacle avoidance speed is less than the control distance.
[0017] In a possible design, before adding the speed direction vector included in the obstacle avoidance speed to the preset offset angle vector, the method further includes:
[0018] It is determined that after moving at the obstacle avoidance speed, the distance between the NPC and the leader NPC exceeds the control distance; or, the distance between the NPC and the leader NPC exceeds the safety distance.
[0019] After the NPC moves at the obstacle avoidance speed, there are various situations regarding the distance from the leader NPC, for example, the distance from the leader NPC exceeds the control distance, or the distance from the leader NPC exceeds the safety distance but does not exceed the control distance.
[0020] In one possible design, the method further includes:
[0021] If the distance between the NPC and the leader NPC does not exceed the safety distance after moving at the obstacle avoidance speed, the obstacle avoidance speed is determined as the target speed of the NPC.
[0022] If the distance between the NPC and the leader NPC does not exceed the safe distance after moving at the obstacle avoidance speed, there is no need to offset the obstacle avoidance speed according to the preset offset angle, which reduces the amount of calculation and improves the efficiency of NPC position synchronization.
[0023] In a possible design, the preset offset angle vector is determined in the following manner, including:
[0024] Determining a planned position of the NPC after moving at the obstacle avoidance speed;
[0025] The offset angle is determined by the offset coefficient, the distance difference between the proposed distance and the safety distance, and the control distance; wherein the offset coefficient is used to set the offset strength, and the proposed distance is the distance between the NPC at the proposed position and the leader NPC;
[0026] The preset offset angle vector is obtained by rotating the tangent direction corresponding to the proposed position by the offset angle in the direction toward the leader NPC.
[0027] After the NPC moves at the obstacle avoidance speed, it determines a proposed position, and then rotates the tangent direction corresponding to the proposed position by an offset angle in the direction toward the NPC to determine a preset offset angle vector. The offset angle vector determined by the above method makes the NPC move in the direction toward the leader NPC, thereby ensuring that the distance between the NPC and the leader NPC is not too far and never exceeds the control distance.
[0028] In a possible design, the server determines a leader NPC from the NPC group, including:
[0029] The server determines an NPC located at a central position from the NPC group as a leader NPC.
[0030] In a possible design, before the server sends the position information of each NPC in the NPC group to the client, it also includes:
[0031] The server compresses the position information of each common NPC in the NPC group from a float data type to a short data type.
[0032] The number of bytes occupied by the short data type is less than that of the float data type. Therefore, compressing the position information of each ordinary NPC in the NPC group from the float data type to the short data type and then transmitting it to the client can further reduce the amount of data transmitted during NPC position synchronization, thereby reducing the bandwidth and network latency occupied during NPC position synchronization and improving user experience.
[0033] In a second aspect, the present application further provides an NPC position synchronization method, the method comprising:
[0034] The client receives the position information of each NPC in the NPC group and the direction vector of the leader NPC sent by the server; wherein the position information of the leader NPC in the NPC group is represented as a coordinate position, and the position information of each common NPC in the NPC group is composed of a direction angle with the leader NPC and a distance with the leader NPC, the leader NPC is determined by the server from the NPC group, and the common NPC is a non-leader NPC;
[0035] The client determines the coordinate position of each common NPC according to the position information of each NPC and the direction vector of the leader NPC.
[0036] Compared with the existing solutions in which the NPC location information received by the client is all coordinates, in the location information of the NPC group received by the client in this application, only the location information of the leader NPC is the coordinates, and the location information of other ordinary NPCs are the direction angle and distance between them and the leader NPC; in this way, the amount of data and network bandwidth occupied by the client when synchronizing the NPC position can be reduced, thereby reducing network latency and improving user experience.
[0037] In a possible design, after the client receives the position information of each NPC in the NPC group sent by the server, before determining the coordinate position of each common NPC, it also includes:
[0038] The client converts the position information of each common NPC in the NPC group from a short data type to a float data type.
[0039] In a possible design, the client determines the coordinate position of each common NPC according to the position information of each NPC and the direction vector of the leader NPC, including:
[0040] For any ordinary NPC in the NPC group, the client determines x2 and y2 in the coordinate position of the ordinary NPC based on the direction vector of the leader NPC, the direction angle between the ordinary NPC and the leader NPC, and the distance between the ordinary NPC and the leader NPC, and the client determines z2 in the coordinate position of the ordinary NPC based on z1 in the coordinate position of the leader NPC.
[0041] In a third aspect, the present application further provides an NPC position synchronization device, the device comprising a processing unit and a transceiver unit;
[0042] The processing unit is used to determine a leader NPC from the NPC group;
[0043] The processing unit is further used to calculate, for any common NPC in the NPC group, a direction angle between the common NPC and the leader NPC and a distance between the common NPC and the leader NPC based on the coordinate position of the common NPC, the coordinate position of the leader NPC and the direction vector of the leader NPC; the common NPC is a non-leader NPC;
[0044] The transceiver unit is used to send the position information of each NPC in the NPC group and the direction vector of the leader NPC to the client; wherein the position information of the leader NPC in the NPC group is expressed as a coordinate position, and the position information of each ordinary NPC in the NPC group consists of a direction angle with the leader NPC and a distance from the leader NPC.
[0045] In a possible design, the processing unit is also used to determine an obstacle avoidance speed set corresponding to each NPC based on the obstacle avoidance principle; any obstacle avoidance speed in the obstacle avoidance speed set can prevent the NPC from colliding with other NPCs in the NPC group; and for any NPC in the NPC group, determine the target speed of the NPC from the obstacle avoidance speed set of the NPC; determine the coordinate position of the NPC based on the target speed of the NPC, and the target speed of the NPC satisfies that the distance between the NPC and the leader NPC is less than the control distance.
[0046] In a possible design, the processing unit is specifically used to determine the obstacle avoidance speed as the target speed of the NPC for any obstacle avoidance speed in the obstacle avoidance speed set of the NPC, if the updated speed direction vector obtained by adding the speed direction vector included in the obstacle avoidance speed and the preset offset angle vector still belongs to the obstacle avoidance speed set; the preset offset angle vector is used to ensure that the distance between the NPC and the leader NPC is less than the control distance.
[0047] In one possible design, before adding the speed direction vector included in the obstacle avoidance speed to the preset offset angle vector, the processing unit determines that after moving at the obstacle avoidance speed, the distance between the NPC and the leader NPC exceeds the control distance; or, the distance between the NPC and the leader NPC exceeds the safety distance.
[0048] In a possible design, if after moving at the obstacle avoidance speed, the distance between the NPC and the leader NPC does not exceed the safety distance, the processing unit is further used to determine the obstacle avoidance speed as the target speed of the NPC.
[0049] In one possible design, the processing unit determines the preset offset angle vector in the following manner: determining the planned position of the NPC after moving at the obstacle avoidance speed; determining the offset angle by the offset coefficient, the distance difference between the planned distance and the safety distance, and the control distance; wherein the offset coefficient is used to set the offset force, and the planned distance is the distance between the NPC at the planned position and the leader NPC; and rotating the tangent direction corresponding to the planned position by the offset angle in the direction toward the leader NPC to obtain the preset offset angle vector.
[0050] In a possible design, the processing unit is specifically used to determine an NPC located at a central position from the NPC group as a leader NPC.
[0051] In a possible design, the processing unit is specifically used to compress the position information of each ordinary NPC in the NPC group from a float data type to a short data type.
[0052] In a fourth aspect, the present application further provides an NPC position synchronization device, the device comprising a processing unit and a transceiver unit;
[0053] The transceiver unit is used to receive the position information of each NPC in the NPC group and the direction vector of the leader NPC sent by the server; wherein the position information of the leader NPC in the NPC group is expressed as a coordinate position, and the position information of each common NPC in the NPC group is composed of a direction angle with the leader NPC and a distance with the leader NPC, the leader NPC is determined by the server from the NPC group, and the common NPC is a non-leader NPC;
[0054] The processing unit is used to determine the coordinate position of each common NPC according to the position information of each NPC and the direction vector of the leader NPC.
[0055] In a possible design, the processing unit is further used to convert the position information of each ordinary NPC in the NPC group from a short data type to a float data type.
[0056] In a possible design, the processing unit is specifically used to determine x2 and y2 in the coordinate position of any ordinary NPC in the NPC group according to the direction vector of the leader NPC, the direction angle between the ordinary NPC and the leader NPC, and the distance between the ordinary NPC and the leader NPC, and the client determines z2 in the coordinate position of the ordinary NPC according to z1 in the coordinate position of the leader NPC.
[0057] In a fifth aspect, the present application also provides an NPC position synchronization device, the device comprising: a processor, and a memory communicatively connected to the processor;
[0058] The memory stores computer-executable instructions;
[0059] The processor executes the computer-executable instructions stored in the memory to implement the method described in the first aspect or the second aspect.
[0060] In a sixth aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a program, and when the program is executed on a device, the device executes a method as described in any one of the first aspect or the second aspect above.
[0061] In a seventh aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the method described in the first aspect or the second aspect is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0063] Figure 1 A schematic diagram of the movement of a group of bison provided in an embodiment of the present application;
[0064] Figure 2 A schematic diagram of a NPC position synchronization method flow chart provided in an embodiment of the present application;
[0065] FIG3( a ) is a schematic diagram of a single leader NPC provided in an embodiment of the present application;
[0066] FIG3( b ) is a schematic diagram of multiple leader NPCs provided in an embodiment of the present application;
[0067] Figure 4 A schematic diagram of the VO algorithm provided in an embodiment of the present application;
[0068] Figure 5 A schematic diagram of the VO algorithm jitter problem provided in an embodiment of the present application;
[0069] FIG. 6( a ) is a schematic diagram of the RVO algorithm provided in an embodiment of the present application Figure 1 ;
[0070] FIG6( b ) is a schematic diagram of the RVO algorithm provided in the embodiment of the present application Figure 2 ;
[0071] Figure 7 A schematic diagram of a preset offset angle vector provided in an embodiment of the present application;
[0072] Figure 8 A schematic diagram of the direction angle and distance between a common NPC and a leader NPC provided in an embodiment of the present application;
[0073] Fig. 9 Schematic diagram of the structure of the NPC position synchronization device provided in the embodiment of the present application Figure 1 ;
[0074] Fig.10 Schematic diagram of the structure of the NPC position synchronization device provided in the embodiment of the present application Figure 2 . DETAILED DESCRIPTION
[0075] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0076] The application scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. It is known to those skilled in the art that with the emergence of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems. In the description of the present application, unless otherwise specified, the meaning of "multiple" is two or more.
[0077] The conventional location synchronization solution is as described in the background technology section. The location information of each NPC in the NPC group is sent from the server to the client in the format of coordinate position. Figure 1 As shown in the figure, suppose there are 100 bison, moving from point A to point B in the form of NPC groups. The server needs to send the updated coordinate position of each of the 100 bison after moving from point A to point B to the client. For each bison, its coordinate position is expressed in the format of x, y, and z in 3D space. x, y, and z are all float data types, and float data types occupy 4 bytes. In other words, the synchronization of the coordinate position of a bison requires 3×4=12 bytes, so the synchronization of the coordinate position of 100 bison requires 100×12=1200 bytes. As the number of NPC groups increases, the number of bytes required for position synchronization will increase significantly, which puts a lot of pressure on the network bandwidth of the client and server.
[0078] Conventional position synchronization optimization schemes include error frame update schemes. Specifically, the NPC group is first grouped, and only the position information of one-third of the individuals in the NPC group is synchronized in each frame, which is equivalent to synchronizing the position information of the entire NPC group in three times. Taking 100 bison as an example, the coordinate positions of 33 bison are updated in each frame. For one position synchronization, the number of bytes occupied is 33×12=396 bytes. It can be seen that for a single position synchronization, the number of bytes occupied by the error frame update scheme is less than that of the conventional position synchronization scheme. However, the error frame update scheme is actually an optimization that exchanges time for space. In other words, since the error frame update scheme transmits the position information of the bison to the client in frames, the client needs to wait for the arrival of the three synchronous transmission data packets before starting to update the position of the bison group, which will cause the NPC movement performance to be more dependent on network stability; in addition, if there are more frames, the amount of data transmitted in a single time will be smaller, which may cause greater delays in client movement performance.
[0079] Based on the problems existing in the above two existing NPC position synchronization schemes, this application proposes the following Figure 2 The NPC position synchronization method shown in the figure specifically comprises:
[0080] Step 200: The server determines a leader NPC from the NPC group.
[0081] Exemplarily, the NPC group has a certain degree of unity when moving, but also has individual differences. Taking the movement of a herd of wild cattle as an example, the herd usually exhibits group behavior when moving, that is, they tend to stay together and form a tight group structure. This group behavior helps protect the herd from attacks by predators. In a herd, there is usually a cow as a leader, and other cows will follow the leader. The leader may be the strongest or most experienced cow in the group. In this application, this cow is virtualized into a non-existent herd leader, which is not located in the front of the herd, but in the center of the herd. Its movement determines the general direction of the movement of the entire herd, that is, the ultimate goal of the movement of each individual cow is the same as that of the leader.
[0082] Further exemplarily, the server may determine an NPC located at the center from the NPC group as the leader NPC, as shown in FIG3(a); or, the server may divide the NPC group into multiple areas, and determine an NPC located at the center from the NPC group in each sub-area as the leader NPC of the sub-area, as shown in FIG3(b). The NPC group is divided into four areas, and a leader NPC may be determined from the group in each sub-area, namely, leader NPC1 to leader NPC4.
[0083] Step 201: For any common NPC in the NPC group, the server calculates the direction angle between the common NPC and the leader NPC and the distance between the common NPC and the leader NPC based on the coordinate position of the common NPC, the coordinate position of the leader NPC and the direction vector of the leader NPC; the common NPC is a non-leader NPC.
[0084] Exemplarily, through step 200, individual NPCs in the NPC group can be divided into leader NPCs and ordinary NPCs. Accordingly, the movement of the entire NPC group can also be regarded as the movement of the leader NPC and the movement of ordinary NPCs; among them, the movement of the leader NPC follows the movement logic of Recast Navigation and has the highest priority; the movement of ordinary NPCs follows the dynamic obstacle avoidance rules to ensure that there is no overlapping collision with other ordinary NPCs. For example, the movement of ordinary NPCs can be based on the relative velocity obstacle (Reciprocal Velocity Obstacles, RVO) algorithm.
[0085] For example, Recast Navigation is an advanced game navigation mesh production tool set that converts complex 3D environments into navigation meshes suitable for AI pathfinding through a series of automated steps. Recast Navigation is divided into two modules: Recast and Detour. Recast is responsible for building the scene into a series of convex polygons that can be used for pathfinding through steps such as voxelization, height field construction, triangulation, and convex polygon merging; the core of Detour is to find the convex polygon sequence from point A to point B through the A* pathfinding algorithm, so as to calculate the final path.
[0086] Exemplarily, the movement of ordinary NPCs is introduced below using the RVO algorithm as an example. The RVO algorithm evolved from the velocity obstacle (VO) algorithm. A subdivision problem in the field of motion planning is dynamic obstacle avoidance, that is, the moving individual adjusts its speed to avoid collision based on the position, speed and other information of other objects in the environment during the movement. The VO algorithm is one of the basic algorithms. Its core idea is to identify the velocity vectors that may cause collisions in the velocity space to form a velocity obstacle area, thereby avoiding the selection of these speeds to achieve obstacle avoidance. Specifically, for two moving individuals A and B, by calculating the set of all relative speeds at which they may collide within a certain time interval, this set is called a velocity obstacle. In actual movement, the speed selected by the moving individual A should ensure that it is not within this velocity obstacle area to avoid collision with object B.
[0087] For example, Figure 4 As shown, Figure 4 The moving individual A is VA Speed, moving individual B moves at V B Speed moves, at some point in the future, the moving individual A reaches position A ′ , moving individual B arrives at position B ′ Therefore, moving individuals A and B will collide. The idea of VO algorithm is to predict and adjust the current speed and direction of moving individuals A and B in advance to avoid collision between the two.
[0088] However, the VO algorithm has jitter problems, such as Figure 5 As shown, Figure 5 There are two moving individuals A and B (moving individuals can also be called intelligent agents). In the first frame, A and B find that a collision may occur and make an avoidance. In the next frame, they find that their speeds have changed and there is no collision, so they will return to the original speed. In the third frame, they find that a collision may occur and change the avoidance speed again. The jitter problem makes the repeated movement of the two moving individuals look unnatural. The root cause is that the moving individuals in the VO algorithm believe that other moving individuals are moving at a stable and constant speed at the current speed, which causes their own behavior to become repeated when the other party's speed changes.
[0089] In order to solve the jitter problem of the VO algorithm, the RVO algorithm was introduced. The RVO algorithm takes into account the mutual avoidance between multiple agents and assumes that all agents use the same obstacle avoidance strategy, that is, each agent will execute half of the velocity vector required by the obstacle avoidance strategy, thereby reducing the jitter phenomenon in the obstacle avoidance process and improving the efficiency and naturalness of obstacle avoidance.
[0090] The core of the RVO algorithm is how to correct the current speed. Taking the example of individual A avoiding individual B, we first need to construct the position domain of individual A, as shown in Figure 6(a). The position of individual A is used as the coordinate origin to construct the position domain of A. A is used as a particle, and its radius is transferred to individual B. That is, the sum of the radius of individual B and the radius of individual A is used as the actual collision radius of individual B. The movement of individual A must ensure that it does not enter the area of B. Then, the velocity domain of individual A is constructed, and the moving speed of individual B is superimposed on the speed of individual A, that is, the moving speed of individual A relative to individual B. If individual A wants to avoid individual B, then individual A must ensure that its own moving vector cannot be within the tangent of the circle with A to B as the center, that is, it cannot be within the V in Figure 6(a). r and V fFinally, in the speed domain of individual A, in order to ensure that individual A does not collide with individual B within time t, it is necessary to ensure that the speed of individual A cannot fall within the circle with B1 as the center. In this case, individual A can choose V1 in Figure 6(a) to reduce speed and avoid it, or choose V2 in Figure 6(a) to shift the moving direction and avoid it.
[0091] Generally speaking, the speed after avoiding obstacles will be towards V r or V f The two vector directions are offset. Assume that individual A chooses V2 as the target moving vector. Since the original moving vector of individual A is V a Therefore, the velocity vector component adjusted by individual A is DeltaV, and individual A and individual B are each responsible for half of the velocity adjustment V p =V a + DeltaV×0.5. Then the speed V of the moving individual B is B Superimposed on the moving individual A, therefore, the actual moving speed direction of the moving individual A is V p +V B , as shown in Figure 6(b), as long as V a If they are not in the area surrounded by the two dotted lines in Figure 6(b), then moving individuals A and B will not collide.
[0092] The above DeltaV has many optional ranges, corresponding to V a The selection of is also to select a point closer to the original moving direction and closer to the original speed from the avoidance speed set. In order to prevent ordinary NPCs in the NPC group from exceeding the control distance of the leader NPC, this application adds a tendency judgment when selecting DeltaV, that is, in addition to ensuring that the moving individual A and the moving individual B do not collide, it is also necessary to ensure that the moving individual A and the moving individual B do not exceed the control distance of the leader NPC.
[0093] Exemplarily, before calculating the directional angle between the ordinary NPC and the leader NPC, the server first determines the moving direction and speed of the ordinary NPC based on the RVO algorithm and tendency judgment, and then determines the position of the ordinary NPC after moving based on the moving direction and speed.
[0094] Specifically, the server first determines the obstacle avoidance speed set corresponding to each NPC based on the obstacle avoidance principle, and any obstacle avoidance speed in the obstacle avoidance speed set can prevent the NPC from colliding with other NPCs in the NPC group; for any NPC in the NPC group, the server determines the NPC's target speed from the NPC's obstacle avoidance speed set; the NPC moves at the selected target speed, and then the server determines the coordinate position of the NPC after moving at the target speed based on the NPC's target speed; among them, when the server determines the NPC's target speed from the NPC's obstacle avoidance speed set, it can determine whether it can be used as the NPC's target speed by traversing each obstacle avoidance speed in the obstacle avoidance speed set.
[0095] Further exemplarily, for any obstacle avoidance speed in the obstacle avoidance speed set of the NPC, it can be considered that the obstacle avoidance speed includes a speed direction vector and a speed value. For example, for the obstacle avoidance speed: (1,1,1), 2m / s, (1,1,1) is the speed direction vector, and the speed value is 2m / s. Then it can be considered that the obstacle avoidance speed indicates that the moving direction is (1,1,1), and the speed in this direction is 2m / s.
[0096] After the NPC moves at the obstacle avoidance speed, there are several possibilities for the distance between the NPC and the leader NPC: first, the distance between the NPC and the leader NPC exceeds the control distance; second, the distance between the NPC and the leader NPC exceeds the safety distance; third, the distance between the NPC and the leader NPC does not exceed the safety distance. For example, assuming the control distance is 10m and the safety distance is 8m, after the NPC moves at different obstacle avoidance speeds, the distance between the NPC and the leader NPC may be 11m, 9m, or 7m.
[0097] This application provides two ways to select NPC target speed:
[0098] Method 1: After the NPC moves at the obstacle avoidance speed, regardless of the distance between the moved NPC and the leader NPC, the speed direction vector included in the obstacle avoidance speed is added to the preset offset angle. If the updated speed direction vector obtained by adding the speed direction vector included in the obstacle avoidance speed to the preset offset angle vector still belongs to the obstacle avoidance speed set, the obstacle avoidance speed can be determined as the target speed of the NPC.
[0099] Method 1 can increase the probability that the distance between the NPC and the leader NPC is always within the control distance, but regardless of the distance, the speed direction vector included in the obstacle avoidance speed is added to the preset offset angle, which has a large amount of calculation.
[0100] Method 2: If the distance between the NPC and the leader NPC exceeds the safety distance after moving at the obstacle avoidance speed, the speed direction vector included in the obstacle avoidance speed is added to the preset offset angle vector. The updated speed direction vector obtained after the addition still belongs to the obstacle avoidance speed set, and the obstacle avoidance speed can be determined as the target speed of the NPC; if the distance between the NPC and the leader NPC does not exceed the safety distance after moving at the obstacle avoidance speed, the obstacle avoidance speed can be directly determined as the target speed of the NPC.
[0101] Method 2 is a preferred method provided by the present application. Compared with method 1, not all obstacle avoidance speeds need to be calculated with the preset offset angle vector, which can reduce the amount of calculation.
[0102] The above-mentioned preset offset angle vector is mainly used to ensure that the distance between the NPC and the leader NPC is less than the control distance. The preset offset angle vector can also be called a safety angle vector. The preset offset angle vector is determined as follows: first determine the intended position of the NPC after the NPC moves at the obstacle avoidance speed; then determine the offset angle by the offset coefficient, the difference between the intended distance and the safety distance, and the control distance, where the offset coefficient is used to set the offset strength, and the intended distance is the distance between the NPC at the intended position and the leader NPC; finally, the tangent direction corresponding to the intended position is rotated by the offset angle in the direction toward the leader NPC to obtain the preset offset angle vector; the offset angle can be determined by the following formula:
[0103] Deviation angle = deviation coefficient × (planned distance - safety distance) / control distance
[0104] The offset coefficient can be adjusted according to the actual effect. For example, if you want the NPC to be closer to the leader NPC, you can set the offset coefficient to a larger value; otherwise, you can set the offset coefficient to a smaller value. For example, assuming the control distance is 10m, the safety distance is 8m, and the offset coefficient is set to 30, if the NPC moves at the obstacle avoidance speed and the distance from the leader NPC is 9m, then the proposed distance is 9m, then the offset angle = 30×(9-8) / 10 = 30, that is, the offset angle is 30°.
[0105] The following combined Figure 7 The determination of the preset offset angle vector is further explained. Figure 7Point A in the figure is the planned position of an NPC after it moves at the obstacle avoidance speed. With the leader NPC as the center and the planned distance as the radius, a tangent line is drawn at the planned position, and then the offset angle is rotated inward to obtain the preset offset angle vector. This application sets a preset offset angle vector. When ordinary NPCs move at the obstacle avoidance speed and are far away from the leader NPC, the inward "gravity" toward the leader NPC is used to prevent ordinary NPCs from moving to the control distance boundary.
[0106] For example, after determining the coordinate position of the ordinary NPC after movement, the server can calculate the direction angle between the ordinary NPC and the leader NPC and the distance between the ordinary NPC and the leader NPC based on the coordinate position of the ordinary NPC, the coordinate position of the leader NPC and the direction vector of the leader NPC.
[0107] For example, the calculation of the direction angle is first introduced, such as Figure 8 As shown, Figure 8 Point A in the figure is the coordinate position of the leader NPC, point B is the coordinate position of the ordinary NPC, and the direction is directly above the leader NPC, that is, Figure 8 In is the direction vector of the leader NPC, then Figure 8 The angle between the ordinary NPC and the leader NPC can be determined by the following formula, where the angle is θ:
[0108]
[0109] For example, assuming cosθ is 1 / 2, then θ is 60°, that is, the directional angle between the ordinary NPC and the leader NPC is 60°.
[0110] For example, the distance calculation between the ordinary NPC and the leader NPC is introduced again. The distance between the ordinary NPC and the leader NPC is the length of the vector determined according to the coordinate position of the ordinary NPC and the coordinate position of the ordinary NPC. Figure 8 As shown, the vector determined by the coordinate position of the ordinary NPC and the coordinate position of the ordinary NPC is Therefore, the distance between the ordinary NPC and the leader NPC is recorded as the vector The length of ; if the vector is (x, y, z), then the ordinary NPC and the leader
[0111] The above calculation method can be used to obtain the direction angle and distance between each ordinary NPC and the leader NPC, and the direction angle and distance are used as the position information of each ordinary NPC. The direction angle and distance here are both float data types. Compared with the conventional position synchronization scheme, the position information of each ordinary NPC is the coordinate position, which is composed of 3 float data types. The position information of each ordinary NPC in the present application is composed of 2 float data types, namely the direction angle and the distance. For the entire NPC group, the number of bytes occupied by the position information of the NPC group is significantly reduced. For example, taking 100 bison as an example, in addition to the leader bison, there are 99 ordinary bison. The number of bytes occupied by the coordinate positions of these 99 ordinary bison = 99×12=1188, and the number of bytes occupied by the position information of the 99 ordinary bison determined by the method proposed in the present application = 99×8=792, and the number of bytes occupied is reduced by about 33%.
[0112] Step 202: The server sends the position information of each NPC in the NPC group and the direction vector of the leader NPC to the client, and correspondingly, the client receives the position information of each NPC in the NPC group and the direction vector of the leader NPC sent by the server; wherein, the position information of the leader NPC in the NPC group is expressed as a coordinate position, and the position information of each ordinary NPC in the NPC group consists of the direction angle with the leader NPC and the distance from the leader NPC.
[0113] Exemplarily, through step 201, the server can obtain the position information of each ordinary NPC in the NPC group. In order to further reduce the amount of data occupied when the position information is transmitted, the server in the present application further compresses the position information of the ordinary NPC before sending the position information of each NPC in the NPC group to the client. The position information of each ordinary NPC is compressed from the float data type to the short data type, and the data obtained after the compression process is recorded as Value. The Value calculation process is as follows:
[0114]
[0115] Where powf is a power function, for example, powf(2,3)=2 3=8; ByteNum is the number of bytes to be converted. Since the number of bytes occupied by the short data type is 2, ByteNum here is 2; Input is the data of the float data type before compression; Since the value range of the direction angle between the ordinary NPC and the leader NPC is limited, and this application ensures that the distance between the ordinary NPC and the leader NPC does not exceed the control distance by presetting the offset angle vector, the distance between the ordinary NPC and the leader NPC is also limited. Usually, the value range of the direction angle can be set to [-3.1415f, 3.1415f], and the value range of the distance can be set to [0, 65535]. Then, when the direction angle is compressed, the MaxValue is 3.1415f and the MinValue is -3.1415f; similarly, when the distance is compressed, the MaxValue is 65535 and the MinValue is 0. It should be noted that the value ranges of the above-mentioned direction angle and distance are only examples, and can be set according to actual effects or needs. This application does not limit this.
[0116] Before compression, the location information of an ordinary NPC occupies 8 bytes, and after compression, the location information of an ordinary NPC occupies 4 bytes. Taking 100 bison as an example, after compression, the number of bytes occupied by the location information of 99 ordinary bison = 99 × 4 = 396, which is about 67% less than the number of bytes occupied by the coordinate position, which is 1188.
[0117] By way of further example, after compression processing, the server can send the position information of each NPC in the NPC group and the direction vector of the leader NPC to the client, wherein the position information of the leader NPC is represented as a coordinate position, and the data included in the coordinate position are all of the float data type, and the data included in the direction vector of the leader NPC are also of the float data type, and the position information of each ordinary NPC is of the short data type.
[0118] Step 203: The client determines the coordinate position of each common NPC based on the position information of each NPC and the direction vector of the leader NPC.
[0119] For example, after receiving the location information of each NPC and the direction vector of the leader NPC sent by the server, the client can determine the coordinate position of each ordinary NPC. Corresponding to the data compression processing performed by the server, the client first needs to convert the location information of each ordinary NPC in the NPC group from the short data type to the float data type, that is, convert the direction angle and distance included in the location information of each ordinary NPC into the float data type, and record the converted data as Value1. The calculation process of Value1 is as follows:
[0120]
[0121] P=(MaxValue-MinValue)×Y
[0122] Value1=Input×P+MinValue
[0123] Among them, powf is a power function; ByteNum is the number of bytes to be converted. Since the number of bytes occupied by the float data type is 4, ByteNum here is 4; Input is the direction angle or distance of the short data type; MaxValue and MinValue can refer to the example of the value range of the direction angle and distance during the above compression processing, which will not be repeated here.
[0124] Further exemplarily, after the client converts the position information of each ordinary NPC from a short data type to a float data type, the client can calculate the coordinate position of each ordinary NPC; specifically, for any ordinary NPC in the NPC group, the client determines x2 and y2 in the coordinate position of the ordinary NPC based on the direction vector of the leader NPC, the direction angle between the ordinary NPC and the leader NPC, and the distance between the ordinary NPC and the leader NPC, and the client determines z2 in the coordinate position of the ordinary NPC based on z1 in the coordinate position of the leader NPC.
[0125] For example, let the coordinate position of the leader NPC be (x1, y1, z1), the direction vector of the leader NPC be (x, y, z), the direction angle between the ordinary NPC and the leader NPC be θ, and the distance between the ordinary NPC and the leader NPC be dist. First, calculate the vector obtained by rotating the direction vector of the leader NPC by θ, denoted as dir, then:
[0126]
[0127] Then normalize dir, convert the length of dir to 1, and then multiply it by dist to obtain x2 and y2 as the x2 and y2 in the coordinate position of the ordinary NPC;
[0128] Finally, z2 in the coordinate position of the ordinary NPC is determined based on z1 in the coordinate position of the leader NPC. NavMesh technology is used to determine z2 in the coordinate position of the ordinary NPC. NavMesh technology can also be called navigation mesh technology. It is a technology used to realize automatic pathfinding of characters in game development. It simplifies the walkable surface of complex scenes into polygonal meshes, so that characters can intelligently bypass obstacles and speed up the pathfinding calculation. In this application, z1 in the coordinate position of the leader NPC is raised to a certain height, and then the NavMesh of the client is ray-checked from top to bottom to query the z2 of the current position that meets the walkable path. The coordinate position of the ordinary NPC is (x2, y2, z2).
[0129] After the client determines the coordinate position of each ordinary NPC, the position of the NPC can be updated. Due to network delays, the position of the NPC seen by the user is usually not real-time. This is because it takes time for the location information of the NPC group to be transmitted between the client and the server, and different clients may face different degrees of delay. In order to provide a smooth and coherent experience, this application uses an interpolation method on the client side to cope with network delays and synchronize NPC positions. That is, after the client determines the coordinate position of each ordinary NPC, if it is found that the current position of the NPC is different from the determined coordinate position, indicating that the position of the NPC has changed and the visual performance needs to be updated, the client uses a linear interpolation algorithm to make the NPC smoothly transition from the current position to the new coordinate position (the new coordinate position is (x2, y2, z2)). The formula for the linear interpolation algorithm is:
[0130] Lerp(a,b,t)=(1-t)×a+t×b
[0131] Among them, a represents the current position, b represents the new coordinate position, for example, (x2, y2, z2), t is the interpolation parameter, and the value range is 0 to 1. As t increases from 0 to 1, the calculation result of the above formula smoothly transitions from a to b, so that the NPC can be smoothly updated from the current position to the new coordinate position.
[0132] The NPC position synchronization method provided in the present application first determines the leader NPC in the NPC group, then calculates the direction angle and distance between each ordinary NPC and the leader NPC, and uses the direction angle and distance as the position information of the ordinary NPC. Before synchronizing the position information of the NPC group to the client, the position information of the ordinary NPC is also compressed, thereby reducing the network bandwidth occupied when synchronizing the position information of the NPC group, reducing network latency, and improving user experience.
[0133] Fig. 9 and Fig.10A schematic diagram of the structure of a possible NPC position synchronization device provided in an embodiment of the present application. These NPC position synchronization devices can be used to implement the functions of the server or client in the above method embodiments, and thus can also achieve the beneficial effects possessed by the above method embodiments.
[0134] like Fig. 9 As shown, the NPC position synchronization device 900 includes a processing unit 910 and a transceiver unit 920. When the NPC position synchronization device 900 is used to implement Figure 2 The functions of the server in the method embodiment shown are:
[0135] The processing unit 910 is used to determine a leader NPC from the NPC group;
[0136] The processing unit 910 is further configured to calculate, for any common NPC in the NPC group, a direction angle between the common NPC and the leader NPC and a distance between the common NPC and the leader NPC based on the coordinate position of the common NPC, the coordinate position of the leader NPC and the direction vector of the leader NPC; the common NPC is a non-leader NPC;
[0137] The transceiver unit 920 is used to send the position information of each NPC in the NPC group and the direction vector of the leader NPC to the client; wherein the position information of the leader NPC in the NPC group is expressed as a coordinate position, and the position information of each ordinary NPC in the NPC group consists of the direction angle with the leader NPC and the distance from the leader NPC.
[0138] In a possible design, the processing unit 910 is also used to determine an obstacle avoidance speed set corresponding to each NPC based on the obstacle avoidance principle; any obstacle avoidance speed in the obstacle avoidance speed set can prevent the NPC from colliding with other NPCs in the NPC group; and for any NPC in the NPC group, determine the target speed of the NPC from the obstacle avoidance speed set of the NPC; determine the coordinate position of the NPC based on the target speed of the NPC, and the target speed of the NPC satisfies that the distance between the NPC and the leader NPC is less than the control distance.
[0139] In one possible design, the processing unit 910 is specifically used to determine the obstacle avoidance speed as the target speed of the NPC for any obstacle avoidance speed in the obstacle avoidance speed set of the NPC, if the updated speed direction vector obtained by adding the speed direction vector included in the obstacle avoidance speed and the preset offset angle vector still belongs to the obstacle avoidance speed set; the preset offset angle vector is used to ensure that the distance between the NPC and the leader NPC is less than the control distance.
[0140] In one possible design, before adding the speed direction vector included in the obstacle avoidance speed to the preset offset angle vector, the processing unit 910 determines that after moving at the obstacle avoidance speed, the distance between the NPC and the leader NPC exceeds the control distance; or, the distance between the NPC and the leader NPC exceeds the safety distance.
[0141] In a possible design, if after moving at the obstacle avoidance speed, the distance between the NPC and the leader NPC does not exceed the safety distance, the processing unit 910 is further used to determine the obstacle avoidance speed as the target speed of the NPC.
[0142] In one possible design, the processing unit 910 determines the preset offset angle vector in the following manner: determining the proposed position of the NPC after moving at the obstacle avoidance speed; determining the offset angle by the offset coefficient, the distance difference between the proposed distance and the safety distance, and the control distance; wherein the offset coefficient is used to set the offset strength, and the proposed distance is the distance between the NPC at the proposed position and the leader NPC; and rotating the tangent direction corresponding to the proposed position by the offset angle in the direction toward the leader NPC to obtain the preset offset angle vector.
[0143] In a possible design, the processing unit 910 is specifically configured to determine an NPC located at a central position from the NPC group as a leader NPC.
[0144] In a possible design, the processing unit 910 is specifically used to compress the position information of each common NPC in the NPC group from a float data type to a short data type.
[0145] When the NPC position synchronization device 900 is used to implement Figure 2 The functions of the client in the method embodiment shown are:
[0146] The transceiver unit 920 is used to receive the position information of each NPC in the NPC group and the direction vector of the leader NPC sent by the server; wherein the position information of the leader NPC in the NPC group is represented as a coordinate position, and the position information of each common NPC in the NPC group is composed of a direction angle with the leader NPC and a distance with the leader NPC. The leader NPC is determined by the server from the NPC group, and the common NPC is a non-leader NPC;
[0147] The processing unit 910 is used to determine the coordinate position of each common NPC according to the position information of each NPC and the direction vector of the leader NPC.
[0148] In a possible design, the processing unit 910 is further used to convert the position information of each common NPC in the NPC group from a short data type to a float data type.
[0149] In a possible design, the processing unit 910 is specifically used to determine x2 and y2 in the coordinate position of any ordinary NPC in the NPC group according to the direction vector of the leader NPC, the direction angle between the ordinary NPC and the leader NPC, and the distance between the ordinary NPC and the leader NPC, and the client determines z2 in the coordinate position of the ordinary NPC according to z1 in the coordinate position of the leader NPC.
[0150] For more detailed description of the processing unit 910 and the transceiver unit 920, please refer to Figure 2 The relevant description in the method embodiment shown is directly obtained and will not be repeated here.
[0151] like Fig.10 As shown, the NPC position synchronization device 1000 includes a processor 1010 and an interface circuit 1020. The processor 1010 and the interface circuit 1020 are coupled to each other. It can be understood that the interface circuit 1020 can be a transceiver or an input-output interface. Optionally, the NPC position synchronization device 1000 can also include a memory 1030 for storing instructions executed by the processor 1010 or storing input data required by the processor 1010 to execute instructions or storing data generated after the processor 1010 executes instructions.
[0152] When the NPC position synchronization device 1000 is used to implement Figure 2 When the method is shown, the processor 1010 is used to implement the functions of the processing unit 910, and the interface circuit 1020 is used to implement the functions of the transceiver unit 920.
[0153] The division of units in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional unit in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0154] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0155] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for synchronizing the position of a non-player character NPC, characterized in that: This method is applicable to NPC groups in the metaverse, including: The server determines a leader NPC from the NPC group; For any common NPC in the NPC group, the server calculates the direction angle between the common NPC and the leader NPC and the distance between the common NPC and the leader NPC based on the coordinate position of the common NPC, the coordinate position of the leader NPC and the direction vector of the leader NPC; the common NPC is a non-leader NPC; The server sends the position information of each NPC in the NPC group and the direction vector of the leader NPC to the client; wherein the position information of the leader NPC in the NPC group is expressed as a coordinate position, and the position information of each ordinary NPC in the NPC group consists of the direction angle with the leader NPC and the distance from the leader NPC.
2. The method according to claim 1, characterized in that Before calculating the direction angle between the ordinary NPC and the leader NPC, the method further includes: The server determines an obstacle avoidance speed set corresponding to each NPC based on the obstacle avoidance principle; any obstacle avoidance speed in the obstacle avoidance speed set can prevent the NPC from colliding with other NPCs in the NPC group; For any NPC in the NPC group, the server determines the target speed of the NPC from the obstacle avoidance speed set of the NPC; determines the coordinate position of the NPC based on the target speed of the NPC, and the target speed of the NPC satisfies that the distance between the NPC and the leader NPC is less than the control distance.
3. The method according to claim 2, characterized in that The server determines the target speed of the NPC from the obstacle avoidance speed set of the NPC, including: For any obstacle avoidance speed in the obstacle avoidance speed set of the NPC, if the updated speed direction vector obtained by adding the speed direction vector included in the obstacle avoidance speed and the preset offset angle vector still belongs to the obstacle avoidance speed set, then the obstacle avoidance speed is determined as the target speed of the NPC; the preset offset angle vector is used to ensure that the distance between the NPC and the leader NPC is less than the control distance.
4. The method according to claim 3, characterized in that Before adding the speed direction vector included in the obstacle avoidance speed to the preset offset angle vector, the method further includes: It is determined that after moving at the obstacle avoidance speed, the distance between the NPC and the leader NPC exceeds the control distance; or, the distance between the NPC and the leader NPC exceeds the safety distance.
5. The method according to claim 4, characterized in that The method further comprises: If the distance between the NPC and the leader NPC does not exceed the safety distance after moving at the obstacle avoidance speed, the obstacle avoidance speed is determined as the target speed of the NPC.
6. The method according to claim 3, characterized in that The preset offset angle vector is determined by the following method, including: Determining a planned position of the NPC after moving at the obstacle avoidance speed; The offset angle is determined by the offset coefficient, the distance difference between the proposed distance and the safety distance, and the control distance; wherein the offset coefficient is used to set the offset strength, and the proposed distance is the distance between the NPC at the proposed position and the leader NPC; The preset offset angle vector is obtained by rotating the tangent direction corresponding to the proposed position by the offset angle in the direction toward the leader NPC.
7. The method according to any one of claims 1 to 6, characterized in that: The server determines a leader NPC from the NPC group, including: The server determines an NPC located at a central position from the NPC group as a leader NPC.
8. The method according to any one of claims 1 to 6, characterized in that Before the server sends the position information of each NPC in the NPC group to the client, the method further includes: The server compresses the position information of each common NPC in the NPC group from a float data type to a short data type.
9. A NPC position synchronization method, characterized in that: The method includes: The client receives the position information of each NPC in the NPC group and the direction vector of the leader NPC sent by the server; wherein the position information of the leader NPC in the NPC group is represented as a coordinate position, and the position information of each common NPC in the NPC group is composed of a direction angle with the leader NPC and a distance with the leader NPC, the leader NPC is determined by the server from the NPC group, and the common NPC is a non-leader NPC; The client determines the coordinate position of each common NPC according to the position information of each NPC and the direction vector of the leader NPC.
10. The method according to claim 9, characterized in that After the client receives the position information of each NPC in the NPC group sent by the server, before determining the coordinate position of each ordinary NPC, it also includes: The client converts the position information of each common NPC in the NPC group from a short data type to a float data type.
11. The method according to claim 9, characterized in that The client determines the coordinate position of each common NPC according to the position information of each NPC and the direction vector of the leader NPC, including: For any ordinary NPC in the NPC group, the client determines x2 and y2 in the coordinate position of the ordinary NPC based on the direction vector of the leader NPC, the direction angle between the ordinary NPC and the leader NPC, and the distance between the ordinary NPC and the leader NPC, and the client determines z2 in the coordinate position of the ordinary NPC based on z1 in the coordinate position of the leader NPC.
12. An NPC position synchronization device, characterized in that: The device comprises a processing unit and a transceiver unit; The processing unit is used to determine a leader NPC from the NPC group; The processing unit is further used to calculate, for any common NPC in the NPC group, a direction angle between the common NPC and the leader NPC and a distance between the common NPC and the leader NPC based on the coordinate position of the common NPC, the coordinate position of the leader NPC and the direction vector of the leader NPC; the common NPC is a non-leader NPC; The transceiver unit is used to send the position information of each NPC in the NPC group and the direction vector of the leader NPC to the client; wherein the position information of the leader NPC in the NPC group is expressed as a coordinate position, and the position information of each ordinary NPC in the NPC group consists of a direction angle with the leader NPC and a distance from the leader NPC.
13. An NPC position synchronization device, characterized in that: The device comprises a processing unit and a transceiver unit; The transceiver unit is used to receive the position information of each NPC in the NPC group and the direction vector of the leader NPC sent by the server; wherein the position information of the leader NPC in the NPC group is expressed as a coordinate position, and the position information of each common NPC in the NPC group is composed of a direction angle with the leader NPC and a distance with the leader NPC, the leader NPC is determined by the server from the NPC group, and the common NPC is a non-leader NPC; The processing unit is used to determine the coordinate position of each common NPC according to the position information of each NPC and the direction vector of the leader NPC.
14. An NPC position synchronization device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 11.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 11 when executed by a processor.
16. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 11 when being executed by a processor.