A method, apparatus, electronic device, and storage medium for synchronizing location information
By synchronizing the position information of the previous frame before logical calculation of each frame, the floating point error accumulation problem caused by the Unity physics engine is solved, and more efficient position information synchronization and error correction are achieved, improving the stability and performance of the game.
Patent Information
- Application Number
- CN202211640165.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-20
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2042-12-20
AI Technical Summary
In multiplayer online games, the physics engine provided by Unity causes floating point errors to accumulate due to the use of floating point numbers, resulting in inconsistent position information between each client, affecting the normal progress of the game.
By synchronizing the position information of the previous frame before each frame logical calculation, synchronized position information is determined, and computing the position information of the next frame based on this information and interaction event information, thereby reducing the accumulation of floating point errors.
It effectively reduces the floating point error caused by the Unity physics engine during frame synchronization, avoids CPU burden, and improves the synchronization efficiency and error correction efficiency of the game.
Smart Images

Figure CN116032988B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of game technology, and in particular to a location information synchronization method, device, electronic device and storage medium. Background Art
[0002] In multiplayer online games, the position information of various movable objects between different clients needs to be synchronized. Among them, frame synchronization is a common method. The client synchronizes the control instructions between different players at a certain frame rate, and performs the calculation process locally on the client to ensure that the position information of various movable objects on different clients is synchronized.
[0003] Usually, the physics engine (such as PhysX) provided by the game engine Unity uses floating-point numbers for physical calculations. As the game progresses, the floating-point error will be larger, resulting in inconsistent performance between clients and causing the game to fail to proceed normally. In the related art, a physics engine based on fixed-point numbers is introduced into the frame synchronization solution based on Unity, and fixed-point numbers are used to eliminate floating-point calculation errors. However, the additional fixed-point physics engine is not as efficient as Unity's own physics engine, and has a slower calculation speed, which will put pressure on the CPU, not only reducing development efficiency, but also increasing development costs. Summary of the invention
[0004] In view of this, the embodiments of the present application at least provide a position information synchronization method, device, electronic device and storage medium, which can greatly reduce the floating point error caused by the physical engine provided by Unity during frame synchronization and will not burden the CPU.
[0005] This application mainly includes the following aspects:
[0006] In a first aspect, one optional embodiment of the present application provides a location information synchronization method, which is applied to any requesting synchronization client of at least one requesting synchronization client included in an information synchronization system, and the information synchronization system also includes at least one information synchronization client and a server; the method includes: receiving first information to be synchronized sent by the server; the first information to be synchronized includes first interactive event information of a first mobile object controlled by the requesting synchronization client, and location information of the first mobile object in a first logical frame of each client in the information synchronization system; if there is a floating point error between the location information of the first mobile object in the first logical frame of each client, then determining the synchronization location information based on the location information corresponding to the first mobile object; and calculating the location information of the first mobile object in the second logical frame based on the synchronization location information and the first interactive event information.
[0007] In a second aspect, one optional embodiment of the present application provides a location information synchronization method, which is applied to any information synchronization client of at least one information synchronization client included in an information synchronization system, and the information synchronization system also includes at least one requesting synchronization client and a server; the method includes: receiving first information to be synchronized sent by the server; the first information to be synchronized includes first interactive event information of a first mobile object controlled by any of the requesting synchronization clients, and the location information of the first mobile object in the first logical frame of each client in the information synchronization system; if there is a floating point error between the location information of the first mobile object in the first logical frame of each client, then determining the synchronization location information based on the location information corresponding to the first mobile object; and calculating the location information of the first mobile object in the second logical frame based on the synchronization location information and the first interactive event information.
[0008] In the third aspect, one optional embodiment of the present application also provides a position information synchronization device, which is applied to any requesting synchronization client of at least one requesting synchronization client included in the information synchronization system, and the information synchronization system also includes at least one information synchronization client and a server; the device includes: a first receiving module, used to receive first information to be synchronized sent by the server; the first information to be synchronized includes first interactive event information of a first mobile object controlled by the requesting synchronization client, and position information of the first mobile object in a first logical frame of each client in the information synchronization system; a first determination module, used to determine the synchronization position information based on the respective position information corresponding to the first mobile object if there is a floating point error between the position information of the first mobile object in the first logical frame of each client; a first calculation module, used to calculate the position information of the first mobile object in the second logical frame based on the synchronous position information and the first interactive event information.
[0009] In the fourth aspect, one of the optional embodiments of the present application also provides a position information synchronization device, which is applied to any information synchronization client of at least one information synchronization client included in the information synchronization system, and the information synchronization system also includes at least one requesting synchronization client and a server; the device includes: a second receiving module, used to receive first information to be synchronized sent by the server; the first information to be synchronized includes first interactive event information of a first mobile object controlled by any of the requesting synchronization clients, and the position information of the first mobile object in the first logical frame of each client in the information synchronization system; a second determination module, used to determine the synchronization position information based on the respective position information corresponding to the first mobile object if there is a floating point error between the position information of the first mobile object in the first logical frame of each client; a second calculation module, used to calculate the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interactive event information.
[0010] In the fifth aspect, one optional embodiment of the present application also provides an electronic device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, when the electronic device is running, the processor and the memory communicate through the bus, and the machine-readable instructions are executed by the processor when running the steps of the location information synchronization method described in the first aspect, or when running the steps of the location information synchronization method described in the second aspect.
[0011] In the sixth aspect, one optional embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the location information synchronization method described in the first aspect are executed, or the steps of the location information synchronization method described in the second aspect are executed.
[0012] The position information synchronization method, device, electronic device and storage medium provided in the embodiments of the present application adopt that after receiving the first information to be synchronized sent by the server, if it is determined that there is a floating-point error between the position information of the first moving object in the first logical frame of each client, the synchronization position information is determined based on the respective position information corresponding to the first moving object, and then the position information of the first moving object in the second logical frame is calculated based on the synchronization position information and the first interactive event information. Compared with the physics engine based on fixed-point numbers that needs to be additionally introduced in the related art, which is not as efficient as the physics engine that comes with Unity and has a slow calculation speed, which puts pressure on the CPU, not only reduces the development efficiency but also increases the development cost, the present application can correct the floating-point error of each frame by synchronizing the position of the previous frame before the logical calculation of each frame without introducing a new physics engine or fixed-point numbers. In this way, the floating-point error will not be involved in the logical calculation of the next frame, and the floating-point error will not be accumulated during the game. Therefore, the floating-point error caused by the physics engine provided by Unity during frame synchronization can be greatly reduced, and no burden will be placed on the CPU.
[0013] Furthermore, the position information synchronization method provided in one of the optional embodiments of the present application can also filter out the synchronization position information from the various position information; or, calculate the synchronization position information based on the various position information. In this way, by adopting the preset information synchronization rules agreed upon in advance by each client, each client can select a unique synchronization position information to synchronize the position of the first moving object, which can improve the synchronization efficiency, and by using the synchronization position information of the first moving object after synchronization to perform the logical calculation of the next frame, the floating point error of the position information of the first moving object can be corrected, which can improve the error correction efficiency and greatly reduce the error generated during the game operation.
[0014] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 A schematic diagram showing the structure of a location information synchronization system provided by one of the optional embodiments of the present application is shown;
[0017] Figure 2 A flow chart of a location information synchronization method provided by one of the optional embodiments of the present application is shown;
[0018] Figure 3 A flowchart of another location information synchronization method provided by one of the optional embodiments of the present application is shown;
[0019] Figure 4 A schematic diagram showing a process of synchronizing location information of each client in a location information synchronization system provided in one of the optional embodiments of the present application;
[0020] Figure 5 A functional module diagram of a location information synchronization device provided by one of the optional embodiments of the present application is shown;
[0021] Figure 6 A functional module diagram of another position information synchronization device provided by one of the optional embodiments of the present application is shown;
[0022] Figure 7 A schematic structural diagram of an electronic device provided in one of the optional embodiments of the present application is shown. DETAILED DESCRIPTION
[0023] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art, under the guidance of the content of the present application, can add one or more other operations to the flowchart, or remove one or more operations from the flowchart.
[0024] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. 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 application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0025] In order to enable those skilled in the art to use the contents of this application, the following implementation is given in combination with the specific application scenario "position synchronization". For those skilled in the art, the general principles defined here can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application.
[0026] The following methods, devices, electronic devices or computer-readable storage media in the embodiments of the present application can be applied to any scenario requiring location synchronization. The embodiments of the present application are not limited to specific application scenarios. Any solution using the location information synchronization method and device provided in the embodiments of the present application is within the protection scope of the present application.
[0027] To facilitate the understanding of the present application, the technical solution provided by the present application is described in detail below in conjunction with specific embodiments.
[0028] Figure 1 FIG. 1 is a schematic diagram showing a structure of a location information synchronization system 100 provided by one of the optional embodiments of the present application. Figure 1 As shown, the location information synchronization system 10 includes at least one request synchronization client 110 , a server 120 , and at least one information synchronization client 130 .
[0029] It should be understood that the request synchronization client 110 can be a mobile terminal, a notebook, a desktop, etc. In other words, the specific type of the request synchronization client 110 can be set according to actual needs, and the embodiment of the present application is not limited to this. Correspondingly, the specific type of the information synchronization client 130 can also be set according to actual needs, and the embodiment of the present application is not limited to this.
[0030] It should also be understood that the server 120 can be a single server or a server group. The server group can be centralized or distributed (for example, the server 120 can be a distributed system). In other words, the specific type of the server 120 can also be set according to actual needs, and the embodiments of the present application are not limited thereto.
[0031] It should be noted that the information synchronization scheme provided in the embodiment of the present application can be further extended to other suitable application scenarios, and is not limited to Figure 1 For example, although Figure 1 A specific number of information synchronization clients 130 are shown in the figure, but those skilled in the art should understand that in actual application, the information synchronization system may include more information synchronization clients 130.
[0032] It should be noted here that although the above description is based on the request synchronization client 110 and the information synchronization client 130, those skilled in the art should understand that the request synchronization client 110 can be used for information synchronization in addition to requesting information synchronization, and correspondingly, the information synchronization client 130 can be used for requesting information synchronization in addition to information synchronization.
[0033] For example, when the first client and the second client are playing a game at the same time, the request synchronization client 110 in the embodiment of the present application can be either the first client or the second client. Correspondingly, the information synchronization client 130 in the embodiment of the present application can be either the first client or the second client.
[0034] It should be noted that in multiplayer online games, each client in the game needs to keep the position information of each other consistent at every moment. Common synchronization methods are frame synchronization and state synchronization. In frame synchronization, the server does not need to know the game logic, but only forwards the client's operation, and then the client performs logical calculations by itself. Common RTS and MOBA are generally frame synchronization. State synchronization is that the server calculates the game logic and returns the character status to the client. The client can directly use the status returned by the server. MMORPG is generally state synchronization. Frame synchronization is used for the embodiment of the present application.
[0035] As we all know, games are rendered on the screen frame by frame, which is generally called rendering frame. Rendering frame is unstable. If a frame calculates too much or the picture is too complicated, the time of this frame may be longer. The same game has different rendering frames on different CPUs and graphics cards. The frame of frame synchronization refers to the logical frame, not the rendering frame. Let's take two mobile phones as an example. They need to be synchronized, which means that their data is consistent. How to ensure their data consistency? Ensure that their starting state is consistent, the time to execute the operation is consistent, and the operation is consistent, then the results of the two machines must be consistent. If we fix the game to 20 logical frames per second, that is, execute a logical frame every 50ms, both mobile phones will execute A's move operation at the 5th frame, and will execute B's attack operation at the 12th frame. In this way, the two mobile phones are always consistent. This is the concept of frame synchronization.
[0036] It should be understood that before doing frame synchronization, you need to know that all game logic needs to be broken down into each logical frame to execute, such as calculating damage, life recovery, etc. These are all things to do in each logical frame. The game keeps calculating data according to the calculation logic, so that the game runs according to the logical frame. As for rendering to the screen, whether it is 30 frames or 60 frames, it has nothing to do with the logical operation of the data.
[0037] For example, synchronization means that the performance of multiple clients is consistent. For example, when playing "Honor of Kings", the hero positions displayed on the screens of ten players must be exactly the same, and the skill release angles and release times must be exactly the same. This is synchronization. For most games, not only must the performance of the client be consistent, but the data of the client and the server must be consistent. Therefore, synchronization is a concept of online games. Only online games require synchronization, while stand-alone games do not require synchronization.
[0038] Generally, in the gaming field, online multiplayer games based on frame synchronization generally do not use the floating-point physics engine provided by Unity (for example, PhysX), but instead introduce a fixed-point physics engine. Among them, "floating-point numbers" refer to numbers with non-fixed decimal points, which can represent a wide range of data, including integers and decimals, including float and double. "Fixed-point numbers" refer to numbers with fixed decimal points, which can represent integers and decimals. In essence, int is a 32-bit fixed-point number with a decimal point at the end.
[0039] Here, the role of the physics engine, in short, is to make the movement of objects in the virtual world conform to the physical laws of the real world, so as to make the game more realistic. Physical simulation calculations require very powerful integer and floating-point computing capabilities. More importantly, physical processing is highly parallel and requires multi-threaded computing. The calculation is very complex and consumes a lot of resources. PhysX can be calculated by the CPU, but the program itself is designed to call independent floating-point processors (such as GPU and PPU) for calculations. Because of this, it can easily complete large-scale physical simulation calculations such as fluid dynamics simulations.
[0040] It should be understood that one of the difficulties of frame synchronization technology is the need for consistency in client calculation results. Among them, when a physics engine based on floating-point numbers is calculating, due to the inconsistency of the hardware environment and system platform, floating-point operations will produce different results in some cases. In other words, computers cannot naturally process decimals. For decimal calculations, different compilers and processors use different calculation standards and optimization methods, resulting in differences in the precision of decimals, which is the so-called "floating-point error". This "floating-point error" will continue to accumulate as the game progresses, resulting in inconsistent performance between various clients, causing the game to be unable to proceed normally. Therefore, in the field of games, floating-point physics engines are usually not used for frame synchronization operations.
[0041] In addition, if you use a fixed-point physics engine for logical calculations, although the fixed-point numbers are finally converted into floating-point numbers related to Unity Transform to display the position of the object, in the game events that determine physical collisions, the physical movement is all run with fixed-point integers, so the determinism of the physics engine iteration is achieved, and the results of physical simulation on different clients are consistent. Therefore, the advantage of a fixed-point physics engine is that it is all calculated based on integers, and the results are certain, which can ensure the consistency of the results of operations on different clients.
[0042] However, fixed-point numbers are prone to overflow when performing multiplication or division, which results in the fact that fixed-point-based physics engines do not have good computing performance under the CPU compared to floating-point-based physics engines. Fixed-point-based physics engines not only have a slow computing speed, but also put pressure on the CPU, and are very inconvenient to use, which will reduce development efficiency and increase development costs. Let's take multiplication as an example. Assuming a 32-bit integer and 16 bits as the decimal part, then it is a fixed-point number of 15.16 (the highest represents the sign, 15 bits represent the integer part, and 16 bits represent the decimal part). If two numbers are multiplied, there is a high probability of overflow (the calculation result exceeds 32 bits). For example, the multiplication of two fixed-point numbers 2^20 and 2^21 is (2^20*2^21) / (2^16)=2^41 / 2^16. When calculating the numerator multiplication, it is 2^41 times, which overflows in the 32-bit int storage, while 2^20 and 2^21 are both legal fixed-point numbers. Here, the performance of the fixed-point physics engine is about 4 times worse than that of the floating-point physics engine. In other words, the performance of the fixed-point physics engine is much worse than that of the floating-point physics engine.
[0043] In short, the physics engine (such as PhysX) provided by the game engine Unity uses floating-point numbers for physical calculations. As the game progresses, the floating-point error will be larger, resulting in inconsistent performance between clients and causing the game to be unable to proceed normally. In the related art, a physics engine based on fixed-point numbers is introduced into the Unity-based frame synchronization solution, and fixed-point numbers are used to eliminate floating-point calculation errors. However, the additional fixed-point physics engine is not as efficient as Unity's own physics engine, and has a slower calculation speed, which will put pressure on the CPU, not only reducing development efficiency, but also increasing development costs.
[0044] Based on this, the embodiment of the present application discloses a location information synchronization solution. After any client in the location information synchronization system receives the first information to be synchronized sent by the server, if it is determined that there is a floating point error between the location information of the first moving object in the first logical frame of each client, the synchronization location information is determined based on the location information corresponding to the first moving object, and then the location information of the first moving object in the second logical frame is calculated based on the synchronization location information and the first interactive event information. In this way, without introducing a new physical engine or fixed-point number, by synchronizing the position of the previous frame before each frame of logical calculation, the floating point error caused by the physical engine provided by Unity during frame synchronization can be greatly reduced, and it will not burden the CPU.
[0045] Figure 2 FIG. 1 is a flow chart showing a method for synchronizing location information provided by one of the optional embodiments of the present application; Figure 2 As shown, the location information synchronization method provided in the embodiment of the present application is applied to any request synchronization client of at least one request synchronization client included in the information synchronization system, and the information synchronization system also includes at least one information synchronization client and a server; and includes the following steps:
[0046] S201: Receive first information to be synchronized sent by the server; the first information to be synchronized includes first interaction event information of a first mobile object controlled by the requesting synchronization client, and position information of the first mobile object in a first logical frame of each client in the information synchronization system.
[0047] In a specific implementation, after receiving the synchronization instruction information sent by all clients in the information synchronization system (including each request synchronization client and each information synchronization client), the server aggregates the synchronization instruction information to obtain the information to be synchronized, and then forwards the information to be synchronized to all clients in the information synchronization system, so that any request synchronization client will receive the information to be synchronized. Here, the information to be synchronized may include the location information of the mobile objects controlled by each client, and may also include the interactive event information of at least one mobile object. The specific content of the information to be synchronized may be set according to the actual situation, and the embodiments of the present application are not limited to this.
[0048] Here, for any requesting synchronization client, the requesting synchronization client receives the first information to be synchronized sent by the server. The first information to be synchronized includes the first interactive event information of the first mobile object controlled by the requesting synchronization client, and the position information of the first mobile object in the first logical frame of each client in the information synchronization system. It should be understood that at the same time or in the same logical frame, the same mobile object has a corresponding position information in each client, and the position information is obtained by logical calculation of the previous logical frame.
[0049] In a possible implementation, before sending information to be synchronized to each client, the server will first receive synchronization instruction information sent by each client. Here, any client requesting synchronization is taken as an example. Specifically, before receiving the first information to be synchronized sent by the server in step S201, the following steps are also included: responding to the target user's control instruction for the first mobile object, sending the first synchronization instruction information to the server; wherein the first synchronization instruction information includes the first interaction event information corresponding to the first mobile object, and the position information of the first mobile object in the first logical frame.
[0050] In a specific implementation, after the request synchronization client detects the target user's control instruction for the first mobile object, it triggers the sending of the first synchronization instruction information to the server. The control instruction is an instruction for representing the control of the first mobile object, such as an instruction for controlling the movement of the first mobile object, an instruction for controlling the first mobile object to release a skill, an instruction for controlling the first mobile object to perform a preset action, etc. The first interactive event information is directly associated with the control instruction, and the first interactive event information can also be understood as the interactive event information corresponding to the control instruction. For example, if the control instruction is an instruction for controlling the first mobile object to release a skill, the first interactive event information includes the skill event information to be released by the first mobile object.
[0051] It should be noted that when any client requesting synchronization detects a control instruction from the target user for the first mobile object, it will trigger the sending of the first synchronization instruction information to the server. After receiving the first information to be synchronized sent by the server, it will perform logical calculations based on the control instruction and execute corresponding actions to ensure data synchronization between each client.
[0052] In addition, the control instruction is issued by the target user through a touch operation on the requesting synchronization client, and the control instruction corresponds to at least one of the following operations: a touch operation on a physical button; a touch operation on a virtual button in the user graphical interface. If the requesting synchronization client is a notebook or desktop computer, the physical button can be a mouse, keyboard, etc. If the requesting synchronization client is a mobile terminal (mobile phone) or ipd, the virtual button is some touch buttons on the user graphical interface, such as an attack button, a jump button, etc.
[0053] It should be understood that for the frame synchronization scheme, each client will send synchronization instruction information to the server at a fixed frame rate, so that data synchronization between each client in the game can be guaranteed; the synchronization instruction information at least includes the position information of the mobile object, and if the mobile object also has interactive event information, the synchronization instruction information also carries the interactive event information. The following is an example of any client requesting synchronization, and the position information synchronization method also includes: sending a second synchronization instruction information to the server at a preset frame rate; the second synchronization instruction information at least includes the position information of the first mobile object.
[0054] For example, assuming that the game executes 20 logical frames in 1 second, the frame rate is 50ms per frame.
[0055] It should be noted that the client needs to synchronize the instructions and then perform logical calculations within a fixed frame interval, rather than sending the logical calculations to other clients. The reason is that if a player performs logical calculations within a certain frame without knowing the operations of other users, the calculation results will be inconsistent. For example, in one frame, player A attacks B, causing B's death, and in the same frame, B also attacks A, causing A's death. Then both clients think that the other is dead. In fact, by performing calculations after synchronization of instructions, only one will die. That is the person who first launched the attack.
[0056] In a possible implementation, the content of the information to be synchronized sent by the server to each client each time may be different. The following describes the situation in which the server sends specific information containing the second mobile object, that is, the location information synchronization method also includes: receiving the second information to be synchronized sent by the server; the second information to be synchronized includes at least one location information of a second mobile object controlled by the information synchronization client and second interaction event information; based on the location information of the second mobile object, synchronizing the location information of the second mobile object; based on the second interaction event information, updating the synchronized location information of the second mobile object.
[0057] In a specific implementation, for any requesting synchronization client, if the second information to be synchronized sent by the server includes the location information and second interaction event information of a second mobile object controlled by any information synchronization client, it means that the information synchronization client wants to perform corresponding operations on the second mobile object. The requesting synchronization client should first synchronize the location information of the second mobile object to ensure that the location information of the second mobile object in the requesting synchronization client is consistent with the location information of the second object of the information synchronization client. After synchronizing the location information of the second object, the synchronized location information of the second mobile object can be updated based on the second interaction event information.
[0058] In addition, considering that the second interaction event here may cause a physical collision between the first moving object and the second moving object, in this case, the position information of the first moving object will also change. This situation is explained in detail below. That is, if the second interaction event information is event information of a physical collision between the first moving object and the second moving object, then after receiving the second information to be synchronized sent by the server, the following steps are also included: based on the second interaction event information, the position information of the first moving object is updated.
[0059] S202: If there is a floating point error between the position information of the first mobile object in the first logical frame of each client, determine the synchronization position information based on each position information corresponding to the first mobile object.
[0060] Here, due to the inconsistency of the hardware environment and system platform of each client, the operation of the physical engine based on floating-point numbers may produce different results in some cases, that is, there is a floating-point error between the position information of the first moving object in the first logical frame of each client.
[0061] It should be understood that in a single logical frame, the floating-point error can generally be controlled below 10 to the -5th power. This error has almost no effect on the game operation, and the effect on position synchronization is also minimal. However, if the floating-point error is not processed during the game operation, the floating-point error will continue to accumulate, causing the game to be unable to run. Based on this, at the beginning of each frame, the present application first performs position synchronization through the position information of the moving object transmitted by the previous frame, and then performs logical calculations to obtain the position information of the moving object in this frame. In this way, under the premise that there is a calculation error between the previous logical frames of different clients, the position of the previous frame will be synchronized before each next logical frame is calculated, and the floating-point error will not be accumulated, realizing the position synchronization using Unity's built-in floating-point physics engine under frame synchronization.
[0062] In a specific implementation, since each client under the same game uses the same game logic, it can be agreed in advance that each client in the information synchronization system uses the same preset information synchronization rules to determine the same, unique synchronization position information based on the various position information of the first moving object in the first logical frame of each client in the information synchronization system, so as to ensure that the position information of the first moving object in the first logical frame is synchronized before calculating the second logical frame.
[0063] The following is a description of the implementation process of determining the synchronization position information based on each position information corresponding to the first mobile object in step S202. Here, two specific implementation methods are given:
[0064] Method 1: Filter out the synchronization position information from the various position information. Here, when the server sends the first information to be synchronized to each client, the position information in the first logical frame of each client carried in the first information to be synchronized has a fixed order. Therefore, each client can agree in advance to use the position information in a certain fixed position order as the synchronization position information, for example, the position information in the first position is used as the synchronization position information.
[0065] Method 2: Calculate the synchronization position information based on the position information. After receiving the position information corresponding to the first mobile object sent by the server, each client can obtain the synchronization position information by performing the same calculation on each position information according to the preset information synchronization rule agreed in advance, for example, averaging each position information to obtain the synchronization position information.
[0066] It should be understood that no matter which method is adopted, as long as the synchronization position information determined by each client is ensured to be the same, the position information of the first mobile object in the first logical frame can be synchronized.
[0067] S203: Calculate the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interaction event information.
[0068] In a specific implementation, after determining the synchronization position information of the mobile object corresponding to the first logical frame, each client in the information synchronization system can directly update the position synchronization information based on the determined position synchronization information by using the interactive information of the mobile object to perform logical calculations and obtain the position information of the mobile object in the second logical frame. For any client requesting synchronization, the same calculation logic can be used to determine the position information of the first mobile object in the second logical frame of the client requesting synchronization.
[0069] It should be noted that only when a physical collision occurs between moving objects does it need to start the physical engine to simulate the collision, and then calculate the corresponding position information of the moving objects during the collision. Specifically, if the first interactive event information is the event information of a physical collision between the first moving object and the first interactive event information, the calculation of the position information of the first moving object in the second logical frame based on the synchronized position information and the first interactive event information in step S203 includes the following steps:
[0070] Step 2031a: Based on the first interaction event information, control the preset physics engine to perform a rigid body collision simulation on the first moving object, and calculate a floating point number of a moving speed and a floating point number of a moving direction of the first moving object.
[0071] In a specific implementation, each client will start the physics engine to simulate physical motion and calculate the position information of the first moving object during the collision only after receiving the event information of the physical collision of the first moving object. Here, taking any request synchronization client as an example, after receiving the first interactive event information of this type, the request synchronization client parses the specific event information in the first interactive event information, such as the attack event information, and then controls the preset physics engine to simulate the rigid body collision of the first moving object based on the parsed specific event information, and calculates the floating point number of the moving speed and the floating point number of the moving direction of the first moving object. Among them, the preset physics engine is a physics engine based on floating point numbers.
[0072] It should be understood that due to the inconsistency of the hardware environment and system platform of different clients, when the first moving object sends a collision event, different clients simulate rigid body collisions through the preset physics engine, and obtain new speeds based on their own mass and speed. At this time, the calculation results of different clients will produce errors. For example, if client 1 calculates the new speed of the first moving object to be 1.121565, and client 2 calculates the new speed of the first moving object to be 1.121566, the new speeds of the first moving object calculated by the two clients will have floating point errors.
[0073] Step 2032a: Calculate the position information of the first moving object in the second logical frame according to the moving speed floating point number, the moving direction floating point number and the synchronous position information of the first moving object.
[0074] In a specific implementation, after calculating the floating-point number of the moving speed and the floating-point number of the moving direction of the first moving object at a certain moment, any client requesting synchronization can calculate the position information of the first moving object in the second logical frame based on these data together with the synchronization position information corresponding to the first logical frame after synchronization. For different clients, the position information of the first moving object in the second logical frame of different clients will generate new floating-point errors, but according to the position synchronization information received before each frame of logic calculation, the position error is always controlled below 10 to the power of -5. In this way, it is ensured that the error is always controlled to be extremely small and will not accumulate, which to a certain extent meets the needs of each client for synchronization of the position of the moving object.
[0075] It should also be noted that, in the case where the first interactive event information is event information of non-collision movement, there is no need to start the physical engine to perform physical collision simulation, and calculation can be performed directly. Specifically, in step S203, based on the synchronous position information and the first interactive event information, the position information of the first moving object in the second logical frame is calculated, including the following steps:
[0076] Step 2031b: directly calculating the moving speed information and moving direction information of the first moving object according to the first interaction event information.
[0077] In a specific implementation, when the first interaction event information is non-collision movement event information, each client directly calculates the movement speed information and movement direction information of the first moving object during the movement process based on the specific event information parsed from the first interaction event information, and both are consistent.
[0078] Step 2032b: Calculate the position information of the first moving object in the second logical frame according to the moving speed information, the moving direction information and the synchronization position information of the first moving object.
[0079] In a specific implementation, in view of this situation, the position information of the first moving object in the second logical frame calculated by each client is consistent without any error, thus meeting the requirement of information synchronization of each client.
[0080] Here, before all clients in the information synchronization system start calculating the next frame, they first synchronize the position information corresponding to the same moving object in the previous frame of each client, and obtain the synchronized position information of the moving object after synchronization. In this way, it is possible to achieve low-cost error correction of the position information of the moving object in different clients, and further, directly use the synchronized position information of the previous frame and the interactive event information of the moving object to calculate the position information of the moving object in the next frame. At this time, although the calculation results between different clients (the position information of the moving object in the next frame) may still be different, we can still select a unique calculation result for synchronization, and then perform position calculation on the new instructions in this frame after synchronization. In this way, even if there are errors between different clients in each frame, all errors will be reset before the next frame starts, and the errors will not participate in the logical calculation of the next frame, so they will not affect the game results.
[0081] It should be noted that the present application can ensure the synchronization of object positions between different clients through error correction, and does not introduce a new physics engine or a fixed-point physics engine to complete the synchronization process. It effectively solves the problem of floating-point errors caused by the floating-point physics engine provided by Unity during frame synchronization, and does not burden the CPU. Moreover, in games that use frame synchronization, the number of objects that need to be strictly synchronized is usually small (generally a limited number of virtual characters, monsters, soldiers, etc.), so it will not bring greater pressure to the network. In summary, the technical solution provided by the present application can overcome the technical prejudice in this field while being easy to implement. Through smaller CPU consumption and network bandwidth occupation, a position synchronization solution based on the floating-point physics engine provided by Unity itself can be completed.
[0082] In a possible implementation, after different clients calculate the position information of the first moving object in the second logical frame, that is, after updating the position information of the first moving object, the updated position information of the first moving object will be synchronized to other clients through the server, that is, after calculating the position information of the first moving object in the second logical frame based on the synchronized position information and the first interaction event information in step S203, the following step is also included: sending the calculated position information of the first moving object to the server.
[0083] In one of the optional embodiments of the present application, after any synchronization requesting client receives the first information to be synchronized sent by the server, if it is determined that there is a floating point error between the position information of the first moving object in the first logical frame of each client, the synchronization position information is determined based on the respective position information corresponding to the first moving object, and then the position information of the first moving object in the second logical frame is calculated based on the synchronization position information and the first interactive event information. In this way, without introducing a new physics engine or fixed-point numbers, by synchronizing the position of the previous frame before each frame of logical calculation, the floating point error caused by the physics engine provided by Unity during frame synchronization can be greatly reduced, and it will not burden the CPU.
[0084] Figure 3 FIG. 1 is a flowchart showing another method for synchronizing location information provided by one of the optional embodiments of the present application; Figure 3 As shown, the location information synchronization method provided in the embodiment of the present application is applied to any information synchronization client of at least one information synchronization client included in the information synchronization system, and the information synchronization system also includes at least one request synchronization client and server; comprising the following steps:
[0085] S301: Receive first information to be synchronized sent by the server; the first information to be synchronized includes first interaction event information of a first mobile object controlled by any of the requesting synchronization clients, and position information of the first mobile object in a first logical frame of each client in the information synchronization system.
[0086] S302: If there is a floating point error between the position information of the first mobile object in the first logical frame of each client, determine the synchronization position information based on each position information corresponding to the first mobile object.
[0087] S303: Calculate the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interaction event information.
[0088] It should be noted that Figure 3 The corresponding technical solution is applied to the information synchronization client. In this embodiment of the present application, the information synchronization client is mainly used for information synchronization. Of course, for the information synchronization client, it can sometimes also be used to request information synchronization. In view of the similarities in the content and execution principle of the information synchronization client and the request synchronization client, and the ability to achieve the same technical effect, no further description is given.
[0089] In a possible implementation, before receiving the first information to be synchronized sent by the server in step S301, the method further includes the following steps: sending third synchronization instruction information to the server; wherein the third synchronization instruction information includes the position information of the second mobile object controlled by the information synchronization client in the first logical frame, so that other clients in the information synchronization system synchronize the position information of the second mobile object.
[0090] In a possible implementation, the step S302 of determining the synchronization position information based on the various position information corresponding to the first mobile object includes the following steps: filtering out the synchronization position information from the various position information; or calculating the synchronization position information based on the various position information.
[0091] In a possible implementation, if the first interaction event information is event information of a physical collision of the first moving object; the step S303 of calculating the position information of the first moving object in the second logical frame based on the synchronous position information and the first interaction event information includes the following steps: based on the first interaction event information, controlling the preset physics engine to perform a rigid body collision simulation on the first moving object, and calculating the floating point number of the moving speed and the floating point number of the moving direction of the first moving object; calculating the position information of the first moving object in the second logical frame according to the floating point number of the moving speed, the floating point number of the moving direction and the synchronous position information of the first moving object.
[0092] In a possible implementation, if the first interaction event information is event information of a non-collision movement of the first moving object; the step S303 of calculating the position information of the first moving object in the second logical frame based on the synchronization position information and the first interaction event information includes the following steps: directly calculating the moving speed information and moving direction information of the first moving object according to the first interaction event information; calculating the position information of the first moving object in the second logical frame according to the moving speed information, moving direction information and the synchronization position information of the first moving object.
[0093] In a possible implementation, the location information synchronization method further includes the following steps: sending fourth synchronization instruction information to the server at a preset frame rate; the fourth synchronization instruction information at least includes the location information of the second mobile object controlled by the information synchronization client.
[0094] In a possible implementation, the location information synchronization method further includes the following steps: receiving second information to be synchronized sent by the server; the second information to be synchronized includes the location information and second interaction event information corresponding to the second mobile object controlled by the information synchronization client; and updating the location information of the second mobile object based on the second interaction event information.
[0095] In a possible implementation, the second information to be synchronized also includes the position information of the first moving object; if the second interaction event information is event information of a physical collision between the first moving object and the second moving object, then after receiving the second information to be synchronized sent by the server, the method also includes the following steps: based on the position information of the first moving object, synchronizing the position information of the first moving object; based on the second interaction event information, updating the synchronized position information of the first moving object.
[0096] In a possible implementation, after calculating the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interaction event information in step S303, the method further includes the following steps: sending the calculated position information of the first mobile object to the server.
[0097] In one of the optional embodiments of the present application, after receiving the first information to be synchronized sent by the server, if any information synchronization client determines that there is a floating point error between the position information of the first moving object in the first logical frame of each client, the synchronization position information is determined based on the respective position information corresponding to the first moving object, and then the position information of the first moving object in the second logical frame is calculated based on the synchronization position information and the first interactive event information. In this way, without introducing a new physics engine or fixed-point numbers, by synchronizing the position of the previous frame before each frame of logic calculation, the floating point error caused by the physics engine provided by Unity during frame synchronization can be greatly reduced, and it will not burden the CPU.
[0098] Figure 4 FIG. 1 shows a schematic diagram of a process of synchronizing location information of each client in a location information synchronization system provided in one optional embodiment of the present application; Figure 4As shown, the location information synchronization system includes three clients and a server, and the clients are client 1, client 2, and client 3. Any of client 1, client 2, and client 3 can be used as an information synchronization client or a request synchronization client, and can be specifically distinguished according to actual conditions. In the first logical frame, client 1, client 2, and client 3 all receive the action [1, 2, 3] (i.e., interactive event information) sent by the server. Client 1, client 2, and client 3 respectively calculate the position of the target mobile object in their respective first logical frames according to the action [1, 2, 3]. Among them, the position of the target mobile object calculated by client 1 is position x1, the position of the target mobile object calculated by client 2 is position x2, and the position of the target mobile object calculated by client 3 is position x3. After calculating the position of the target mobile object in the first logical frame, each client sends the position information of the target mobile object in its first logical frame to the server so that other clients can synchronize. At this time, client 1 also initiates action [4], and then sends client 1 together with the position information and action [4] of the target mobile object in the first logical frame to the server. The server aggregates the information sent by each client and then forwards the aggregated information to each client. Each client determines the synchronous position information of the target mobile object based on the position information of the target mobile object in the first logical frame of each client sent by the server. For example, position x3 is selected as the synchronous position information. Further, each client calculates the position information of the target mobile object in its second logical frame based on the synchronous position information and action [4] of the target mobile object, which are position x4, position x5, and position x6 respectively.
[0099] It can be seen from this that in the embodiment of the present application, at the beginning of each frame, the position synchronization is first performed using the position information transmitted by the previous frame (eg Figure 4 In the second logical frame, position x3 is selected as the synchronization result), and then logical calculation is performed (for example, in the second logical frame of Figure 5, the three clients obtain three results, position x4, position x5, and position x6, respectively), to obtain the position of the object in this frame. In this way, under the premise that there are calculation errors between different clients, the position of the previous frame is synchronized before each frame of logical calculation, and the floating-point error will not be accumulated, thus realizing the position synchronization using Unity's built-in floating-point physics engine under frame synchronization.
[0100] In one specific embodiment of the present application, the location information synchronization process of multiple logical frames is specifically described, including the following contents:
[0101] 1. The first logical frame:
[0102] Step (1): Client 1 initiates a movement event and sends its own position, that is, the position of character 1; Client 2 sends its own position of character 2.
[0103] Step (2), the server sends the movement event of client 1 and the positions of characters 1 and 2 to client 1 and client 2; after receiving the movement event of client 1, the two clients first synchronize the positions of the characters, and then calculate the new positions of characters 1 and 2 based on the received movement event of client 1. Before characters 1 and 2 collide, the positions of the characters in the two clients remain synchronized.
[0104] 2. Logical frame 2 to logical frame 60:
[0105] Step (3), after repeating the above process, at the 60th frame, character 1 of client 1 physically collides with character 2 of client 2. The two sides simulate rigid body collision through the floating-point physics engine provided by Unity, and obtain new speeds based on their own mass and speed. At this time, errors occur in the calculation results of client 1 and client 2.
[0106] Among them, client 1 calculates the new speed of character 1 to be 1.121565, and client 2 calculates the new speed of character 1 to be 1.121566. Clients 1 and 2 send the new positions of the characters to the server respectively.
[0107] 3. From the 61st logical frame to the 120th logical frame:
[0108] At this time, there is an error in the position of character 1 in client 1 and client 2, but according to the position synchronization information received before the logical calculation of each frame, the position error is always controlled below 10 to the power of -5.
[0109] 4. Logical frame 121:
[0110] After a period of decay, the speeds of character 1 and character 2 have become 0. Client 1 and Client 2 do not receive any movement events at this time. Their positions will be the result after synchronization at the 120th frame, and the positions of the characters in the two clients will be completely synchronized again.
[0111] It should be understood that if the error in each logical frame is not corrected during the game, the error between the two clients will reach 0.1 under continuous physical calculations, which is already a large error and will affect the operation of the game. The technical solution of the embodiment of the present application can keep the error below 10 to the power of -5, which has no effect on the game operation and ensures the synchronization of the position information of the moving objects between the clients to a certain extent.
[0112] Based on the same application concept, the embodiment of the present application also provides a location information synchronization device corresponding to the location information synchronization method provided in the above embodiment. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the location information synchronization of the above embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0113] Figure 5 FIG. 4 shows a functional module diagram of a position information synchronization device provided by one of the optional embodiments of the present application; Figure 5 As shown, the position information synchronization device 500 is applied to any request synchronization client of at least one request synchronization client included in the information synchronization system, and the information synchronization system also includes at least one information synchronization client and a server; the position information synchronization device 500 includes: a first receiving module 510, used to receive the first information to be synchronized sent by the server; the first information to be synchronized includes the first interactive event information of the first mobile object controlled by the request synchronization client, and the position information of the first mobile object in the first logical frame of each client in the information synchronization system; a first determination module 520, used to determine the synchronization position information based on the various position information corresponding to the first mobile object if there is a floating point error between the position information of the first mobile object in the first logical frame of each client; a first calculation module 530, used to calculate the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interactive event information.
[0114] In a possible implementation, Figure 5 As shown, the position information synchronization device 500 also includes a first sending module 540; the first sending module 540 is used to: before receiving the first information to be synchronized sent by the server, respond to the control instruction of the target user for the first mobile object, and send the first synchronization instruction information to the server; wherein the first synchronization instruction information includes the first interaction event information corresponding to the first mobile object, and the position information of the first mobile object in the first logical frame.
[0115] In a possible implementation, the control instruction corresponds to at least one of the following operations: a touch operation on a physical key; a touch operation on a virtual key in a user graphical interface.
[0116] In a possible implementation, Figure 5 As shown, the first determination module 520 is specifically used to determine the synchronization position information according to the following steps: filtering out the synchronization position information from the various position information; or calculating the synchronization position information according to the various position information.
[0117] In a possible implementation, Figure 5 As shown, if the first interactive event information is event information of a physical collision of the first moving object; the first calculation module 530 is specifically used to calculate the position information of the first moving object in the second logical frame according to the following steps: based on the first interactive event information, control the preset physics engine to perform a rigid body collision simulation on the first moving object, and calculate the floating point number of the moving speed and the floating point number of the moving direction of the first moving object; calculate the position information of the first moving object in the second logical frame according to the floating point number of the moving speed, the floating point number of the moving direction and the synchronization position information of the first moving object.
[0118] In a possible implementation, Figure 5 As shown, if the first interactive event information is event information of non-collision movement of the first moving object; the first calculation module 530 is specifically used to calculate the position information of the first moving object in the second logical frame according to the following steps: directly calculate the moving speed information and moving direction information of the first moving object according to the first interactive event information; calculate the position information of the first moving object in the second logical frame according to the moving speed information, moving direction information and the synchronization position information of the first moving object.
[0119] In a possible implementation, Figure 5 As shown, the first sending module 540 is further used to: send second synchronization instruction information to the server at a preset frame rate; the second synchronization instruction information at least includes the position information of the first moving object.
[0120] In a possible implementation, Figure 5 As shown, the first receiving module 510 is also used to: receive second information to be synchronized sent by the server; the second information to be synchronized includes at least one position information of a second mobile object controlled by the information synchronization client and second interaction event information; based on the position information of the second mobile object, synchronize the position information of the second mobile object; based on the second interaction event information, update the synchronized position information of the second mobile object.
[0121] In a possible implementation, Figure 5 As shown, if the second interaction event information is event information of a physical collision between the first moving object and the second moving object, then after receiving the second information to be synchronized sent by the server, the first receiving module 510 is also used to update the position information of the first moving object based on the second interaction event information.
[0122] In a possible implementation, Figure 5 As shown, after calculating the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interaction event information, the first sending module 540 is further used to: send the calculated position information of the first mobile object to the server.
[0123] In one of the optional embodiments of the present application, after receiving the first information to be synchronized sent by the server, if it is determined that there is a floating point error between the position information of the first moving object in the first logical frame of each client, the synchronization position information is determined based on the respective position information corresponding to the first moving object, and then the position information of the first moving object in the second logical frame is calculated based on the synchronization position information and the first interactive event information. In this way, without introducing a new physics engine or fixed-point numbers, by synchronizing the position of the previous frame before each frame of logic calculation, the floating point error caused by the physics engine provided by Unity during frame synchronization can be greatly reduced, and it will not burden the CPU.
[0124] Figure 6 FIG. 4 shows a functional module diagram of another position information synchronization device 600 provided in one optional embodiment of the present application; Figure 6 As shown, the position information synchronization device 600 is applied to any information synchronization client of at least one information synchronization client included in the information synchronization system, and the information synchronization system also includes at least one request synchronization client and a server; the position information synchronization device 600 includes: a second receiving module 610, used to receive the first information to be synchronized sent by the server; the first information to be synchronized includes the first interactive event information of the first mobile object controlled by any of the request synchronization clients, and the position information of the first mobile object in the first logical frame of each client in the information synchronization system; a second determination module 620, used to determine the synchronization position information based on the various position information corresponding to the first mobile object if there is a floating point error between the position information of the first mobile object in the first logical frame of each client; a second calculation module 630, used to calculate the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interactive event information.
[0125] In a possible implementation, Figure 6As shown, the position information synchronization device 600 also includes a second sending module 640; the second sending module 640 is used to: send third synchronization instruction information to the server before receiving the first information to be synchronized sent by the server; wherein the third synchronization instruction information includes the position information of the second mobile object controlled by the information synchronization client in the first logical frame, so that other clients in the information synchronization system can synchronize the position information of the second mobile object.
[0126] In a possible implementation, Figure 6 As shown, the second determination module 620 is used to determine the synchronization position information according to the following steps: filtering out the synchronization position information from the various position information; or calculating the synchronization position information according to the various position information.
[0127] In a possible implementation, Figure 6 As shown, if the first interactive event information is event information of a physical collision of the first moving object; the second calculation module 630 is used to calculate the position information of the first moving object in the second logical frame according to the following steps: based on the first interactive event information, control the preset physics engine to perform a rigid body collision simulation on the first moving object, and calculate the floating point number of the moving speed and the floating point number of the moving direction of the first moving object; calculate the position information of the first moving object in the second logical frame according to the floating point number of the moving speed, the floating point number of the moving direction and the synchronization position information of the first moving object.
[0128] In a possible implementation, Figure 6 As shown, if the first interactive event information is event information of the first moving object undergoing non-collision movement; the second calculation module 630 is used to calculate the position information of the first moving object in the second logical frame according to the following steps: directly calculate the moving speed information and moving direction information of the first moving object according to the first interactive event information; calculate the position information of the first moving object in the second logical frame according to the moving speed information, moving direction information and the synchronization position information of the first moving object.
[0129] In a possible implementation, Figure 6 As shown, the second sending module 640 is further used to: send fourth synchronization instruction information to the server at a preset frame rate; the fourth synchronization instruction information at least includes the position information of the second mobile object controlled by the information synchronization client.
[0130] In a possible implementation, Figure 6As shown, the second receiving module 610 is also used to: receive second information to be synchronized sent by the server; the second information to be synchronized includes the position information and second interaction event information corresponding to the second mobile object controlled by the information synchronization client; based on the second interaction event information, update the position information of the second mobile object.
[0131] In a possible implementation, Figure 6 As shown, the second information to be synchronized also includes the position information of the first moving object; if the second interaction event information is event information of a physical collision between the first moving object and the second moving object, then after receiving the second information to be synchronized sent by the server, the second receiving module 610 is also used to: synchronize the position information of the first moving object based on the position information of the first moving object; and update the synchronized position information of the first moving object based on the second interaction event information.
[0132] In a possible implementation, Figure 6 As shown, after calculating the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interaction event information, the second sending module 640 is further used to: send the calculated position information of the first mobile object to the server.
[0133] In one of the optional embodiments of the present application, after receiving the first information to be synchronized sent by the server, if it is determined that there is a floating point error between the position information of the first moving object in the first logical frame of each client, the synchronization position information is determined based on the respective position information corresponding to the first moving object, and then the position information of the first moving object in the second logical frame is calculated based on the synchronization position information and the first interactive event information. In this way, without introducing a new physics engine or fixed-point numbers, by synchronizing the position of the previous frame before each frame of logic calculation, the floating point error caused by the physics engine provided by Unity during frame synchronization can be greatly reduced, and it will not burden the CPU.
[0134] Based on the same application concept, see Figure 7 As shown, it is a structural diagram of an electronic device 700 provided in an embodiment of the present application, including: a processor 710, a memory 720 and a bus 730, wherein the memory 720 stores machine-readable instructions executable by the processor 710, and when the electronic device 700 is running, the processor 710 communicates with the memory 720 through the bus 730, and the machine-readable instructions are executed by the processor 710 when running as described above Figure 2 or Figure 3 The steps of the location information synchronization method.
[0135] Specifically, when the machine-readable instructions are executed by the processor 710, the following processing can be performed: receiving the first information to be synchronized sent by the server; the first information to be synchronized includes the first interactive event information of the first mobile object controlled by the requesting synchronization client, and the position information of the first mobile object in the first logical frame of each client in the information synchronization system; if there is a floating point error between the position information of the first mobile object in the first logical frame of each client, then determining the synchronization position information based on the respective position information corresponding to the first mobile object; and calculating the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interactive event information.
[0136] Specifically, when the machine-readable instructions are executed by the processor 710, another processing as follows can be performed: receiving the first information to be synchronized sent by the server; the first information to be synchronized includes the first interactive event information of the first mobile object controlled by any of the requesting synchronization clients, and the position information of the first mobile object in the first logical frame of each client in the information synchronization system; if there is a floating point error between the position information of the first mobile object in the first logical frame of each client, determining the synchronization position information based on the respective position information corresponding to the first mobile object; and calculating the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interactive event information.
[0137] Based on the same application concept, the embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, and the computer program is executed by a processor when it is run. Figure 2 or Figure 3 Steps of the location information synchronization method.
[0138] Specifically, the storage medium can be a general storage medium, such as a mobile disk, a hard disk, etc. When the computer program on the storage medium is run, the above-mentioned position information synchronization method can be executed. Without introducing a new physics engine or fixed-point number, by synchronizing the position of the previous frame before each frame of logical calculation, the floating-point error caused by the physics engine provided by Unity during frame synchronization can be greatly reduced, and it will not bring any burden to the CPU.
[0139] In the embodiment of the present application, the computer program can also execute other machine-readable instructions when run by the processor to execute other methods described in the embodiment. For the specific execution method steps and principles, please refer to the description of the embodiment, which will not be repeated here.
[0140] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0141] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0142] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0143] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0144] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.
[0145] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application. They should all be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A method for synchronizing location information, It is characterized in that The method is applied to any request synchronization client of at least one request synchronization client included in the information synchronization system, and the information synchronization system also includes at least one information synchronization client and a server; the method includes: Receive first information to be synchronized sent by the server; the first information to be synchronized includes first interaction event information of a first mobile object controlled by the requesting synchronization client, and position information of the first mobile object in a first logical frame of each client in the information synchronization system; If there is a floating point error between the position information of the first mobile object in the first logical frame of each client, determining the synchronization position information based on each position information corresponding to the first mobile object; Based on the synchronization position information and the first interaction event information, the position information of the first mobile object in the second logical frame is calculated.
2. The method according to claim 1, It is characterized in that Before receiving the first information to be synchronized sent by the server, the method further includes: In response to a control instruction of a target user for the first mobile object, sending first synchronization instruction information to the server; The first synchronization instruction information includes first interaction event information corresponding to the first moving object and position information of the first moving object in the first logical frame.
3. The method according to claim 2, It is characterized in that The control instruction corresponds to at least one of the following operations: Touch operations on physical buttons; touch operations on virtual buttons in the user graphical interface.
4. The method according to claim 1, It is characterized in that The determining the synchronization position information based on each position information corresponding to the first mobile object includes: Filtering the synchronization location information from the various location information; or, The synchronization position information is calculated according to the respective position information.
5. The method according to claim 1, It is characterized in that If the first interaction event information is event information of a physical collision of the first moving object; the calculating the position information of the first moving object in the second logical frame based on the synchronization position information and the first interaction event information includes: Based on the first interaction event information, control a preset physics engine to perform a rigid body collision simulation on the first moving object, and calculate a floating point number of a moving speed and a floating point number of a moving direction of the first moving object; The position information of the first moving object in the second logical frame is calculated according to the floating point number of the moving speed, the floating point number of the moving direction and the synchronous position information of the first moving object.
6. The method according to claim 1, It is characterized in that If the first interaction event information is event information of a non-collision movement of the first moving object; The calculating, based on the synchronization position information and the first interaction event information, the position information of the first mobile object in the second logical frame includes: Directly calculating the moving speed information and the moving direction information of the first moving object according to the first interaction event information; The position information of the first moving object in the second logical frame is calculated according to the moving speed information, the moving direction information and the synchronization position information of the first moving object.
7. The method according to claim 1, It is characterized in that The method further comprises: Sending second synchronization instruction information to the server at a preset frame rate; the second synchronization instruction information at least includes the position information of the first mobile object.
8. The method according to claim 1, It is characterized in that The method further comprises: receiving second information to be synchronized sent by the server; the second information to be synchronized includes at least one location information of a second mobile object controlled by the information synchronization client and second interaction event information; Based on the position information of the second mobile object, synchronizing the position information of the second mobile object; Based on the second interaction event information, the synchronized position information of the second mobile object is updated.
9. The method according to claim 8, It is characterized in that If the second interaction event information is event information of a physical collision between the first moving object and the second moving object, then after receiving the second information to be synchronized sent by the server, the method further includes: Based on the second interaction event information, the position information of the first moving object is updated.
10. The method according to claim 1, It is characterized in that After calculating the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interaction event information, the method further includes: The calculated position information of the first mobile object is sent to the server.
11. A method for synchronizing location information, It is characterized in that The method is applied to any information synchronization client of at least one information synchronization client included in the information synchronization system, and the information synchronization system also includes at least one request synchronization client and a server; the method includes: Receive first information to be synchronized sent by the server; the first information to be synchronized includes first interaction event information of a first mobile object controlled by any of the requesting synchronization clients, and position information of the first mobile object in a first logical frame of each client in the information synchronization system; If there is a floating point error between the position information of the first mobile object in the first logical frame of each client, determining the synchronization position information based on each position information corresponding to the first mobile object; Based on the synchronization position information and the first interaction event information, the position information of the first mobile object in the second logical frame is calculated.
12. A location information synchronization device, It is characterized in that The device is applied to any request synchronization client of at least one request synchronization client included in the information synchronization system, and the information synchronization system also includes at least one information synchronization client and a server; the device includes: A first receiving module is used to receive first information to be synchronized sent by the server; the first information to be synchronized includes first interaction event information of a first mobile object controlled by the requesting synchronization client, and position information of the first mobile object in a first logical frame of each client in the information synchronization system; A first determining module, configured to determine synchronization position information based on each position information corresponding to the first mobile object if there is a floating point error between the position information of the first mobile object in the first logical frame of each client; The first calculation module is used to calculate the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interaction event information.
13. A location information synchronization device, It is characterized in that The device is applied to any information synchronization client of at least one information synchronization client included in the information synchronization system, and the information synchronization system also includes at least one request synchronization client and a server; the device includes: A second receiving module is used to receive first information to be synchronized sent by the server; the first information to be synchronized includes first interaction event information of a first mobile object controlled by any of the requesting synchronization clients, and position information of the first mobile object in a first logical frame of each client in the information synchronization system; a second determining module, configured to determine synchronization position information based on each position information corresponding to the first mobile object if there is a floating point error between the position information of the first mobile object in the first logical frame of each client; The second calculation module is used to calculate the position information of the first mobile object in the second logical frame based on the synchronization position information and the first interaction event information.
14. An electronic device, It is characterized in that include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and the machine-readable instructions are executed by the processor to perform the steps of the location information synchronization method as described in any one of claims 1 to 10 when running, or to perform the steps of the location information synchronization method as described in claim 11 when running.
15. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program executes the steps of the location information synchronization method according to any one of claims 1 to 10, or executes the steps of the location information synchronization method according to claim 11.
Citation Information
Patent Citations
Method and device for realizing drifting effect in game, equipment and storage medium
CN109718540A
Smooth display method, terminal and computer storage medium
CN111167116A