CN111298429A - Method and device for synchronizing states of virtual vehicles in game - Google Patents

Method and device for synchronizing states of virtual vehicles in game Download PDF

Info

Publication number
CN111298429A
CN111298429A CN202010044944.4A CN202010044944A CN111298429A CN 111298429 A CN111298429 A CN 111298429A CN 202010044944 A CN202010044944 A CN 202010044944A CN 111298429 A CN111298429 A CN 111298429A
Authority
CN
China
Prior art keywords
virtual vehicle
server
vehicle
virtual
state information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010044944.4A
Other languages
Chinese (zh)
Inventor
陈思浓
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202010044944.4A priority Critical patent/CN111298429A/en
Publication of CN111298429A publication Critical patent/CN111298429A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/30Interconnection arrangements between game servers and game devices; Interconnection arrangements between game devices; Interconnection arrangements between game servers
    • A63F13/35Details of game servers
    • A63F13/358Adapting the game course according to the network or server load, e.g. for reducing latency due to different connection speeds between clients
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/55Controlling game characters or game objects based on the game progress
    • A63F13/57Simulating properties, behaviour or motion of objects in the game world, e.g. computing tyre load in a car race game
    • A63F13/577Simulating properties, behaviour or motion of objects in the game world, e.g. computing tyre load in a car race game using determination of contact between game characters or objects, e.g. to avoid collision between virtual racing cars

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention provides a method and a device for synchronizing states of virtual vehicles in games, which relate to the technical field of game scene application, and the method comprises the steps of synchronizing first state information of the virtual vehicles to a server in a period that the virtual vehicles are controlled by a client, wherein the first state information is used for collision prediction calculation of the virtual vehicles by the server; the virtual vehicles are switched to be controlled by the server in response to a first switching instruction sent by the server when the virtual vehicles are predicted to collide, and second state information of the virtual vehicles in a period controlled by the server and sent by the server is received, so that the technical problem that the vehicles in the game clients are not consistent in posture synchronously is solved.

Description

Method and device for synchronizing states of virtual vehicles in game
Technical Field
The present application relates to the field of game scene application technologies, and in particular, to a method and an apparatus for synchronizing states of virtual vehicles in a game.
Background
With the improvement of game technology and game quality, the carrier system becomes an indispensable part of many online games. Role synchronization in a common Massively Multiplayer Online (MMO) network game is classified into state synchronization and frame synchronization. The vehicle synchronization is different from the role synchronization, and the physical vehicle needs the synchronization position and direction involved in the role synchronization and also involves the problem of attitude consistency when a plurality of vehicles collide.
Because the physical simulation performance of the carrier is high in consumption, most network games place the physical carrier on the client for simulation, and upload simulation results to the server, and the server is only responsible for forwarding snapshot information uploaded by each client. However, since the communication delay time between different clients and the server may be different, the physical simulation results of the respective clients are inconsistent when the carriers collide with each other, which causes a problem that the postures of the carriers in the multiple clients are inconsistent after the physical collision.
Disclosure of Invention
The invention aims to provide a method and a device for synchronizing states of virtual vehicles in games, which aim to solve the technical problem that the vehicles in game clients are inconsistent in synchronization posture.
In a first aspect, an embodiment of the present application provides a method for synchronizing states of virtual vehicles in a game, which is applied to a game client, and the method includes:
synchronizing first state information of the virtual vehicle to a server in a period that the virtual vehicle is controlled by a client, wherein the first state information is used for collision prediction calculation of the virtual vehicle by the server;
in response to a first switching instruction sent by the server when the virtual vehicle is predicted to collide, switching the virtual vehicle to be controlled by the server, and receiving second state information of the virtual vehicle sent by the server in a period controlled by the server.
In an optional implementation, before the step of synchronizing the first state information of the virtual vehicle to the server, the method further includes:
determining first state information of the virtual vehicle according to a first operation instruction aiming at the virtual vehicle in a period that the virtual vehicle is controlled by a client.
In an optional implementation, the step of determining first state information of the virtual vehicle according to a first operation instruction for the virtual vehicle includes:
creating a first simulation carrier based on the virtual carrier according to a first operation instruction aiming at the virtual carrier, and simulating to obtain the current state of the first simulation carrier;
determining first state information of the virtual vehicle based on the current state of the first simulated vehicle, wherein the first state information of the virtual vehicle smoothly approaches the current state of the first simulated vehicle.
In an optional implementation, before the step of receiving second status information of the virtual vehicle sent by the server within a period controlled by the server, the method further includes:
synchronizing the first operation instruction to the server during a period in which the virtual vehicle is controlled by the server, so that the server determines second state information of the virtual vehicle based on the first operation instruction.
In an optional implementation, before the step of receiving second status information of the virtual vehicle sent by the server within a period controlled by the server, the method further includes:
determining a second operation instruction for the virtual vehicle in a period that the virtual vehicle is controlled by a server;
synchronizing the second operating instruction to the server to cause the server to determine third state information of the virtual vehicle based on the second operating instruction.
In an optional implementation, the second state information for the virtual vehicle is a current state of a second simulated vehicle of the virtual vehicle; after the step of receiving second state information of the virtual vehicle sent by the server within a period controlled by the server, the method comprises the following steps:
determining a current state of the virtual vehicle based on second state information of the second simulated vehicle, the current state of the virtual vehicle smoothly approaching the current state of the second simulated vehicle.
In a second aspect, an embodiment provides a method for synchronizing a state of a virtual carrier in a game, which is applied to a server, and the method includes:
synchronizing first state information of the virtual vehicle during a period in which the virtual vehicle is controlled by a client;
performing collision prediction for the virtual vehicle based on first state information of the virtual vehicle;
when the virtual vehicle is predicted to collide, a first control right switching instruction is sent to the client, the virtual vehicle is switched to be controlled by the server, and second state information of the virtual vehicle in a period controlled by the server is synchronized to the client.
In an optional implementation, the step of performing collision prediction for the virtual vehicle based on the first state information of the virtual vehicle includes:
establishing a direction bounding box of the virtual vehicle based on the current state and physical parameters of the virtual vehicle;
collision detection is performed by the directional bounding box of the virtual vehicle.
In an optional embodiment, the current state includes a vehicle position, a vehicle speed, a vehicle forward direction vector, a vehicle right direction vector and a vehicle estimated movement time, and the physical parameters include a vehicle length, a vehicle width and a vehicle width additional value.
In an optional implementation, the performing collision detection by the virtual vehicle includes:
if the projections of the direction bounding boxes of at least two virtual vehicles on all coordinate axes are overlapped, judging that the virtual vehicles collide;
and if the projections of the directional bounding boxes of at least two virtual vehicles on all coordinate axes are not overlapped, judging that the virtual vehicles cannot collide.
In an optional implementation, before the step of collision detection by the orientation bounding box of the virtual vehicle, the method further includes:
respectively carrying out height detection and range detection according to the vertical distance and the horizontal distance between the center point of the virtual vehicle and the center point of the virtual vehicle to be collided;
and when the vertical distance is smaller than a preset height distance threshold value and the horizontal distance is smaller than the sum of the lengths of the virtual vehicle and the virtual vehicle to be collided, executing a step of collision detection through a direction bounding box of the virtual vehicle.
In an optional implementation, before the step of synchronizing, to the client, second state information of the virtual vehicle during the period controlled by the server, the method further includes:
determining second state information of the virtual vehicle according to a first operation instruction aiming at the virtual vehicle in a period that the virtual vehicle is controlled by a server.
In a third aspect, an embodiment provides a device for synchronizing states of virtual vehicles in a game, which is applied to a game client, and the device includes:
a first state determination module, configured to synchronize, to a server, first state information of the virtual vehicle during a period in which the virtual vehicle is controlled by a client, where the first state information is used for performing collision prediction calculation on the virtual vehicle by the server;
the first synchronization module is used for responding to a first switching instruction sent by the server when the virtual vehicle is predicted to collide, switching the virtual vehicle to be controlled by the server, and receiving second state information of the virtual vehicle in a period controlled by the server, wherein the second state information is sent by the server.
In a fourth aspect, an embodiment provides an apparatus for synchronizing states of virtual vehicles in a game, where the apparatus is applied to a server, and the apparatus includes:
a second synchronization module, configured to synchronize first state information of the virtual vehicle during a period in which the virtual vehicle is controlled by a client;
a prediction module to perform collision prediction for the virtual vehicle based on first state information of the virtual vehicle;
and the second state determination module is used for sending a first control right switching instruction to the client when the virtual vehicle is predicted to collide, switching the virtual vehicle to be controlled by the server, and synchronizing second state information of the virtual vehicle in a period controlled by the server to the client.
In a fifth aspect, an embodiment provides a terminal, including a memory and a processor, where the memory stores a computer program operable on the processor, and the processor executes the computer program to implement the steps of the method in any one of the foregoing embodiments.
In a sixth aspect, an embodiment provides a server, including a memory and a processor, where the memory stores a computer program operable on the processor, and the processor implements the steps of the method described in any one of the foregoing embodiments when executing the computer program.
In a seventh aspect, embodiments provide a machine-readable storage medium having stored thereon machine-executable instructions that, when invoked and executed by a processor, cause the processor to carry out the steps of the method of any preceding embodiment.
The embodiment of the invention provides a method and a device for synchronizing the state of a virtual carrier in a game, which can realize the purpose of synchronizing the collision postures of the carriers of all clients by switching the carrier control rights of the clients and a server. When the vehicle control right is at the client, the vehicle collision does not occur at the moment, the client determines the first state information of the virtual vehicle and synchronizes to the server, so that the server synchronizes to other clients in the current game scene, the operation delay is reduced, and the server operation load is reduced. And when the collision of the vehicles is predicted, the control right is given to the server, the server generates second state information of the virtual vehicles and synchronizes to each client in the current game scene, and the problem of inconsistent postures after the vehicles collide and synchronize is solved.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
Fig. 1 is a schematic view of an application scenario provided in an embodiment of the present application;
fig. 2 is a schematic structural diagram of a mobile phone according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a server according to an embodiment of the present application;
fig. 4 is a flowchart illustrating a method for synchronizing states of virtual vehicles in a game according to an embodiment of the present disclosure;
fig. 5 is a second flowchart illustrating a method for synchronizing a state of a virtual vehicle in a game according to an embodiment of the present application;
FIG. 6 is a schematic projection diagram of a directional bounding box provided in an embodiment of the present application;
fig. 7 is a third flowchart illustrating a method for synchronizing states of virtual vehicles in a game according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a state synchronization device for a virtual vehicle in a game according to an embodiment of the present application;
fig. 9 is a second schematic structural diagram of a state synchronization device for a virtual vehicle in a game according to an embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions of the present application will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "comprising" and "having," and any variations thereof, as referred to in the embodiments of the present application, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements but may alternatively include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In a general game scene, under the state synchronization of game characters, a server needs to transmit snapshot information of positions, directions and the like of all players to each client through a network, and then the client performs interpolation expression according to a snapshot sequence. While frame synchronization for game characters is a synchronization scheme that encapsulates user input into frame messages to drive all clients. And the attitude data of the vehicle synchronization comprises the current position of the vehicle, three rotation angles, a yaw angle, a pitch angle and a roll angle.
Synchronization of vehicles in a game scene is generally achieved by the following two ways:
scheme 1), the client end simulates and determines the position and the rotation angle of the local carrier, and forwards the position and the rotation angle to other client ends through the server. The remote carriers (to-be-collided carriers) in the client are Kinematic objects with infinite mass, so that the problem that the physical carriers of the client collide can be avoided.
And in the scheme 2), the server performs physical simulation on the carrier and forwards the attitude information of the carrier to each client, each client is similar to a player, and only the physical position and the attitude information of the carrier sent by the server are expressed.
In the case of the scheme 1, the remote vehicle to be collided is a vehicle with infinite mass, that is, the local vehicle at the client cannot collide with the other vehicle. Although the problem of inconsistent postures of collision synchronization of the vehicles is solved by the solution, the problem that the collision of the physical vehicles is not real enough and does not accord with physical phenomena exists. Because the quality of the existing game is continuously improved, the state synchronization scheme of the virtual carrier in the game is not enough to meet the requirement of the current physical carrier system.
In case of the scheme 2, in the end-stream, since the network delay is small, the problem of inconsistent synchronization postures of the vehicles can be solved by performing the physical simulation of the vehicles through the server, but the performance pressure of the server is large at the same time. In the hand trip, because the network delay and the fluctuation are both large, if the server performs the carrier physical simulation, the operation delay of the mobile phone player user is high when the network fluctuates, and the experience is poor.
Based on this, the method and the device for synchronizing the states of the virtual vehicles in the game provided by the embodiment of the application solve the technical problem that the vehicles in each game client are inconsistent in synchronization posture, reduce operation delay, reduce the running load of the server, and improve user experience.
The physical vehicle in the embodiment of the present invention is actually a virtual physical vehicle displayed on the image user interface of the terminal, and is herein referred to as a virtual vehicle.
The method for synchronizing the state of the virtual carrier in the game in the embodiment of the application can be applied to the terminal and the server respectively. The terminal can be a local terminal, the server can comprise a PC (personal computer) terminal or an upper computer, and the state synchronization condition of the virtual carrier in the game scene can be provided for the local terminal through a graphical user interface to be displayed. The local terminal is used for interacting with a user through a graphical user interface. The manner in which the local terminal provides the graphical user interface to the player may include a variety of ways, for example, it may be rendered for display on a display screen of the terminal or provided to the player through holographic projection.
As another example, the local terminal may include a display screen to present a graphical user interface including game screens of a game scene in which the virtual vehicle is located, and a processor to run a client of the game, generate a graphical user interface, and control display of the graphical user interface on the display screen.
For example, fig. 1 is a schematic view of an application scenario provided in the embodiment of the present application. As shown in fig. 1, the application scenario may include a terminal (e.g., a cell phone 101, a computer, a tablet, etc.) and a server 102, and the terminal may communicate with the server 102 through a wired network or a wireless network. Wherein the terminal is configured to run a client through which interaction with the server 102 can be performed.
For another example, the terminal may further include a local terminal, wherein the local terminal is mainly used for displaying a graphical user interface for the client.
The following description will be given taking the mobile phone 101 as an example. As shown in fig. 2, the cellular phone 101 includes: transceiver 210, memory 220, display 230, processor 240, etc. Those skilled in the art will appreciate that the computer architecture shown in fig. 2 is not intended to be limiting of cell phones and may include more or fewer components than those shown, or some components may be combined, some components may be split, or a different arrangement of components. Those skilled in the art will appreciate that display 230 is part of a User Interface (UI) and that cell phone 101 may include fewer than or the same user interface shown.
The transceiver 210 may communicate with a network and other devices via wireless communication. The wireless communication may use any communication standard or protocol.
The memory 220 may be used to store software programs and modules, and the processor 240 executes various functional applications and data processing of the mobile phone 101 by operating the software programs and modules stored in the memory 220. The memory 220 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the cellular phone 101, and the like. Further, the memory 220 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The display screen 230 may be used to display a graphical user interface and to receive user operations with respect to the graphical user interface. Specific display screens 230 may include a display panel and a touch panel. The display panel may be configured in the form of an LCD (Liquid crystal display), an OLED (Organic Light-Emitting Diode), and the like.
The mobile phone 101 further includes an operation panel for receiving an operation on the graphical user interface, where the operation panel may be a touch panel covering the display screen 230, or a keyboard device, a mouse, and the like that are relatively independent from the display screen 230. Thus, the operation panel and the display screen 230 may be implemented as two separate components or may be integrated.
The operation panel receives information from operations such as pressing a key or touching the key, converts the information into information that can be processed by the processor, and sends the information to the processor 240, and the display 230 can receive and execute commands sent from the processor 240. For example, the operator panel, upon receiving an operation thereon or thereabout, communicates to the processor 240 to determine a user input, and the processor 240 then provides a corresponding visual output on the display screen 230 in response to the user input.
The processor 240 is a control center of the mobile phone 101, connects various parts of the entire mobile phone by using various interfaces and lines, and performs various functions of the mobile phone 101 and processes data by operating or executing software programs and/or modules stored in the memory 220 and calling data stored in the memory 220, thereby integrally monitoring the computer.
The handset 101 also includes a power supply (e.g., a battery) for powering the various components, which may be logically coupled to the processor 240 via a power management system to manage charging, discharging, and power consumption via the power management system.
Next, the server is explained with reference to fig. 3, and as shown in fig. 3, the server 300 includes: the processor 301, the memory 302 and the bus, the memory 302 stores machine readable instructions executable by the processor 301, when the electronic device is running, the processor 301 communicates with the memory 302 through the bus, and the processor 301 executes the machine readable instructions to execute the steps of the method for synchronizing the state of the virtual carrier in the game.
Specifically, the memory 302 and the processor 301 can be general-purpose memory and processor, and are not limited to the specific embodiments, and the above method can be performed when the processor 301 runs the computer program stored in the memory 302.
Those skilled in the art will appreciate that the configuration of the server shown in fig. 3 does not constitute a limitation of the development terminal, and may include more or fewer components than those shown, or some components may be combined, or some components may be split, or a different arrangement of components.
Embodiments of the present invention are further described below with reference to the accompanying drawings.
Fig. 4 is a flowchart illustrating a method for synchronizing states of virtual vehicles in a game according to an embodiment of the present disclosure. The method is applied to a game client, and as shown in fig. 4, the method comprises the following steps:
step S402, synchronizing first state information of the virtual vehicle to a server in a period that the virtual vehicle is controlled by a client, wherein the first state information is used for collision prediction calculation of the virtual vehicle by the server;
step S404, responding to a first switching instruction sent by the server when the virtual vehicle is predicted to collide, switching the virtual vehicle to be controlled by the server, and receiving second state information of the virtual vehicle in a period controlled by the server and sent by the server.
According to the embodiment of the application, in some game scenes with vehicle collision situations, the vehicle collision postures of the clients can be synchronized by switching the vehicle control rights of the clients and the server. When the vehicle control right is at the client, the vehicle collision does not occur at the moment, the client determines the first state information of the virtual vehicle and synchronizes to the server, so that the server synchronizes to other clients in the current game scene, the operation delay is reduced, and the server operation load is reduced. And when the collision of the vehicles is predicted, the control right is given to the server, the server generates second state information of the virtual vehicles and synchronizes to each client in the current game scene, and the problem of inconsistent postures after the vehicles collide and synchronize is solved.
It can be understood that, under the condition that the vehicles do not collide, the client takes over the control right of the virtual vehicle and forwards the determined first state information through the server, so that no operation delay exists; and when the collision is predicted, the control right of the virtual carrier is handed to the server, and the server forwards the generated second state information to each client so that the virtual carrier in each client determines the current game picture in the current game scene according to the second state information. Since the server simulates the processing vehicle to determine the second state information of the virtual vehicle, there may be a partial operation delay, but the average operation delay of this scheme is low because the server control time is relatively short.
The source of the first state information may be generated by a virtual vehicle under the operation control of a player, or may be obtained by self-simulation of a client. For example, the client records or calculates the first state information of the virtual vehicle by obtaining the player operation control instruction, or the client autonomously simulates the state of the virtual vehicle in an actual game scene (such as a bumpy road condition) to obtain the first state information.
The above steps S402-S404 will be described in detail with reference to specific embodiments.
In some embodiments, before synchronizing the first status information of the virtual vehicle to the server in step S402, the method further includes the following steps:
step 1.1), determining first state information of the virtual vehicle according to a first operation instruction aiming at the virtual vehicle in a period that the virtual vehicle is controlled by a client.
It can be understood that, when the game client takes over the control right of the carrier, the game client needs to simulate the virtual carrier according to the physical parameters of the virtual carrier and the first operation instruction input by the user, obtain the first state information, and synchronize the first state information to the server. At this moment, the server can obtain the first state information without physical simulation, and the first state information determined by the client is directly synchronized to the rest clients, so that the performance consumption of the server is effectively reduced.
In order to make the display effect of the virtual vehicle attitude data more accurate, each client may further smooth the simulated state data, and in some embodiments, the step 1.1) may further include the following steps:
step 1.1.1), according to a first operation instruction aiming at the virtual carrier, simulating to obtain the current state of a first simulation carrier based on the first simulation carrier created by the virtual carrier;
step 1.1.2), determining first state information of the virtual vehicle based on the current state of the first simulated vehicle, wherein the first state information of the virtual vehicle smoothly approaches to the current state of the first simulated vehicle.
It should be noted that the game client includes a local physical vehicle (a first simulation vehicle), and the server includes a physical vehicle (a second simulation vehicle) existing in the server, where the first simulation vehicle and the second simulation vehicle have the same physical parameters, that is, two identical physical vehicles except for different storage locations can be considered.
The current state in the above embodiments is the physical snapshot information obtained after the physical vehicle simulation, and may generally include the vehicle position, the vehicle rotation quaternion, the speed, and the like.
When the server sends a first control right switching instruction to the client, the client stops simulating to generate the first state information of the virtual carrier.
In some possible embodiments, step 1.1.2) may specifically comprise:
and calculating to obtain first state information of the virtual carrier by a line interpolation and weighted average interpolation method and the current state of the first simulation carrier.
Here, the posture-representation smoothing processing in the above-described embodiment may be realized by an interpolation algorithm. The embodiment of the invention is mainly applied to shooting type and tank type game scenes, wherein the tank carrier can still perform steering operation when the moving speed is not high, and the seamless switching effect is realized when the control right is switched between the game client and the server, so that the embodiment of the invention combines a weighted smooth interpolation method and a linear interpolation method to perform fusion interpolation.
On the basis of the above embodiments, in order to further achieve low operation delay, when the client hosts the virtual vehicle, the embodiment of the present invention achieves posture smoothing performance by creating two physical vehicles locally at the client. One of the simulation vehicles is a first simulation vehicle A, which can perform posture real expression according to the operation data, and can be simulated by a physical engine of the client after receiving the input instruction of the player, and the vehicle A is not displayed at the client. The other is a virtual carrier B which is displayed on the client side, and the player can view the virtual carrier through the client side. In addition, the server also comprises a second simulation carrier S for recording the position and the rotation quaternion of the carrier in the server. The vehicle B is processed to smoothly catch up with the vehicle a, so as to achieve low operation delay and display smooth effect, wherein the vehicle position catching up condition between the vehicles can be specifically realized by the following formula:
Pos=PosS*lerpt+PosA*(1-lerpt)
PosB=Pos*lerpb+PosB*(1-lerpb)
Figure BDA0002368479960000141
qB=slerp(q,qB,lerpb)=(qB*q-1)lerpbq
wherein, PosSRepresents the position, Pos, of the first simulated vehicle A at the client on the serverARepresents the position, Pos, of the first simulated vehicle A at the clientBRepresenting the location of virtual vehicle B at the client. q. q.sSQuaternion, q, representing the rotation angle of the first simulated vehicle A at the client on the serverAA quaternion representing the rotation angle of the first simulated vehicle A at the client, qBAnd a rotation angle quaternion representing the virtual vehicle B at the client.
In this specification, lerp istIs an interpolation parameter with the value range of [0,1 ]]In the meantime. When the client side is in master control of the first simulation carrier A, the lerptAt this point, the virtual vehicle B visible to the player continues to linearly interpolate the position of the first simulated vehicle a. And lerpbIn the range of [0.2,0.5 ]]Specifically, the network delay is determined, and when the network delay is high, lerp is determinedbIs correspondingly smaller, this is forThe distance between the position of the virtual carrier B and the position of the second simulation carrier S in the server is relatively close, so that the carriers are not accelerated or decelerated excessively when the control right of the carriers is switched. Similarly, the rotation angle catching-up situation among the carriers is realized by performing spherical interpolation on the rotation angle of the carriers. And will not be described in detail herein. Finally, setting the position Pos of the virtual carrier according to the calculation results of the position and the rotation angle of the carrierBAnd a rotation angle qB
In some embodiments, when the server determines that the virtual vehicle collision is over, and under the condition that the virtual vehicle does not collide, the server sends a second operation instruction to the client, and the server transfers the control right of the virtual vehicle to the client. At the moment, the client can buffer reversely, and the interpolation parameter lerp is continuously updated every frametWill be lerptFrom 1 to 0. When lerptWhen the virtual carrier B is equal to 0, the client controls the first simulated carrier again, and at this time, the virtual carrier B visible to the player continuously performs linear interpolation on the position of the first simulated carrier a, so as to realize the effect that the virtual carrier B smoothly catches up with the first simulated carrier a.
It is understood that gesture synchronization refers to all clients synchronizing the current time state of the virtual vehicle at other clients including the position and rotation angle through the server. When the client side is in master control of the virtual carrier, the client side needs to acquire local carrier data including a first operation instruction and physical parameters input by a user at regular time and synchronize the local carrier data to the server according to a fixed frequency. As an alternative embodiment, the server may make the second simulation vehicle have the same configuration as the first simulation vehicle in the client according to the physical parameters synchronized by the client. The physical parameters comprise the current rotation angle of the vehicle, the current position of the vehicle, the current linear speed and angular speed of the vehicle and the like.
In some embodiments, before the step S404 of synchronizing the server to determine the second status information of the virtual vehicle during the period of controlling the virtual vehicle belongs to the server, the method further includes the following steps:
step 2.1), synchronizing the first operation instruction to the server in a period that the virtual vehicle is controlled by the server, so that the server determines second state information of the virtual vehicle based on the first operation instruction.
Here, the server determines the second state information of the virtual vehicle according to the first operation instruction initially sent by the user. For example, initially (e.g., the time period when the control right belongs to the client), the user inputs an operation command of "control vehicle forward", and when the control right belongs to the server, the server still determines the second state information according to the initial user operation command of "vehicle forward".
As an optional embodiment, before receiving the second status information of the virtual vehicle sent by the server in the period controlled by the server in step S404 in the above embodiment, the method further includes:
step 3.1), determining a second operation instruction for the virtual vehicle in a period that the virtual vehicle is controlled by a server;
and 3.2) synchronizing the second operation instruction to the server, so that the server determines third state information of the virtual vehicle based on the second operation instruction.
Here, the server determines the third status information of the virtual vehicle according to the second operation instruction sent by the user at this time (the time period when the control right belongs to the server). For example, initially (e.g., the time period when the control right belongs to the client), the user inputs an operation command for "controlling the vehicle to move forward", and during the time period when the control right belongs to the server, the user inputs an operation command for controlling "vehicle to rotate", and the server generates the third state information of the current time according to the user operation command "vehicle to rotate".
In some embodiments, in order to further achieve the effect of smoothing the current posture determined by the server controlling the virtual vehicle, for the second state information of the virtual vehicle in the above embodiments, that is, the current state synchronized to the client is the current state of the second simulated vehicle of the virtual vehicle, after receiving the second state information of the virtual vehicle during the period controlled by the server sent by the server in step S404, the following method may be specifically adopted:
determining a current state of the virtual vehicle based on second state information of the second simulated vehicle, the current state of the virtual vehicle smoothly approaching the current state of the second simulated vehicle.
The physical carrier which is collided by the embodiment of the invention does not generate the effect that the carrier cannot be pushed because of the infinite mass of the remote carrier, and the authenticity of the collision can be greatly improved through the physical simulation of the server. In addition, due to the fact that collision prediction exists in the server, the control right of the physical vehicle between the server and the game client can be smoothly and seamlessly switched.
Fig. 5 is a second flowchart illustrating a method for synchronizing a state of a virtual vehicle in a game according to an embodiment of the present application. The method is applied to a server, and as shown in fig. 5, the method includes:
step S502, synchronizing first state information of the virtual vehicle during the period that the virtual vehicle is controlled by the client;
step S504, performing collision prediction on the virtual vehicle based on the first state information of the virtual vehicle;
step S506, when it is predicted that the virtual vehicle will collide, a first control right switching instruction is sent to the client, the virtual vehicle is switched to be controlled by the server, and second state information of the virtual vehicle during the period controlled by the server is synchronized to the client.
According to the embodiment of the application, when the server detects that the virtual carrier is collided, the server takes over the control right and sends the first control right switching instruction to the client, and after the client receives the first control right switching instruction, the client does not perform physical simulation on the virtual carrier any more. The client uploads the input information (first operation instruction) of the player, such as input of forward movement, steering and the like, to the server, then receives the carrier physical attitude information (current attitude) simulated by the server on the virtual carrier, and performs local expression on the client. And when the server detects that the virtual vehicles do not collide, sending a second control right switching instruction to the client, and forwarding the virtual vehicle attitude information (current state) simulated by the client to each client.
The client and the server complete the switching of the control right of the virtual carrier according to the collision condition of the carrier, and realize that the client simulates the synchronous posture without time delay when no collision occurs; when collision occurs, the server uniformly controls the virtual vehicles after the collision, so that the current postures (positions and rotations) presented by the virtual vehicles of the client terminals after the collision are consistent, and the technical problem that the postures of the vehicles in the game client terminals are inconsistent synchronously is solved.
In some possible embodiments, before synchronizing the second status information of the virtual vehicle in the server-controlled period to the client in step S506, the method further includes the following steps:
and 4.1) determining second state information of the virtual vehicle according to the first operation instruction aiming at the virtual vehicle in the period that the control right of the virtual vehicle belongs to the server.
In addition, the control time for the server to take over the virtual carrier is relatively short, and the time for participating in the simulation is also relatively short, so that compared with the scheme that the whole carrier collision process is simulated by the server, the physical simulation load of the server is greatly reduced.
In some possible embodiments, after receiving the local vehicle data timed and synchronized by the client, the server stores the local vehicle data in the physical end of the server, so as to facilitate simulated use after collision. Meanwhile, the server sends the local carrier data to other game clients in the current game scene so as to ensure that the attitude and the position of the carriers of all the clients are synchronous and correct.
On the basis of the foregoing embodiment, as another possible embodiment, when the server detects that the current location is about to collide, a first control right switching instruction is sent to the client. When the client receives a first control right switching instruction of the server, the control right is delivered from the client to the server. At this time, the client needs to start a buffering operation in the control right switching process to complete seamless switching, that is, the virtual vehicle B is smoothly switched from the chasing first simulated vehicle a to the chasing second simulated vehicle S, specifically:
client continuously updates lerp in each frametWill be lerptFrom 0 to 1. At this time, the position of the virtual vehicle B follows the weight calculation results of the first simulated vehicle a and the second simulated vehicle S, so as to smoothly switch the following objects. Finally, when the client switching is finished, lerptWhen the virtual vehicle is 1, the stage of the server for master control of the virtual vehicle is entered, the current posture of the virtual vehicle is completely controlled by the simulation of the server, and the virtual vehicle B at the moment always chases the second simulated vehicle S.
In some embodiments, in order to accurately detect the collision condition of the virtual vehicle, so as to implement timely switching of the control right of the virtual vehicle between the client and the server, and ensure consistency of synchronization of the postures of the virtual vehicle, the step S504 may specifically include the following steps:
step 5.1), establishing a direction bounding box of the virtual carrier based on the current state and physical parameters of the virtual carrier, wherein the current state comprises a carrier position, a carrier speed, a carrier forward direction vector, a carrier right direction vector and a carrier predicted movement duration, and the physical parameters comprise a carrier length, a carrier width and a carrier width added value;
and 5.2) carrying out collision detection through the direction bounding box of the virtual vehicle.
In some possible embodiments, a plurality of virtual vehicles may collide with each other in the game scene, and in order to ensure the accuracy and timeliness of the control right switching between the server and the client, collision prediction needs to be performed on all the virtual vehicles in the game scene at the server, so as to notify the client of the control right switching in advance.
In addition, since the embodiments of the present invention need to smoothly switch the control right of the client and the server, the vehicle of the client needs to be notified in advance before the collision occurs, so as to ensure that the control right switching is completed when the vehicle collides.
An embodiment of the present invention provides a collision detection algorithm capable of predicting a collision in advance, and as shown in fig. 6, a server represents a virtual vehicle by using a two-dimensional directional Bounding Box (OBB), and the directional Bounding Box is added with a speed factor for performing collision prediction. The server constructs direction bounding boxes according to the current state and the physical parameters, the virtual vehicles are enclosed inside the direction bounding boxes, and the direction bounding boxes of each vehicle are represented by the following formula:
center=posvh+forwardvh*speedvh*0.5*t
E1=lengthvh+speedvh*t
E2=widthvh+w
axis1=forwardvh
axis2=rightvh
wherein, axis1Denotes a first coordinate axis, axis2Denotes a second coordinate axis, E1First side length, E, representing the length of the bounding box2Second side length representing the bounding box length, center represents the center point, posvhIndicating the current position of the vehicle, forwardvhRepresenting the forward direction vector of the vehicle, rightvhRepresenting the right direction vector of the vehicle, speedvhRepresenting the current speed of the vehicle, t representing the length of time the vehicle is predicted to move, lengthvhIndicating the length, width, of the carriervhRepresenting the width of the carrier and w representing the added value of the width. The width additional value is an empirical parameter which can be set according to the actual situation, and the parameter is used for predicting the lateral collision of the vehicle.
In some embodiments, in order to be able to more accurately know the prediction result through the directional bounding box, step 5.2) specifically includes the following steps:
step 5.2.1), detecting whether the virtual vehicle collides or not by judging the overlapping condition of the projections of the directional bounding boxes of the virtual vehicle on all coordinate axes;
step 5.2.2), if the projections of the directional bounding boxes of at least two virtual vehicles on all coordinate axes are overlapped, judging that the virtual vehicles collide;
step 5.2.3), if the projections of the directional bounding boxes of at least two virtual vehicles on all coordinate axes are not overlapped, judging that the virtual vehicles do not collide.
Here, when the projections of the bounding box OBB in both directions on the x and y axes overlap, it is determined that a collision is imminent; otherwise, it is determined that no collision occurs.
Specifically, the collision detection method in the embodiment of the present invention respectively calculates whether projections of the directional bounding boxes of the two virtual vehicles on the positive and negative half axes on the x and y coordinate axes overlap, and determines that a collision is about to occur if projections on the 4 coordinate half axes overlap. Otherwise, no collision is considered to occur. As shown in fig. 6, for example, the side length of the directional bounding box of the vehicle C is L1, the side length of the directional bounding box of the vehicle D is L2, the projection of the vehicle C on the positive and negative half axes of the x axis is projection 1, the projection of the vehicle D on the positive and negative half axes of the x axis is projection 2, and projection 1 and projection 2 are overlapped on the positive and negative half axes of the x axis. Similarly, the projections of the carrier C and the carrier D on the positive and negative half axes of the y axis have the same overlapping condition, and are not described again here. Therefore, it is known that the vehicle C and the vehicle D collide with each other.
When a plurality of virtual vehicles appear in a game scene, not all the virtual vehicles may collide, and if collision detection is performed on all the virtual vehicles, server resources are occupied, and meanwhile, detection time is increased. Therefore, in order to improve the above problem, the embodiment of the present invention specifically includes the following steps before step 5.2):
step 6.1), respectively carrying out height detection and range detection according to the vertical distance and the horizontal distance between the center point of the virtual vehicle and the center point of the virtual vehicle to be collided;
step 6.2), when the vertical distance is smaller than a preset height distance threshold value and the horizontal distance is smaller than the sum of the lengths of the virtual vehicle and the virtual vehicle to be collided, executing the step 5.2).
Here, in practical applications, the server represents a three-dimensional object by using a two-dimensional directional bounding box OBBA physical carrier. In order to optimize the detection algorithm, in the embodiment of the invention, carriers with longer distances are screened before projection overlap detection is performed, and the screened carriers do not need to be subjected to overlap detection, so that the number of carriers repeatedly subjected to projection overlap detection is reduced. Specifically, it is necessary to perform a height detection and a range detection, that is, to detect the vertical distance vertical _ dist and the horizontal distance hori _ dist of the center points of the two carriers. And the formula vertical _ dist is less than the threshold value, and is used for screening the carriers with overlarge vertical height distance difference. Here, by the formula dist < L1+L2The method is used for screening partial carriers with longer distances. Wherein L is1Length, L, of directional bounding box OBB1 of carrier 12Indicating the length of the directional bounding box OBB2 of carrier 2.
For example, the vertical distance vertical _ dist between the center points of the two vehicles to be collided is calculated, if vertical _ dist>A threshold value, namely determining that the two vehicles to be collided do not collide; if the vertical _ dist is less than the threshold value, calculating the horizontal distance hori _ dist of the center points of the two vehicles to be collided; if hori _ dist>L1+L2Then, the two vehicles to be collided are considered not to be collided; if hori _ dist < L1+L2Then step 2.1) is entered, and the two vehicles to be collided are detected.
It is understood that the threshold value is an empirical value, and can be adjusted differently according to different application scenarios. As an alternative example, for a tank game application scenario, the height of a tank will not exceed 5m, and therefore the threshold here may be chosen to be 5 m.
Fig. 7 is a schematic view illustrating an interaction flow between a server and a game client in a method for synchronizing states of virtual vehicles in a game, where the method shown in fig. 7 includes:
step S701, in the period that the control right of the virtual carrier belongs to the client, the game client simulates and obtains the current state of a first simulation carrier based on the first simulation carrier of the virtual carrier according to a first operation instruction aiming at the virtual carrier;
step S702, determining first state information of a virtual vehicle based on the current state of the first simulated vehicle, wherein the first state information of the virtual vehicle smoothly approaches the current state of the first simulated vehicle;
step S703, the game client synchronizes first state information of the virtual carrier determined by the client to the server;
step S704, the server synchronizes the first state information of the virtual carrier in the control period of the client to the rest game clients;
step S705, the server performs collision prediction on the virtual vehicle based on the first state information of the virtual vehicle;
step S706, when the virtual vehicle is predicted to collide, the server sends a first control right switching instruction to the game client;
step S707, the server determines the current state of the second simulated vehicle in the period that the control right belongs to the server;
step S708, the game client responds to the first control right switching instruction, and synchronizes the current state of the second simulation carrier determined by the server in the period that the control right belongs to the server;
in step S709, the game client determines second state information of the virtual vehicle based on the current state of the second simulated vehicle, and the second state information of the virtual vehicle smoothly approaches the current state of the second simulated vehicle.
In step S710, the server synchronizes the second state information of the virtual vehicle to the remaining game clients in the current game scene.
In the practical preferred embodiment, the vehicle collision simulation synchronization is divided into two modes, client simulation and server simulation. And when the virtual vehicle has no collision condition, the server informs the client end of controlling the vehicle simulation. When the fact that the carrier is about to collide is predicted, the server informs the client to abandon carrier simulation, and the server takes over the carrier simulation control right, so that the synchronous consistency of the physical carrier postures is achieved, time delay is reduced, and the performance consumption of the server is saved.
As an optional embodiment, in order to reduce the size of a data packet during transmission between the server and the client, the first state information, the second state information, and the current state of the second simulated vehicle of the virtual vehicle that needs to be transmitted are sampled, and the sampled data are transmitted again. And the received server or client performs smoothing processing on the sampled data to present the first state information, the second state information and the current state of the second simulation carrier of the virtual carrier before sampling.
Fig. 8 is a schematic structural diagram of a state synchronization device of a virtual vehicle in a game according to an embodiment of the present disclosure. As shown in fig. 8, the apparatus is applied to a game client, and includes:
a first state determination module 801, configured to synchronize, to a server, first state information of the virtual vehicle during a period in which the virtual vehicle is controlled by a client, where the first state information is used for performing collision prediction calculation on the virtual vehicle by the server;
a first synchronization module 802, configured to switch the virtual vehicle to be controlled by the server in response to a first switching instruction sent by the server when the virtual vehicle is predicted to collide, and receive second state information of the virtual vehicle sent by the server during a period controlled by the server.
In some embodiments, the first state determination module 801 is specifically configured to:
determining first state information of the virtual vehicle according to a first operation instruction aiming at the virtual vehicle in a period that the virtual vehicle is controlled by a client.
In some embodiments, the first state determination module 801 is specifically configured to:
according to a first operation instruction aiming at the virtual carrier, simulating to obtain the current state of a first simulation carrier based on the first simulation carrier created by the virtual carrier; determining first state information of the virtual vehicle based on the current state of the first simulated vehicle, wherein the first state information of the virtual vehicle smoothly approaches the current state of the first simulated vehicle.
In some embodiments, the first synchronization module 802 is specifically configured to:
synchronizing the first operation instruction to the server during a period in which the virtual vehicle is controlled by the server, so that the server determines second state information of the virtual vehicle based on the first operation instruction.
In some embodiments, the first synchronization module 802 is specifically configured to:
determining a second operation instruction for the virtual vehicle in a period that the virtual vehicle is controlled by a server; synchronizing the second operating instruction to the server to cause the server to determine third state information of the virtual vehicle based on the second operating instruction.
In some embodiments, the second state information for the virtual vehicle is a current state of a second simulated vehicle of the virtual vehicle; the first synchronization module 802 is specifically configured to:
determining a current state of the virtual vehicle based on second state information of the second simulated vehicle, the current state of the virtual vehicle smoothly approaching the current state of the second simulated vehicle.
Fig. 9 is a schematic structural diagram of a state synchronization device of a virtual vehicle in a game according to an embodiment of the present application. As shown in fig. 9, the apparatus is applied to a game client, and includes:
a second synchronization module 901, configured to synchronize first state information of the virtual vehicle during a period in which the virtual vehicle is controlled by the client;
a prediction module 902 configured to perform collision prediction for the virtual vehicle based on first state information of the virtual vehicle;
a second state determining module 903, configured to send a first control right switching instruction to the client when the virtual vehicle is predicted to collide, switch the virtual vehicle to be controlled by the server, and synchronize, to the client, second state information of the virtual vehicle in a period controlled by the server.
In some embodiments, the prediction module 902 is specifically configured to:
establishing a direction bounding box of the virtual carrier based on the current state and physical parameters of the virtual carrier, wherein the current state comprises a carrier position, a carrier speed, a carrier forward direction vector, a carrier right direction vector and a carrier predicted movement duration, and the physical parameters comprise a carrier length, a carrier width and a carrier width additional value; collision detection is performed by the directional bounding box of the virtual vehicle.
In some embodiments, the prediction module 902 is specifically configured to:
detecting whether the virtual vehicle collides or not by judging the overlapping condition of the projections of the directional bounding boxes of the virtual vehicle on all coordinate axes; if the projections of the direction bounding boxes of at least two virtual vehicles on all coordinate axes are overlapped, the virtual vehicles collide; if the projections of the directional bounding boxes of at least two virtual vehicles on all coordinate axes are not overlapped, the virtual vehicles do not collide.
In some embodiments, the prediction module 902 is specifically configured to:
respectively carrying out height detection and range detection according to the vertical distance and the horizontal distance between the center point of the virtual vehicle and the center point of the virtual vehicle to be collided; and when the vertical distance is smaller than a preset height distance threshold value and the horizontal distance is smaller than the sum of the lengths of the virtual vehicle and the virtual vehicle to be collided, executing a step of collision detection through a direction bounding box of the virtual vehicle.
In some embodiments, the second state determining module 903 is specifically configured to:
determining second state information of the virtual vehicle according to a first operation instruction aiming at the virtual vehicle in a period that the virtual vehicle is controlled by a server.
The state synchronization device for a virtual vehicle in a game provided by the embodiment of the present application has the same technical features as the state synchronization method for a virtual vehicle in a game provided by the above embodiment, so that the same technical problems can be solved, and the same technical effects can be achieved.
Corresponding to the method for synchronizing the state of the virtual vehicle in the game, an embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the method for synchronizing the state of the virtual vehicle in the game is performed.
The state synchronization device of the virtual vehicle in the game provided by the embodiment of the application can be specific hardware on the device, or software or firmware installed on the device, and the like. The device provided by the embodiment of the present application has the same implementation principle and technical effect as the foregoing method embodiments, and for the sake of brief description, reference may be made to the corresponding contents in the foregoing method embodiments where no part of the device embodiments is mentioned. It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the foregoing systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the mobile control method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus once an item is defined in one figure, it need not be further defined and explained in subsequent figures, and moreover, the terms "first", "second", "third", etc. are used merely to distinguish one description from another and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present application, and are used for illustrating the technical solutions of the present application, but not limiting the same, and the scope of the present application is not limited thereto, and although the present application is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope disclosed in the present application; such modifications, changes or substitutions do not depart from the scope of the embodiments of the present application. Are intended to be covered by the scope of the present application.

Claims (17)

1. A method for synchronizing the state of a virtual vehicle in a game is applied to a game client, and comprises the following steps:
synchronizing first state information of the virtual vehicle to a server in a period that the virtual vehicle is controlled by a client, wherein the first state information is used for collision prediction calculation of the virtual vehicle by the server;
in response to a first switching instruction sent by the server when the virtual vehicle is predicted to collide, switching the virtual vehicle to be controlled by the server, and receiving second state information of the virtual vehicle sent by the server in a period controlled by the server.
2. The method of claim 1, further comprising, prior to the step of synchronizing the first state information of the virtual vehicle to a server:
determining first state information of the virtual vehicle according to a first operation instruction aiming at the virtual vehicle in a period that the virtual vehicle is controlled by a client.
3. The method of claim 2, wherein determining the first status information of the virtual vehicle according to the first operation command for the virtual vehicle comprises:
according to a first operation instruction aiming at the virtual carrier, simulating to obtain the current state of a first simulation carrier based on the first simulation carrier created by the virtual carrier;
determining first state information of the virtual vehicle based on the current state of the first simulated vehicle, wherein the first state information of the virtual vehicle smoothly approaches the current state of the first simulated vehicle.
4. The method of claim 2, wherein prior to the step of receiving second status information of the virtual vehicle sent by the server during the period controlled by the server, the method further comprises:
synchronizing the first operation instruction to the server during a period in which the virtual vehicle is controlled by the server, so that the server determines second state information of the virtual vehicle based on the first operation instruction.
5. The method of claim 1, wherein prior to the step of receiving second status information of the virtual vehicle sent by the server during the period controlled by the server, the method further comprises:
determining a second operation instruction for the virtual vehicle in a period that the virtual vehicle is controlled by a server;
synchronizing the second operating instruction to the server to cause the server to determine third state information of the virtual vehicle based on the second operating instruction.
6. The method of claim 1, wherein the second state information for the virtual vehicle is a current state of a second simulated vehicle of the virtual vehicle; after the step of receiving second state information of the virtual vehicle sent by the server within a period controlled by the server, the method comprises the following steps:
determining a current state of the virtual vehicle based on second state information of the second simulated vehicle, the current state of the virtual vehicle smoothly approaching the current state of the second simulated vehicle.
7. A method for synchronizing the state of a virtual carrier in a game is applied to a server, and comprises the following steps:
synchronizing first state information of the virtual vehicle during a period in which the virtual vehicle is controlled by a client;
performing collision prediction for the virtual vehicle based on first state information of the virtual vehicle;
when the virtual vehicle is predicted to collide, a first control right switching instruction is sent to the client, the virtual vehicle is switched to be controlled by the server, and second state information of the virtual vehicle in a period controlled by the server is synchronized to the client.
8. The method of claim 7, wherein the step of performing collision prediction for the virtual vehicle based on the first state information of the virtual vehicle comprises:
establishing a direction bounding box of the virtual vehicle based on the current state and physical parameters of the virtual vehicle;
collision detection is performed by the directional bounding box of the virtual vehicle.
9. The method of claim 8, wherein the current state comprises vehicle position, vehicle speed, vehicle forward direction vector, vehicle right direction vector, and vehicle estimated movement duration, and the physical parameters comprise vehicle length, vehicle width, and vehicle width additional value.
10. The method of claim 8, wherein the performing collision detection by the virtual vehicle comprises:
if the projections of the direction bounding boxes of at least two virtual vehicles on all coordinate axes are overlapped, judging that the virtual vehicles collide;
and if the projections of the directional bounding boxes of at least two virtual vehicles on all coordinate axes are not overlapped, judging that the virtual vehicles cannot collide.
11. The method of claim 8, further comprising, prior to the step of collision detection by the directional bounding box of the virtual vehicle:
respectively carrying out height detection and range detection according to the vertical distance and the horizontal distance between the center point of the virtual vehicle and the center point of the virtual vehicle to be collided;
and when the vertical distance is smaller than a preset height distance threshold value and the horizontal distance is smaller than the sum of the lengths of the virtual vehicle and the virtual vehicle to be collided, executing a step of collision detection through a direction bounding box of the virtual vehicle.
12. The method of claim 7, wherein the step of synchronizing to the client second state information of the virtual vehicle during the server-controlled period is preceded by the step of:
determining second state information of the virtual vehicle according to a first operation instruction aiming at the virtual vehicle in a period that the virtual vehicle is controlled by a server.
13. A state synchronization device of a virtual vehicle in a game is applied to a game client, and the device comprises:
a first state determination module, configured to synchronize, to a server, first state information of the virtual vehicle during a period in which the virtual vehicle is controlled by a client, where the first state information is used for performing collision prediction calculation on the virtual vehicle by the server;
the first synchronization module is used for responding to a first switching instruction sent by the server when the virtual vehicle is predicted to collide, switching the virtual vehicle to be controlled by the server, and receiving second state information of the virtual vehicle in a period controlled by the server, wherein the second state information is sent by the server.
14. A state synchronization device of a virtual vehicle in a game is applied to a server, and the device comprises:
a second synchronization module, configured to synchronize first state information of the virtual vehicle during a period in which the virtual vehicle is controlled by a client;
a prediction module to perform collision prediction for the virtual vehicle based on first state information of the virtual vehicle;
and the second state determination module is used for sending a first control right switching instruction to the client when the virtual vehicle is predicted to collide, switching the virtual vehicle to be controlled by the server, and synchronizing second state information of the virtual vehicle in a period controlled by the server to the client.
15. A terminal comprising a memory, a processor, and a computer program stored in the memory and operable on the processor, wherein the processor, when executing the computer program, performs the steps of the method according to any of the preceding claims 1 to 6.
16. A server comprising a memory, a processor, and a computer program stored in the memory and operable on the processor, wherein the processor implements the steps of the method of any of claims 7 to 12 when executing the computer program.
17. A machine-readable storage medium having stored thereon machine-executable instructions which, when invoked and executed by a processor, cause the processor to carry out the steps of the method of any one of claims 1 to 12.
CN202010044944.4A 2020-01-15 2020-01-15 Method and device for synchronizing states of virtual vehicles in game Pending CN111298429A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010044944.4A CN111298429A (en) 2020-01-15 2020-01-15 Method and device for synchronizing states of virtual vehicles in game

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010044944.4A CN111298429A (en) 2020-01-15 2020-01-15 Method and device for synchronizing states of virtual vehicles in game

Publications (1)

Publication Number Publication Date
CN111298429A true CN111298429A (en) 2020-06-19

Family

ID=71150862

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010044944.4A Pending CN111298429A (en) 2020-01-15 2020-01-15 Method and device for synchronizing states of virtual vehicles in game

Country Status (1)

Country Link
CN (1) CN111298429A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112642147A (en) * 2020-12-24 2021-04-13 网易(杭州)网络有限公司 Game control method, device, equipment and storage medium
CN112950535A (en) * 2021-01-22 2021-06-11 北京达佳互联信息技术有限公司 Video processing method and device, electronic equipment and storage medium
CN114374540A (en) * 2021-12-15 2022-04-19 广州趣丸网络科技有限公司 Network interaction control method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107273008A (en) * 2017-05-23 2017-10-20 武汉秀宝软件有限公司 Collision processing method, client, server and system in a kind of virtual environment
CN109529355A (en) * 2018-12-24 2019-03-29 网易(杭州)网络有限公司 Information synchronization method, device, processor and the server of virtual reality scenario
CN110585695A (en) * 2019-09-12 2019-12-20 腾讯科技(深圳)有限公司 Method, apparatus, device and medium for using near-war property in virtual environment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107273008A (en) * 2017-05-23 2017-10-20 武汉秀宝软件有限公司 Collision processing method, client, server and system in a kind of virtual environment
CN109529355A (en) * 2018-12-24 2019-03-29 网易(杭州)网络有限公司 Information synchronization method, device, processor and the server of virtual reality scenario
CN110585695A (en) * 2019-09-12 2019-12-20 腾讯科技(深圳)有限公司 Method, apparatus, device and medium for using near-war property in virtual environment

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112642147A (en) * 2020-12-24 2021-04-13 网易(杭州)网络有限公司 Game control method, device, equipment and storage medium
CN112950535A (en) * 2021-01-22 2021-06-11 北京达佳互联信息技术有限公司 Video processing method and device, electronic equipment and storage medium
CN112950535B (en) * 2021-01-22 2024-03-22 北京达佳互联信息技术有限公司 Video processing method, device, electronic equipment and storage medium
CN114374540A (en) * 2021-12-15 2022-04-19 广州趣丸网络科技有限公司 Network interaction control method and device
CN114374540B (en) * 2021-12-15 2024-02-02 广州趣丸网络科技有限公司 Control method and device for network interaction

Similar Documents

Publication Publication Date Title
CN111298429A (en) Method and device for synchronizing states of virtual vehicles in game
CN107958480B (en) Image rendering method and device and storage medium
US10976982B2 (en) Guided view mode for virtual reality
CN111383309B (en) Skeleton animation driving method, device and storage medium
US9626800B2 (en) Apparatus and method for augmented reality
US10338879B2 (en) Synchronization object determining method, apparatus, and system
JP2009236934A (en) Display device, apparatus including the same, program, and display method
EP3726843B1 (en) Animation implementation method, terminal and storage medium
EP3783471A1 (en) Display control method and terminal
CN105808071A (en) Display control method and device and electronic equipment
CN112206515B (en) Game object state switching method, device, equipment and storage medium
CN112891943A (en) Lens processing method and device and readable storage medium
CN115509406B (en) Coal mine multi-scene fusion method and device, storage medium and electronic equipment
JP2004086508A (en) Display control method for moving image based on three-dimensional shape data and navigation device
CN108170295A (en) Virtual camera condition control method, device, electronic equipment and storage medium
CN103520921A (en) Cursor control method and system and control device
WO2021117660A1 (en) Server, processing system, processing method, and program
KR102314782B1 (en) apparatus and method of displaying three dimensional augmented reality
CN112206519A (en) Method, device, storage medium and computer equipment for realizing game scene environment change
CN110955377A (en) Control method of virtual object and related device
CN109985383A (en) A kind of method, apparatus of information processing, storage medium and electronic device
CN114115673B (en) Control method of vehicle-mounted screen
CN103076874A (en) Method and system for improving high delay of computer-vision-based somatosensory input equipment
CN112631447A (en) Mouse synchronous processing method and device, electronic equipment and storage medium
CN104766363B (en) The WARPING method of the multi-direction reference view of drawing based on depth map

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination