Method for enabling game server to directly run physical scene of client
By building a physics engine into the game server and exporting the client level configuration file, the problem of the server being unable to directly run client physics scenes is solved, enabling rich scene calculations and efficient game development to meet the needs of large-scale games.
Patent Information
- Application Number
- CN202410743952.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-10-15
AI Technical Summary
In the existing technology, the game server cannot directly run the level scenes with the physics system edited by the client, resulting in a slow game development process, high maintenance costs, and the inability to achieve complete physical simulation, causing the game to lose fun and richness.
The server has a built-in physics engine that matches the game. By exporting and loading the level configuration file of the client engine, the physical world and level objects are created, frame push calculations and collision event processing are performed, and video files are generated and sent to the client for playback.
It enables the server to directly run client physical scenes, provides richer scene change effects, reduces the workload of the game development team, reduces learning costs and development time, and improves game development efficiency.
Smart Images

Figure CN118767423A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of game development, and in particular to a method for enabling a game server to directly run a client physical scene. Background Art
[0002] In the field of game development, in order to prevent cheating on the client side, developers often add verification of the level process and level results to the server. Among them, the most direct and effective method is for the server to calculate the level and generate a video for the client to play, which completely eliminates the possibility of cheating. For physics-based games, the client engine often provides a wealth of tools that can edit level scenes, level units, etc. in the editor. However, since the server's development language and operating environment are different from those of the client, these edited level scenes cannot be run directly. Therefore, developers often need to give up the rich functions of the client engine and develop their own configuration format so that their own servers can load and run, which also leads to problems such as slow game development and high maintenance costs.
[0003] There is a solution: the level scene is calculated by the server, but it simply simulates the physical characteristics without using the complete physical function. For example, when an object falls to the ground, the program calculates the speed at the time of collision based on the acceleration of gravity, and then simply calculates the speed after rebounding according to a certain method. This is because the implementation of the physics engine is very complex, and it is very difficult to require programmers to implement it completely. However, this will cause the game to lose some of its fun and richness. In a complete physical simulation, objects can contain various settings such as friction and elasticity, and fun game scenes can be designed by adjusting these parameters.
[0004] Another solution is that the server does not perform a complete check of the level scene, but only checks the key steps. For example, when a bullet hits our wall and causes damage, the client makes a collision determination on its own, notifies the server of the collision event, and the server calculates the damage value. Since the collision determination is calculated by the client itself, the client has a lot of room for cheating. As long as the client does not report the event of the enemy bullet colliding with our wall through cheating, the server cannot calculate the corresponding damage. In this way, our wall can always avoid damage, so that we always win. Summary of the invention
[0005] The purpose of the present invention is to provide a method that enables a game server to directly run a client's physical scene, thereby solving the problems existing in the prior art and allowing the server to directly run a game scene with a physical system that has been edited in the client's game engine.
[0006] In order to achieve the above object, the solution of the present invention is:
[0007] A method for enabling a game server to directly run a client physics scene, wherein the server has a built-in physics engine matching the game, and includes the following steps:
[0008] Step 1: Game planner designs levels in the client engine;
[0009] Step 2: Export the configuration file of the level in the client engine and save it in a file format that can be recognized and read by the server;
[0010] Step 3: When the client requests to calculate a certain level, the server loads the configuration file of the corresponding level and creates the physical world and its level objects in the memory;
[0011] Step 4: The server calculates the level object. Each frame push includes the following steps:
[0012] 4-1. Call the frame push function of the physical world corresponding to the level;
[0013] 4-2. Get the latest position and rotation information of each object in the level and synchronize it with the game logic;
[0014] 4-3. Get the collision event that occurred in this frame;
[0015] 4-4. Perform logical processing on the latest position, rotation information and collision events of each object in this frame, and write the current frame number and its corresponding data into the memory or a specific data recording file;
[0016] 4-5. Determine whether the level has ended. If not, return to 4-1 to continue the cycle. If it has ended, proceed to 4-6;
[0017] 4-6. Destroy the physical world and the level ends;
[0018] 4-7. After a preset time interval or after a level is completed, the server will convert the recorded data in the memory or a specific data recording file into a video file and send it to the client for playback.
[0019] The physics engine matched with the game is a 2D physics engine or a 3D physics engine.
[0020] Preferably, the 2D physics engine is Box2D, and the 3D physics engine is PhysX.
[0021] In step 2, the configuration file exported by the client engine includes global physical configuration, scene configuration and object configuration.
[0022] Preferably, in step 3, the specific steps of creating a level object in the memory by the server are:
[0023] 3-1. Call the physics engine API to create a physics world and load the global physics configuration in the configuration file;
[0024] 3-2. Load the scene configuration in the configuration file and create a scene object;
[0025] 3-3. Traverse each object configuration in the scene and create object objects.
[0026] After adopting the above technical solution, the present invention has the following technical effects:
[0027] The present invention builds a bridge between the client engine and the server, so that the level scenes edited in the client engine can be directly put into operation on the server, and the server can calculate richer and more interesting scene change effects to meet the needs of some large-scale games; for programmers in the game development team, the step of formulating rules is omitted, which is more efficient; for design positions such as game planning and art, the corresponding game scenes can be directly edited using existing knowledge and applied to the final product, with lower learning costs, which can speed up the game development process and improve game development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a logic block diagram of a specific embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to further explain the technical solution of the present invention, the present invention is described in detail below through specific embodiments.
[0030] The present invention discloses a method for enabling a game server to directly run a client physical scene, wherein the server is equipped with a built-in physical engine matching the game, and comprises the following steps:
[0031] Step 1: The game planner designs the level in the client engine. Generally, a level is represented by a scene, and a single scene can contain a variety of objects.
[0032] Step 2: Because the server cannot directly use the file format of the client engine, it is necessary to export the configuration file of the level in the client engine and save it in a file format that can be recognized and read by the server. The file format can be a text format (such as json, txt, etc.) or a custom binary format, as long as the server can recognize and read it.
[0033] Step 3: When the client requests to calculate a certain level, the server loads the configuration file of the corresponding level and creates the physical world and its level objects in memory.
[0034] Step 4: The server calculates the level object, refer to Figure 1 As shown, each frame push includes the following steps:
[0035] 4-1. Call the frame push function (Step) of the physical world corresponding to the level;
[0036] 4-2. Get the latest position and rotation information of each object in the level (GetItemTransform) and synchronize it to the game logic to make it consistent with the physical world;
[0037] 4-3. Get the collision events that occurred in this frame (GetCollisionEvents);
[0038] 4-4. Perform logical processing on the latest position, rotation information and collision events of each object in this frame, and write the current frame number and its corresponding data (such as the latest position, rotation information and collision events of each object and various attribute values) into the memory or a specific data recording file;
[0039] 4-5. Determine whether the level has ended. If not, return to 4-1 to continue the cycle. If it has ended, proceed to 4-6;
[0040] 4-6. Destroy the physical world and the level ends;
[0041] 4-7. After a preset time interval or after the end of a level, the server will record the data in the memory or a specific data recording file into a video file and send it to the client for playback. Since the video file has covered the entire process, the client does not need to perform level logic operations, but only needs to add corresponding performances to each frame, such as playback effects, interface performance, etc. If the server operation process takes a long time, it can send the video data to the client for playback while calculating; if the video data is too large, it can be compressed first, such as in zip format.
[0042] Through the above scheme, the present invention realizes building a bridge between the client engine and the server, so that the level scenes that have been edited in the client engine can be directly put into operation on the server, and the server can calculate richer and more interesting scene change effects to meet the needs of some large-scale games; for programmers in the game development team, the step of formulating rules is omitted, which is more efficient; for design positions such as game planning and art, the corresponding game scenes can be directly edited using existing knowledge and applied to the final product, with lower learning costs, which can speed up the game development process and improve game development efficiency.
[0043] Specific embodiments of the present invention are shown below.
[0044] Since the server runs independently and cannot directly use the physics module of the client engine, it is necessary to give the server the ability to simulate the physical world during design. Currently, the more stable and reliable 2D physics engine is Box2D, and the 3D physics engine is PhysX. These physics engines are usually open source and can be directly introduced into the project as dependencies. You can choose according to the needs of the project. Of course, the actual application is not limited to these two physics engines. As long as the source code can be obtained and introduced into the server, it can be used.
[0045] Furthermore, the introduced physics engine is usually developed in C++, while the server may or may not be C++. If the server is C++, you can directly call the API of the physics engine; otherwise, you need to consult the documentation of the corresponding language to confirm how to call each other with C++. Examples of the interfaces that need to be used are:
[0046] ① Create a physical world (CreateWorld): During initialization, call this interface to create a physical world;
[0047] ②Destroy the physical world: At the end of the level, adjust this interface to destroy the physical world;
[0048] ③ Frame push (Step): The physical world is advanced frame by frame, and this interface needs to be called FPS times per second;
[0049] ④Create Rigidbody: Call this interface to create a rigid body;
[0050] ⑤Destroy rigid body: When an object in a game dies, this interface is called to destroy the corresponding rigid body in the physical world;
[0051] ⑥Create Collider: Call this interface to add a collider of a certain shape to the rigid body;
[0052] ⑦GetCollisionEvents: In the physical world, collision events occur when two collision bodies overlap. The game can obtain these events in each frame for logical processing;
[0053] ⑧Get object position and rotation value (GetItemTransform): Get the latest position of each object after a physical frame from the physical world, which is used to synchronize with the game for logical operations.
[0054] In step 2 above, the configuration files exported by the client engine include global physics configuration, scene configuration and object configuration. Among them, the global physics configuration is a unified configuration, which is independent of the specific level and is configured in the client engine. Its configuration items include: frames per second (FPS), gravity coefficient (controls the gravity, the default value is the same as the earth, about -9.8), collision relationship table (which collision bodies will collide and which will not), etc.; the scene configuration includes a list of all objects in this scene, as well as other game-specific configuration items; object configuration configuration items include: position (representing its position in the physical world, 2D games contain x, y, 3D games contain x, y, z), rotation (representing its rotation value in the physical world, 2D games only need z, 3D games contain x, y, z), rigid body (representing that it corresponds to a rigid body object in the physical world. Generally speaking, the client engine can freely configure the various properties of the rigid body and customize it according to the actual needs of the project. The above properties can be rigid body type, mass and gravity scaling value, etc.), collider (representing its shape in the physical world. Common ones are circular colliders and square colliders. Colliders of different shapes require slightly different data to be exported. For example, circular colliders require the export of radius, while square colliders require the export of width and height, that is, the exported data must reflect the shape characteristics), custom script (code that controls this object, for example, the function may be: detect whether this object has been collided, and if so, take corresponding measures) and other game-specific configuration items.
[0055] Furthermore, in the above step 3, the specific steps for the server to create a level object in memory are:
[0056] 3-1. Call the physics engine API (CreateWorld) to create a physics world and load the global physics configuration in the configuration file;
[0057] 3-2. Load the scene configuration in the configuration file and create a scene object;
[0058] 3-3. Traverse each object configuration in the scene and create an object object. If the object contains a rigid body, call the API of the physics engine to create the rigid body and import the rigid body parameters of the object configuration; if the object contains a collider, call the API of the physics engine to create the collider and import the collider parameters of the object configuration; if the object contains a custom script, create this script object in memory; in addition, it also contains other custom game objects.
[0059] The above embodiments and drawings do not limit the product form and style of the present invention. Any appropriate changes or modifications made by ordinary technicians in the relevant technical field should be deemed to be within the patent scope of the present invention.
Claims
1. A method for enabling a game server to directly run a client physics scene, characterized in that The server has a built-in physics engine that matches the game and includes the following steps: Step 1: Game planner designs levels in the client engine; Step 2: Export the configuration file of the level in the client engine and save it in a file format that can be recognized and read by the server; Step 3: When the client requests to calculate a certain level, the server loads the configuration file of the corresponding level and creates the physical world and its level objects in the memory; Step 4: The server calculates the level object. Each frame push includes the following steps: 4-1. Call the frame push function of the physical world corresponding to the level; 4-2. Get the latest position and rotation information of each object in the level and synchronize it with the game logic; 4-3. Get the collision event that occurred in this frame; 4-4. Perform logical processing on the latest position, rotation information and collision events of each object in this frame, and write the current frame number and its corresponding data into the memory or a specific data recording file; 4-5. Determine whether the level has ended. If not, return to 4-1 to continue the cycle. If it has ended, proceed to 4-6; 4-6. Destroy the physical world and the level ends; 4-7. After a preset time interval or after a level is completed, the server will convert the recorded data in the memory or a specific data recording file into a video file and send it to the client for playback.
2. The method for enabling a game server to directly run a client physical scene as claimed in claim 1, characterized in that: The physics engine matched with the game is a 2D physics engine or a 3D physics engine.
3. The method for enabling a game server to directly run a client physical scene as claimed in claim 2, characterized in that: The 2D physics engine is Box2D, and the 3D physics engine is PhysX.
4. The method for enabling a game server to directly run a client physical scene as claimed in claim 1, characterized in that: In step 2, the configuration file exported by the client engine includes global physical configuration, scene configuration and object configuration.
5. The method for enabling a game server to directly run a client physical scene as claimed in claim 4, characterized in that: In step 3, the specific steps of creating a level object in memory by the server are: 3-1. Call the physics engine API to create a physics world and load the global physics configuration in the configuration file; 3-2. Load the scene configuration in the configuration file and create a scene object; 3-3. Traverse each object configuration in the scene and create object objects.
