Virtual object motion method, device, equipment, storage medium and program product
By segmenting and iteratively detecting the offset between the start and end time of the virtual object's motion, the problem of low effectiveness of displacement update when the virtual object moves in the virtual scene is solved, and a more efficient motion effect is achieved.
Patent Information
- Application Number
- CN202111235036.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-22
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-10-22
AI Technical Summary
When virtual objects move in the virtual scene, the span of the displacement update is large, resulting in low effectiveness of the updated position of sweep detection. Virtual objects often cross insurmountable virtual obstacles, affecting the movement effect.
By obtaining the offset between the motion start time and end time, it is segmented, iteratively determines the sub-positions, and performs sweep detection on each sub-position to form a fine-grained motion trajectory to control the motion of the virtual object.
It improves the effectiveness of each sub-position of the virtual object's motion trajectory, reduces the impact of terrain on the updated position, and improves the motion effect of the virtual object.
Smart Images

Figure CN113926197B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to rendering technology in the field of computer applications, and in particular to a method, device, equipment, storage medium and program product for moving a virtual object. Background Art
[0002] The art displacement file refers to the data source for the displacement update of virtual objects in the virtual scene; in the virtual scene, the movement of the virtual object is usually rendered by dynamically obtaining the moving destination and moving scaling distance in combination with the art displacement file. However, when the virtual object moves in combination with the art displacement file, the span of a displacement update is large, and the effectiveness of the updated position determined by sweep detection is low; for example, in the process of the virtual object moving to the updated position, there is often a situation where the virtual object crosses an insurmountable virtual obstacle, resulting in poor movement effect of the virtual object. Summary of the invention
[0003] The embodiments of the present application provide a method, apparatus, device, computer-readable storage medium, and computer program product for moving a virtual object, which can improve the movement effect of the virtual object.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] The present application provides a method for moving a virtual object, including:
[0006] Get the movement start position and movement end time corresponding to the movement start time;
[0007] The offset between the movement start time and the movement end time is divided into M sub-offsets, where M is a positive integer greater than 1;
[0008] Determine a first initial position based on the movement start position and the first sub-offset, and perform a sweep detection on the first initial position to obtain a first sub-position;
[0009] The following processing is performed by iteration i, where 2≤i≤M and i is a monotonically increasing integer variable:
[0010] Determine the i-th initial position based on the i-1-th sub-position and the i-th sub-offset, and perform a sweep detection on the i-th initial position to determine the i-th sub-position;
[0011] The motion trajectory of the virtual object is determined based on the M sub-positions obtained in iteration i, and the virtual object is controlled to move between the motion start time and the motion end time based on the motion trajectory.
[0012] The embodiment of the present application provides a motion device for a virtual object, comprising:
[0013] An information acquisition module, used to acquire a movement start position and a movement end time corresponding to a movement start time;
[0014] A displacement segmentation module, used for segmenting the offset between the movement start time and the movement end time to obtain M sub-offsets, where M is a positive integer greater than 1;
[0015] A sweep detection module, used for determining a first initial position based on the movement starting position and the first sub-offset, and performing a sweep detection on the first initial position to obtain a first sub-position;
[0016] a detection iteration module, configured to perform the following processing by iteration i, wherein 2≤i≤M, and i is a monotonically increasing integer variable: determining the i-th initial position based on the i-1-th sub-position and the i-th sub-offset, and performing a sweep detection on the i-th initial position to determine the i-th sub-position;
[0017] The object motion module is used to determine the motion trajectory of the virtual object based on the M sub-positions obtained in iteration i, and control the virtual object to move between the motion start time and the motion end time based on the motion trajectory.
[0018] In an embodiment of the present application, the information acquisition module is also used to obtain the last displacement update time and the target time; based on the specified frame, the time period between the last displacement update time and the target time is divided to obtain N start times and N end times corresponding to N sub-time periods, wherein N is a positive integer greater than 1; the j-th start time is determined as the start time of the movement, wherein 1≤j≤N, and j is a monotonically increasing integer variable; the j-th end time is determined as the end time of the movement; and the position corresponding to the j-th start time is determined as the start position of the movement.
[0019] In an embodiment of the present application, the sweep detection includes at least one of edge detection and collision detection, wherein the edge detection is used to determine whether the position of the virtual object on the virtual motion surface is the position at the edge of the virtual motion surface, and the collision detection is used to determine whether a virtual obstacle is included in the process of updating the position.
[0020] In an embodiment of the present application, when the sweep detection includes the edge detection, the sweep detection module is further used to perform ground detection on the i-th initial position based on the i-1th sub-position to obtain the i-th initial ground position; within the restricted height, when the detection ray of the i-th initial ground position intersects with the virtual motion surface, the i-th initial ground position is determined as the i-th sub-position; within the restricted height, when the detection ray of the i-th initial ground position does not intersect with the virtual motion surface, the i-th initial ground position is pulled back based on the i-1th sub-position to obtain the i-th sub-position.
[0021] In an embodiment of the present application, the sweep detection module is also used to determine the i-th edge detection starting point corresponding to the i-th initial ground position; obtain the edge line between the i-th edge detection starting point and the i-1-th sub-position on the plane corresponding to the height of the i-th edge detection starting point, and obtain the intersection position between the edge line and the virtual moving body to obtain the edge point position; combine the starting height of the ground detection and the edge point position to obtain a new starting point for the ground detection; pull back the i-th initial ground position based on the new starting point for the ground detection and the specified height to determine the i-th sub-position.
[0022] In an embodiment of the present application, the sweep detection module is further used to pull back the i-th initial ground position based on the i-1-th sub-position to obtain the i-th sub-position including the i-1-th sub-position.
[0023] In an embodiment of the present application, the sweep detection module is also used to obtain the i-th movement direction; when i is less than M, when the direction difference between the i+1-th movement direction and the i-th movement direction is less than a specified direction, the i-th sub-position is determined as the i+1-th sub-position.
[0024] In an embodiment of the present application, when the sweep detection includes the collision detection, the sweep detection module is further used to perform collision detection based on the i-1th sub-position and the i-th initial position to obtain a collision detection result; when the collision detection result is that the virtual obstacle is not included between the i-1th sub-position and the i-th initial position, the i-th initial position is determined to be the i-th sub-position; when the collision detection result is that the virtual obstacle is included between the i-1th sub-position and the i-th initial position, the i-th initial position is pulled back based on the i-1th sub-position to obtain the i-th sub-position.
[0025] In an embodiment of the present application, the sweep detection module is also used to, when the displacement segmentation step is less than the specified step, perform a pullback process on the i-th initial position based on the i-1th sub-position to obtain the i-th sub-position including the i-1th sub-position; when the displacement segmentation step is greater than or equal to the specified step, determine the pullback position corresponding to the virtual obstacle based on the i-1th sub-position, and determine the pullback position as the i-th sub-position.
[0026] In an embodiment of the present application, the information acquisition module is also used to determine the last displacement update time as the movement start time; determine the position corresponding to the last displacement update time as the movement start position; and determine the target time as the movement end time.
[0027] In an embodiment of the present application, the displacement segmentation module is also used to determine the displacement segmentation step based on the size of the virtual object; based on the displacement segmentation step, the offset between the movement start time and the movement end time is segmented to obtain M sub-offsets.
[0028] The present application provides a motion device for a virtual object, including:
[0029] A memory for storing executable instructions;
[0030] The processor is used to implement the virtual object movement method provided in the embodiment of the present application when executing the executable instructions stored in the memory.
[0031] An embodiment of the present application provides a computer-readable storage medium storing executable instructions, wherein the executable instructions are used to implement the virtual object movement method provided in the embodiment of the present application when executed by a processor.
[0032] An embodiment of the present application provides a computer program product, including a computer program or instructions. When the computer program or instructions are executed by a processor, the method for moving a virtual object provided in the embodiment of the present application is implemented.
[0033] The embodiments of the present application have at least the following beneficial effects: when controlling a virtual object to move between a movement start time and a movement end time, each sub-position in the obtained motion trajectory is obtained by dividing the offset of the updated displacement and performing a sweep detection on the initial position determined by each divided sub-offset; in this way, fine-grained sweep detection is achieved, and the influence of the terrain on the effectiveness of the updated position is reduced through displacement division, so that the effectiveness of each sub-position is higher; thereby, the motion effect of the virtual object can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1is a schematic diagram of an exemplary virtual object update displacement provided in an embodiment of the present application;
[0035] Figure 2 is a schematic diagram of the architecture of a motion system for a virtual object provided in an embodiment of the present application;
[0036] Figure 3 The embodiment of this application provides Figure 2 A schematic diagram of the composition structure of the server in FIG.
[0037] Figure 4 The following is a flow chart of the method for moving a virtual object provided in the embodiment of the present application. Figure 1 ;
[0038] Figure 5 It is a flowchart of the time-slicing method provided in the embodiment of the present application;
[0039] Figure 6 The following is a flow chart of the method for moving a virtual object provided in the embodiment of the present application. Figure 2 ;
[0040] Figure 7 The following is a flow chart of the method for moving a virtual object provided in the embodiment of the present application. Figure 3 ;
[0041] Figure 8 is a flowchart of an exemplary method for moving a virtual object provided in an embodiment of the present application;
[0042] Fig. 9 is a schematic diagram of an exemplary process of determining the current state of an art displacement provided in an embodiment of the present application;
[0043] Fig.10 is a schematic diagram of an exemplary ground-based calculation provided in an embodiment of the present application;
[0044] Fig.11 is a schematic diagram of an exemplary ground detection provided in an embodiment of the present application;
[0045] Fig.12 It is a schematic diagram of an exemplary collision detection provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0047] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0048] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meaning as those commonly understood by those skilled in the art of the present application. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0049] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0050] 1) Virtual scene: A scene that is different from the real world and that is output by a device. Visual perception of the virtual scene can be formed with the naked eye or with the assistance of a device; for example, two-dimensional images output by a display screen, three-dimensional images output by stereoscopic display technologies such as stereo projection, virtual reality, and augmented reality technologies; in addition, various perceptions that simulate the real world, such as auditory perception, tactile perception, olfactory perception, and motion perception, can also be formed through various possible hardware.
[0051] It should also be noted that the virtual scene displayed (or provided) when the application is running on the terminal device can be a simulation environment of the real world, a semi-simulated and semi-fictitious virtual environment, or a purely fictitious virtual environment. The virtual scene can be any one of a two-dimensional virtual scene, a 2.5-dimensional virtual scene, or a three-dimensional virtual scene. The embodiment of the present application does not limit the dimension of the virtual scene. For example, the virtual scene may include the sky, land, ocean, etc., and the land may include environmental elements such as deserts, cities, and buildings. Virtual objects can move or perform other operations (such as attack operations) in the virtual scene under the control of a user or AI.
[0052] 2) Client: An application running in an electronic device to provide various services; for example, a game client and a video playback client.
[0053] 3) Virtual objects: images of various people and objects that can interact in a virtual scene, or movable objects in a virtual scene. The movable objects can be virtual characters, virtual animals, cartoon characters, etc., such as people, animals, plants, oil drums, walls, stones, and buildings displayed in a virtual scene. The virtual object can be a virtual image in the virtual scene that represents the user. A virtual scene can include multiple virtual objects, each of which has its own shape and volume in the virtual scene and occupies a part of the space in the virtual scene. In the embodiments of the present application, the virtual objects involved are virtual objects that can move.
[0054] 4) Art displacement file: It is the data source for determining the movement of virtual objects based on the changes in the position and orientation of the root bone. The art displacement file includes multiple frames of data on the movement of virtual objects, where each frame of data includes information such as the position offset of the root bone of the virtual object relative to the coordinate origin, as well as information on whether collision detection and ground contact detection are performed during the displacement process, and the maximum climbing angle, etc.
[0055] Generally speaking, when a virtual object in a virtual scene is running, each displacement update process usually determines the corresponding offset based on the last update time and the current time, and determines the new position based on the determined offset, and then performs ground processing on the new position to obtain the updated position. However, the updated position obtained is too prominent relative to the virtual motion surface, that is, it exceeds the edge of the virtual motion surface; therefore, in the process of rendering the motion of the virtual object, it is often impossible to stop in time at the edge of the virtual motion surface, resulting in low accuracy and effectiveness of the determined new position.
[0056] For example, see Figure 1 , Figure 1 is a schematic diagram of an exemplary virtual object update displacement provided in an embodiment of the present application; Figure 1 As shown, the virtual object 1-1 moves on the virtual motion surface; when the virtual object 1-1 starts to update its displacement from position 1-2, the new position determined may be position 1-3. At this time, after the virtual object 1-1 completes the displacement update, it will be stuck at position 1-3. When the virtual object 1-1 starts to update its displacement from position 1-2, the new position determined may be position 1-4. At this time, when the virtual object 1-1 completes the update, it is in a floating state at position 1-4, causing the virtual object 1-1 to fall. Therefore, in the process of updating the displacement of the virtual object, the accuracy and effectiveness of the new position determined are low, resulting in poor motion effect of the rendered virtual object.
[0057] Based on this, the embodiments of the present application provide a method, device, equipment, computer-readable storage medium and computer program product for the movement of a virtual object, which can enhance the movement effect of the rendered virtual object. The following describes an exemplary application of a motion device for a virtual object (hereinafter referred to as a motion device) provided in an embodiment of the present application. The motion device provided in an embodiment of the present application can be implemented as various types of terminals such as smart phones, smart watches, laptops, tablet computers, desktop computers, smart TVs, set-top boxes, smart car devices, portable music players, personal digital assistants, dedicated messaging devices, portable gaming devices and smart speakers, and can also be implemented as a server. Below, an exemplary application when the device is implemented as a server will be described.
[0058] See also Figure 2 , Figure 2 Schematic diagram of the architecture of the motion system of the virtual object provided in the embodiment of the present application; Figure 2 As shown, in order to support a motion application of a virtual object, in a motion system 100 of a virtual object, a terminal 400 (exemplarily showing a terminal 400-1 and a terminal 400-2) is connected to a server 200 (referred to as a motion device) via a network 300. The network 300 may be a wide area network or a local area network, or a combination of the two. In addition, the motion system 100 of the virtual object also includes a database 500 for providing data support to the server 200; and, Figure 1 What is shown in the figure is a situation where the database 500 is independent of the server 200. In addition, the database 500 can also be integrated in the server 200, which is not limited in the embodiment of the present application.
[0059] The terminal 400 is used to receive the motion track sent by the server 200 through the network 300, and control the virtual object to move between the motion start time and the motion end time based on the motion track.
[0060] The server 200 is used to obtain the movement start position and movement end time corresponding to the movement start time; divide the offset between the movement start time and the movement end time to obtain M sub-offsets, where M is a positive integer greater than 1; determine the first initial position based on the movement start position and the first sub-offset, and perform a sweep detection on the first initial position to obtain the first sub-position; perform the following processing through iteration i, where 2≤i≤M, and i is a monotonically increasing integer variable: determine the i-th initial position based on the i-1th sub-position and the i-th sub-offset, and perform a sweep detection on the i-th initial position to determine the i-th sub-position; determine the movement trajectory of the virtual object based on the M sub-positions obtained by iteration i, and send the movement trajectory to the terminal 400 through the network 300.
[0061] In some embodiments, the server 200 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal 400 may be a smart phone, a smart watch, a laptop, a tablet computer, a desktop computer, a smart TV, a set-top box, a smart car device, a portable music player, a personal digital assistant, a dedicated messaging device, a portable gaming device, and a smart speaker, but is not limited thereto. The terminal and the server may be directly or indirectly connected by wired or wireless communication, which is not limited in the embodiments of the present application.
[0062] See also Figure 3 , Figure 3 The embodiment of this application provides Figure 2 The composition structure diagram of the server in Figure 3 The server 200 shown includes: at least one processor 210, a memory 250 and at least one network interface 220. The various components in the server 200 are coupled together via a bus system 240. It is understood that the bus system 240 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 240 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 240 is not described in detail. Figure 3 Various buses are labeled as bus system 240 .
[0063] The processor 210 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0064] In some embodiments, the server 200 further includes a user interface 230; wherein the user interface 230 includes one or more output devices 231 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 230 also includes one or more input devices 232, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0065] The memory 250 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 250 may optionally include one or more storage devices that are physically remote from the processor 210.
[0066] The memory 250 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 250 described in the embodiments of the present application is intended to include any suitable type of memory.
[0067] In some embodiments, memory 250 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.
[0068] Operating system 251, including system programs for processing various basic system services and performing hardware-related tasks, such as framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0069] A network communication module 252, used to reach other computer devices via one or more (wired or wireless) network interfaces 220, exemplary network interfaces 220 include: Bluetooth, Wireless Fidelity (Wi-Fi), and Universal Serial Bus (USB), etc.;
[0070] a presentation module 253 for enabling presentation of information via one or more output devices 231 (e.g., display screen, speaker, etc.) associated with the user interface 230 (e.g., a user interface for operating peripherals and displaying content and information);
[0071] The input processing module 254 is used to detect one or more user inputs or interactions from one of the one or more input devices 232 and translate the detected inputs or interactions.
[0072] In some embodiments of the present application, the motion device of the virtual object provided in the embodiments of the present application can be implemented in a software manner. Figure 3A motion device 255 of a virtual object stored in a memory 250 is shown, which may be software in the form of a program or a plug-in, and includes the following software modules: an information acquisition module 2551, a displacement segmentation module 2552, a sweep detection module 2553, a detection iteration module 2554, and an object motion module 2555. These modules are logical, and thus may be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.
[0073] In some embodiments, the motion device of the virtual object provided in the embodiments of the present application can be implemented in hardware. As an example, the motion device of the virtual object provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the motion method of the virtual object provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs) or other electronic components.
[0074] In some embodiments, the terminal or server can implement the motion method of the virtual object provided in the embodiment of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a native application (APP, Application), that is, a program that needs to be installed in the operating system to run, such as a game APP, a live broadcast APP or an instant messaging APP; it can also be a small program, that is, a program that can be run only by downloading it to a browser environment; it can also be a small program that can be embedded in any APP. In short, the above-mentioned computer program can be an application, module or plug-in in any form.
[0075] Below, the motion method of a virtual object provided in an embodiment of the present application will be described in combination with an exemplary application and implementation of a motion device provided in an embodiment of the present application; here, the executor of the motion method of a virtual object is a motion device.
[0076] See also Figure 4 , Figure 4 The following is a flow chart of the method for moving a virtual object provided in the embodiment of the present application. Figure 1 , will combine Figure 4 The steps shown are explained.
[0077] S401, obtaining a movement start position and a movement end time corresponding to a movement start time.
[0078] In an embodiment of the present application, when the motion device updates the motion displacement of a virtual object in a virtual scene, the start and end time of the current displacement update is obtained, and the motion start time and the motion end time are obtained; wherein the motion state of the virtual object corresponding to the motion start time includes the motion start position of the virtual object corresponding to the motion start time.
[0079] It should be noted that the movement start time and the movement end time can be the start and end time of a displacement update of a virtual object, or the start and end time obtained by dividing the start and end time of a displacement update of a virtual object, etc., which is not limited in the embodiments of the present application. A virtual object refers to an object that can be moved in a virtual scene, such as a virtual character, a virtual animal, and a virtual prop, etc. The movement start position is the position of the virtual object at the start time of the movement.
[0080] S402: Divide the offset between the movement start time and the movement end time to obtain M sub-offsets.
[0081] In an embodiment of the present application, the motion device obtains a corresponding offset from a preset animation file (e.g., an art file) based on the obtained motion start time and motion end time, and divides the offset between the obtained motion start time and motion end time to obtain multiple sub-offsets; wherein the obtained multiple sub-offsets are M sub-offsets, where M is a positive integer greater than 1, such as 2, 5, and so on.
[0082] It should be noted that when the motion device divides the offset, it can be evenly divided according to a preset step size, and the preset step size can be fixed or set based on relevant information (i.e., variable), and the relevant information can be the size of the virtual object or the flatness of the virtual motion surface, etc., which is not limited in the embodiments of the present application; wherein the virtual motion surface is an object in the virtual scene used to carry the movement of the virtual object, such as the ground, water surface, roof surface, wall top surface, etc. In addition, the preset animation file is the data source for the motion device to update the displacement of the virtual object, including the position offset information corresponding to each frame of data; and the motion start time and the motion end time correspond to the frame time in the preset animation file respectively, and here, the motion start time and the motion end time include at least one frame time.
[0083] S403: Determine a first initial position based on the movement start position and the first sub-offset, and perform a sweep detection on the first initial position to obtain a first sub-position.
[0084] In the embodiment of the present application, after the motion device obtains M sub-offsets, since the M sub-offsets are a sequence of sub-offsets based on the chronological order, different sub-offsets are used to determine different motion positions between the motion start time and the motion end time, namely, sub-positions; and the acquisition of the first sub-position is determined based on the calculation result of the motion start position and the first sub-offset. Here, the motion device first calculates the position based on the motion start position and the first sub-offset, and obtains the calculation result, namely, the first initial position; since the position corresponding to the first initial position on the virtual motion surface may not necessarily be able to carry the virtual object, that is, the first initial position may be a position that causes the virtual object to enter an abnormal state (for example, stuck, floating down, climbing over an insurmountable virtual obstacle, etc.); therefore, the motion device determines the validity of the first initial position through sweep detection and obtains a valid first sub-position.
[0085] It should be noted that sweep detection refers to the processing of detecting the validity of the position; wherein the validity of the position refers to the result that a position causes the virtual object to enter an abnormal state. When the validity is valid, the virtual object at the position will not enter an abnormal state; and when the validity is invalid, the virtual object at the position enters an abnormal state.
[0086] In an embodiment of the present application, the motion device executes S404 by iterating i to obtain other sub-positions after the first sub-position; wherein, 2≤i≤M, and i is a monotonically increasing integer variable, and the iteration step of i is 1, and i is the order of the offset.
[0087] S404: Determine the i-th initial position based on the i-1-th sub-position and the i-th sub-offset, and perform a sweep detection on the i-th initial position to determine the i-th sub-position.
[0088] In the embodiment of the present application, when 2≤i≤M, the acquisition of each sub-position (i.e., the i-th sub-position) is determined based on the calculation result of the previous sub-position (i.e., the i-1-th sub-position) and the offset corresponding to each sub-position (i.e., the i-th sub-offset). Here, the motion device first calculates the position based on the i-1-th sub-position and the i-th sub-offset, and obtains the calculation result, which is the i-th initial position; since the position corresponding to the i-th initial position on the virtual motion surface may not be able to support the virtual object, that is, the i-th initial position may be the position that causes the virtual object to enter an abnormal state; therefore, the motion device determines the validity of the i-th initial position through sweep detection and obtains a valid i-th sub-position.
[0089] It should be noted that S403 describes the process of the moving device obtaining the first sub-position, and S404 describes the process of the moving device obtaining the second sub-position to the Mth sub-position; the difference between S403 and S404 is that in S403, the acquisition of the first sub-position is determined and scanned and detected based on the starting position of the movement and the first sub-offset; in S404, each sub-position from the second sub-position to the Mth sub-position is determined and scanned and detected based on the previous sub-position and the i-th sub-offset.
[0090] S405 , determining a motion trajectory of the virtual object based on the M sub-positions obtained in iteration i, and controlling the virtual object to move between a motion start time and a motion end time based on the motion trajectory.
[0091] In the embodiment of the present application, the motion device obtains the first sub-position through S403, and obtains the second sub-position to the Mth sub-position through the iteration of S404; thus, when the iteration of i is completed, the motion device also obtains M sub-positions, namely the first sub-position to the Mth sub-position. Here, the M sub-positions obtained by the motion device are the motion trajectory corresponding to the time period between the start time and the end time of the motion of the virtual object, so that the motion of the virtual object between the start time and the end time of the motion can be rendered based on the motion trajectory.
[0092] It should be noted that when the sports device is implemented as a server (for example, Figure 2 When the server 200 in the example, sends the motion trajectory of the virtual object between the motion start time and the motion end time to the rendering device (for example, Figure 2 Terminal 400 in the rendering device) to render the movement of the virtual object between the movement start time and the movement end time based on the movement trajectory.
[0093] It can be understood that when controlling the virtual object to move between the start time and the end time of the movement, each sub-position in the obtained motion trajectory is obtained by dividing the offset of the updated displacement and performing a sweep detection on the initial position determined by each divided sub-offset. In this way, fine-grained sweep detection is achieved, and the influence of the terrain on the effectiveness of the updated position is reduced through displacement segmentation, so that the effectiveness of each sub-position is higher; thereby improving the motion effect of the rendered virtual object.
[0094] See also Figure 5 , Figure 5 is a flow chart of the time-slicing method provided in the embodiment of the present application; Figure 5 As shown, in the embodiment of the present application, Figure 4S401 in the figure can be implemented through S4011 to S4015; that is, the sports device obtains the sports starting position and sports ending time corresponding to the sports starting time, including S4011 to S4015, and each step is described below.
[0095] S4011. Obtain the last displacement update time and target time.
[0096] In an embodiment of the present application, when the motion device updates the displacement of a virtual object, the logical frame time corresponding to the last motion time and the deadline can be obtained from the displacement update request; wherein the last displacement update time is the previous logical frame time, and the target time is the current logical frame time; thus, the displacement update request obtained by the motion device is used to request the motion information of the virtual object between the last displacement update time and the target time.
[0097] Exemplarily, when the displacement update request is a request to obtain motion data of a virtual character rolling forward 2 meters within 2 seconds, the virtual character is a virtual object, and the duration between the last motion time and the deadline is 2 seconds; if the frame rate is 0.5 seconds / frame, when the last displacement update time is 0.5 seconds, the target time is 1 second.
[0098] S4012. Based on the designated frame, divide the time period between the last displacement update time and the target time to obtain N start times and N end times corresponding to the N sub-time periods.
[0099] In an embodiment of the present application, the motion device determines the time division unit of the time period between the last displacement update time and the target time based on the frame time interval in the preset animation file.
[0100] It should be noted that the designated frame is a time division unit determined based on the frame time interval in the preset animation file, such as 1 frame time interval, 2 frame time intervals, etc. Here, when the motion device uses the designated frame to divide the time period between the last displacement update time and the target time, N sub-time periods will be divided, and each of the N sub-time periods includes 1 start time and 1 end time, so that the N sub-time periods correspond to N start times and N end times; wherein N is a positive integer greater than 1.
[0101] Exemplarily, when the last displacement update time is 0.5 seconds and the target time is 1 second, the corresponding time period is 0.5 seconds; at this time, if the specified frame is 1 frame time interval, which is 0.03 seconds; 16 sub-time periods can be obtained, that is, N is 16.
[0102] S4013. Determine the jth start time as the movement start time.
[0103] S4014. Determine the jth end time as the exercise end time.
[0104] S4015. Determine the position corresponding to the j-th start time as the movement starting position.
[0105] It should be noted that the motion device updates the displacement of the virtual object for each sub-time period; thus, the motion device traverses N sub-time periods, and for each traversed sub-time period, referred to as the jth sub-time period, obtains the jth start time and the jth end time corresponding to the jth sub-time period, and determines the jth start time as the motion start time, the jth end time as the motion end time, and the position corresponding to the jth start time as the motion start position, so as to determine the motion trajectory corresponding to each sub-time period through the process described in S401 to S405; thus, the motion device can obtain N motion trajectories to render the motion of the virtual object between the last displacement update time and the target time based on the N motion trajectories. Wherein, 1≤j≤N, and j is a monotonically increasing integer variable, and the iteration step of j is 1, and j is the order of the sub-time periods.
[0106] It is understandable that since the time period between the last displacement update time and the target time obtained by the motion device is the frame time when rendering the movement of the virtual object, and different motion devices correspond to different rendering performances, and thus different motion devices have different frame rates when rendering, the time period between the last displacement update time and the target time obtained by the motion device is different; for example, at a low frame rate, the time period may be 0.5 seconds, and at a high frame rate, the time period may be 0.03 seconds; therefore, the movement position determined based on different time periods is also different, and in the case of a low frame rate, the entire art displacement may be completed in one displacement update. In this way, client A with poor performance sees a player C (that is, a virtual object) rolling over an obstacle, but client B with better performance sees that player C cannot climb over the obstacle, while in fact player C cannot climb over the obstacle, which ultimately results in the effect of player C being pulled rendered on client A, and the movement effect of the virtual object is poor. Here, by dividing the time period based on the specified frame, even if the obtained time periods are different, since the time division units are all specified frames, the displacement update process is consistent, thereby improving the consistency of the motion trajectories of N corresponding to different motion devices and improving the motion effect of the virtual object.
[0107] In the embodiment of the present application, S4011 may also include a process of directly determining the last displacement update time and the target time as the start and end times of the movement of the virtual object determined by the motion device; that is, after the motion device obtains the last displacement update time and the target time, the motion method of the virtual object also includes: the motion device determines the last displacement update time as the start time of the movement; determines the position corresponding to the last displacement update time as the start position of the movement; and determines the target time as the end time of the movement.
[0108] It should be noted that the motion device can time-segment the time period between the last displacement update time and the target time, and use the start and end time corresponding to a sub-time period as the start and end time for determining the motion trajectory of the virtual object; it can also directly use the last displacement update time and the target time as the start and end time for determining the motion trajectory of the virtual object; the embodiments of the present application are not limited to this.
[0109] In an embodiment of the present application, sweep detection includes at least one of edge detection and collision detection, wherein edge detection is used to determine whether the position of the virtual object on the virtual motion surface is the position at the edge of the virtual motion surface, and collision detection is used to determine whether a virtual obstacle is included in the updated position process.
[0110] It can be understood that the motion device can stop in time at the edge of the virtual motion surface by performing edge detection on the initial position; and can stop in time at the virtual obstacle by performing collision detection on the initial position; in this way, the movement of the virtual object is normal, and there will be no abnormal situation of crossing over uncrossable terrain; thereby, the accuracy of the movement of the virtual object can be improved.
[0111] In the embodiment of the present application, when the sweep detection includes edge detection, see Figure 6 , Figure 6 The following is a flow chart of the method for moving a virtual object provided in the embodiment of the present application. Figure 2 ;like Figure 6 As shown, Figure 4 S404 in the above step can be implemented through S4041 to S4043; that is, the motion device performs a sweep detection on the i-th initial position to determine the i-th sub-position, including S4041 to S4043, and each step is described below.
[0112] S4041. Perform ground detection on the i-th initial position based on the i-1th sub-position to obtain the i-th initial ground position.
[0113] In an embodiment of the present application, the sports device performs ground detection on the i-th initial position to obtain a position on a virtual sports surface corresponding to the i-th initial position; here, the position on the virtual sports surface corresponding to the i-th initial position is referred to as the i-th initial ground position.
[0114] S4042: Within the restricted height, when the detection ray of the ith initial ground position intersects with the virtual motion surface, the ith initial ground position is determined as the ith sub-position.
[0115] It should be noted that, since the i-th initial ground position may be at the edge of the virtual motion surface, the motion device continues to detect the i-th initial ground position to determine whether the i-th initial ground position is at the edge of the virtual motion surface. Here, since the preset animation file includes the maximum climbing angle, the motion device can determine the restricted height based on the maximum climbing angle; or, the preset animation file includes the restricted height. Next, the motion device determines whether the detection ray determined based on the i-th initial ground position intersects with the virtual motion surface within the restricted height; when the motion device determines that the detection ray of the i-th initial ground position within the restricted height intersects with the virtual motion surface, it indicates that the i-th initial ground position is not at the edge of the virtual motion surface, and thus, at this time, the i-th initial ground position is the i-th sub-position of the virtual object corresponding to the i-th sub-offset.
[0116] It should also be noted that the detection ray of the i-th initial ground position can be obtained by making a vertical ray from the center of the virtual object or other nodes such as the center to the virtual motion surface.
[0117] S4043. Within the restricted height, when the detection ray of the ith initial ground position does not intersect with the virtual motion surface, the ith initial ground position is pulled back based on the i-1th sub-position to obtain the ith sub-position.
[0118] It should be noted that, when the sports device determines that the detection ray of the ith initial ground position within the restricted height does not intersect the virtual moving surface, it indicates that the ith initial ground position is at the edge of the virtual moving surface, and the update of the sub-offset this time will cause the position of the virtual object to exceed the edge of the virtual moving surface; therefore, at this time, the sports device pulls the ith initial ground position back to the i-1th sub-position, and obtains the ith sub-position of the virtual object corresponding to the ith sub-offset.
[0119] It should be noted that S4032 and S4033 are two parallel processing steps. When S4032 is executed, S4033 is no longer executed, and when S4033 is executed, S4032 is no longer executed.
[0120] It can be understood that the sports device performs edge detection on the ith initial ground position, and when it is determined that the ith initial ground position is at the edge of the virtual moving surface, the ith initial ground position is pulled back to the i-1th sub-position to obtain a position on the virtual moving surface, so that the virtual object can stop in time at the edge of the virtual moving surface when moving, thereby improving the effect of the virtual object movement.
[0121] In an embodiment of the present application, in S4043, the sports device pulls back the i-th initial ground position based on the i-1-th sub-position to obtain the i-th sub-position, including S40431 to S40434 (not shown in the figure), and each step is described below.
[0122] S40431. Determine the i-th edge detection starting point corresponding to the i-th initial ground position.
[0123] In an embodiment of the present application, when the sports device determines that the i-th initial ground position is the position at the edge of the virtual motion surface, the center of the i-th initial ground position is offset to the lowest point in a direction perpendicular to the virtual motion surface, thereby obtaining the i-th edge detection starting point.
[0124] S40432. On the plane corresponding to the height of the i-th edge detection starting point, obtain the edge line between the i-th edge detection starting point and the i-1-th sub-position, and obtain the intersection position between the edge line and the virtual moving body to obtain the edge point position.
[0125] In an embodiment of the present application, the motion device takes the i-th edge detection starting point as the starting point, and makes a ray to the i-1-th sub-position in the plane direction parallel to the virtual motion surface, thereby obtaining an edge line between the i-th edge detection starting point and the i-1-th sub-position; wherein, the intersection position between the edge line and the virtual motion body is determined at the closest point to the i-th initial ground position, thereby obtaining the edge point position.
[0126] S40433. Combine the starting height and edge point position of the ground detection to obtain a new starting point for the ground detection.
[0127] It should be noted that the edge point position obtained by the motion device is not necessarily the valid position of the virtual object carried on the virtual motion body. Therefore, the motion device uses the height of the starting position of the ground detection in S4041 (that is, the starting height) as the height of the edge point position, and thus obtains a new starting point for the ground detection.
[0128] S40434. Pull back the i-th initial ground position based on the new ground detection starting point and the specified height to determine the i-th sub-position.
[0129] In an embodiment of the present application, the sports device determines a new end point of ground detection based on a new starting point of ground detection and a specified height, determines the contact position between the new starting point of ground detection and the new end point of ground detection and the virtual sports surface as the i-th sub-position, and realizes the pulling back processing of the i-th initial ground position to the i-1-th sub-position.
[0130] It can be understood that the motion device achieves minimized pullback processing on the ith initial ground position by acquiring the edge point position corresponding to the ith initial ground position, thereby improving the accuracy of obtaining the ith sub-position, and thus being able to improve the motion effect of the virtual object.
[0131] In an embodiment of the present application, in S4043, the sports device pulls back the i-th initial ground position based on the i-1-th sub-position to obtain the i-th sub-position, including S40435 (not shown in the figure). This step is described below.
[0132] S40435. Pull back the i-th initial ground position based on the i-1-th sub-position to obtain the i-th sub-position including the i-1-th sub-position.
[0133] It should be noted that the sports device can pull back the i-th initial ground position by determining the edge point position, and can also directly determine the i-1-th sub-position as the i-th sub-position to achieve the pullback of the i-th initial ground position. The embodiments of the present application are not limited to this.
[0134] In the embodiment of the present application, when the displacement segmentation step length is greater than or equal to the specified step length, the i-th initial ground position can be pulled back by determining the edge point position; and when the displacement segmentation step length is less than the specified step length, the i-1th sub-position can be directly determined as the i-th sub-position to achieve the pullback of the i-th initial ground position.
[0135] In an embodiment of the present application, in S4043, the motion device pulls back the i-th initial ground position based on the i-1th sub-position. After obtaining the i-th sub-position, the motion method of the virtual object also includes S4044 and S4045 (not shown in the figure).
[0136] S4044. Obtain the i-th movement direction.
[0137] It should be noted that the i-th movement direction obtained by the motion device refers to the movement direction corresponding to the i-th sub-position.
[0138] S4045: When i is less than M, and the direction difference between the i+1th movement direction and the i-th movement direction is less than the specified direction, determine the i-th sub-position as the i+1th sub-position.
[0139] It should be noted that when i is equal to M, it indicates that the i-th sub-offset is the last sub-offset, and at this time, the motion device no longer continues to determine the position of the subsequent movement of the virtual object; and when i is less than M, it indicates that the i-th sub-offset is not the last sub-offset. At this time, since the motion device has determined that it has reached the edge of the virtual motion surface when determining the i-th sub-position, if the direction difference between the i+1th motion direction and the i-th motion direction is less than the specified direction at this time, the motion device determines the i-th sub-position as the i+1th sub-position. Among them, the direction difference between the i+1th motion direction and the i-th motion direction is less than the specified direction, indicating that the direction of the subsequent movement of the virtual object has not changed; therefore, even if i is less than M, if the direction difference is greater than or equal to the specified direction, the corresponding sub-position is still determined based on the subsequent sub-offset.
[0140] In an embodiment of the present application, when the movement end time is not the target time, when i is equal to M, and the direction difference between the i+1th movement direction and the i-th movement direction is less than the specified direction, the movement device can also determine the i-th sub-position as the position of the subsequent movement of the virtual object.
[0141] It can be understood that by judging the size of the direction difference between the i-th movement direction and the i+1-th movement direction, and determining that the virtual object reaches the edge of the virtual movement surface and the subsequent movement direction remains unchanged, the currently determined sub-position is determined as the sub-position of the subsequent movement of the virtual object, which can reduce the resource consumption of the motion device in determining the position of the subsequent movement of the virtual object.
[0142] In the embodiment of the present application, when the sweep detection includes collision detection, see Figure 7 , Figure 7 The following is a flow chart of the method for moving a virtual object provided in the embodiment of the present application. Figure 3 ;like Figure 7 As shown, Figure 4 S404 in the above step can be implemented through S4046 to S4048; that is, the motion device performs a sweep detection on the i-th initial position to determine the i-th sub-position, including S4046 to S4048, and each step is described below.
[0143] S4046: Perform collision detection based on the i-1th sub-position and the i-th initial position to obtain a collision detection result.
[0144] It should be noted that the motion device performs collision detection between the i-1th sub-position and the i-th initial position, and obtains a collision detection result; wherein the collision detection result is the result of whether there is a virtual obstacle between the i-1th sub-position and the i-th initial position.
[0145] S4047: When the collision detection result shows that there is no virtual obstacle between the i-1th sub-position and the i-th initial position, the i-th initial position is determined as the i-th sub-position.
[0146] It should be noted that when the collision detection result shows that there is no virtual obstacle between the i-1th sub-position and the i-th initial position, it indicates that the virtual object can move from the i-1th sub-position to the i-th initial position. At this time, the motion device determines the i-th initial position as the i-th sub-position.
[0147] S4048. When the collision detection result shows that a virtual obstacle is included between the i-1th sub-position and the i-th initial position, the i-th initial position is pulled back based on the i-1th sub-position to obtain the i-th sub-position.
[0148] It should be noted that when the collision detection result shows that there is a virtual obstacle between the i-1th sub-position and the i-th initial position, it indicates that the virtual object cannot move from the i-1th sub-position to the i-th initial position by climbing over the obstacle. At this time, the motion device pulls the i-th initial position back to the i-1th sub-position to obtain the i-th sub-position.
[0149] It can be understood that the motion device performs collision detection and, when it is determined that there is a virtual obstacle between the i-1th sub-position and the i-th initial position, pulls back the i-th initial position based on the i-1th sub-position, so that the obtained i-th sub-position has higher validity, thereby improving the motion effect of the virtual object.
[0150] In an embodiment of the present application, in S4048, the motion device pulls back the i-th initial position based on the i-1-th sub-position to obtain the i-th sub-position, including S40481 and S40482 (not shown in the figure), and each step is described below.
[0151] S40481. When the displacement segmentation step is smaller than the specified step, the i-th initial position is pulled back based on the i-1-th sub-position to obtain the i-th sub-position including the i-1-th sub-position.
[0152] S40482: When the displacement segmentation step length is greater than or equal to the specified step length, determine the pullback position corresponding to the virtual obstacle based on the i-1th sub-position, and determine the pullback position as the i-th sub-position.
[0153] It should be noted that the sports device can use the i-1th sub-position as the i-th sub-position to implement a pull-back process for the i-th initial position based on the i-1th sub-position; the position at the virtual obstacle (for example, the position of the virtual obstacle closest to the i-1th sub-position) can also be used as the i-th sub-position to implement a pull-back process for the i-th initial position based on the i-1th sub-position; any position between the i-1th sub-position and the i-th initial position can be determined as the i-th sub-position to implement a pull-back process for the i-th initial position based on the i-1th sub-position; and the embodiments of the present application are not limited to this.
[0154] In an embodiment of the present application, when the displacement segmentation step is less than the specified step, the motion device may use the i-1th sub-position as the i-th sub-position; and when the displacement segmentation step is greater than or equal to the specified step, the position at the virtual obstacle may be used as the i-th sub-position.
[0155] In an embodiment of the present application, when the motion device performs sweep detection, it may first perform edge detection and then perform collision detection.
[0156] In the embodiment of the present application, the sweep detection in S403 is similar to the process described in S4041 to S4043, and S4046 to S4048, except that the processing objects are different. The processing object of S403 is the first initial position, and the processing object of S404 is the i-th initial position.
[0157] In an embodiment of the present application, S402 can be implemented through S4021 and S4022 (not shown in the figure); that is, the sports device divides the offset between the start time of the movement and the end time of the movement to obtain M sub-offsets, including S4021 and S4022, and each step is described below.
[0158] S4021. Determine the displacement segmentation step size based on the size of the virtual object.
[0159] S4022. Divide the offset between the movement start time and the movement end time based on the displacement segmentation step to obtain M sub-offsets.
[0160] It should be noted that the displacement segmentation step determined by the motion device for segmenting the offset may be determined based on the size of the virtual object, such as the radius of the circumscribed circle of the virtual object, half the length of the virtual object on the virtual motion surface, and so on.
[0161] Next, an exemplary application of the embodiment of the present application in a practical application scenario will be described. The exemplary application describes the movement process of a virtual character (referred to as a virtual object) completing a 2-meter roll within 2 seconds.
[0162] See also Figure 8 , Figure 8 is a flowchart of an exemplary method for moving a virtual object provided in an embodiment of the present application; Figure 8 As shown, the exemplary virtual object motion method includes S801 to S804, and the execution subject of the exemplary virtual object motion method is a server (referred to as a motion device). Figure 8 Each step is described separately.
[0163] S801. Obtain the initial state of the art displacement (called the last displacement update state).
[0164] S802, obtaining the current rendering frame time (Delta Time, also called target time).
[0165] It should be noted that when the upper layer calls, it can obtain the initial state of the art displacement and the actual rendered logical frame, wherein the actual rendered logical frame is the current rendering frame time.
[0166] S803. Determine the current state of the art displacement based on the initial state of the art displacement, the current rendering frame time, and the art displacement file (referred to as a preset animation file).
[0167] It should be noted that the server divides the time period corresponding to the current rendering frame time based on the frame time in the art displacement file to obtain multiple fixed time slices (called N sub-time slices); and obtains the offset corresponding to each fixed time slice from the art displacement file, divides the offset based on a fixed step length (called the displacement segmentation step length) to obtain M sub-offsets; by traversing the M sub-offsets, a sweep detection is performed on the new position (initial position) determined by each sub-offset to obtain the final new position (sub-position), thereby obtaining M final new positions. Here, the virtual character rolls based on the M final new positions in a sub-time period within the current rendering frame time, and finally reaches the final new position corresponding to the target time, thus determining the current state of the art displacement.
[0168] S804, determine whether the current rendering frame time reaches the maximum duration; if yes, end; if not, determine the current state of the art displacement as the initial state of the art displacement and continue to execute S802.
[0169] It should be noted that the maximum duration of rolling is 2 seconds.
[0170] The processing procedure corresponding to S803 is described in detail below.
[0171] See also Fig. 9 , Fig. 9is a schematic diagram of an exemplary process of determining the current state of art displacement provided by an embodiment of the present application; Fig. 9 As shown, the exemplary process of determining the current state of the art displacement includes S901 to S904, and the execution subject of the exemplary process of determining the current state of the art displacement is the server. Fig. 9 The steps shown are described separately.
[0172] S901. Divide the time period corresponding to the current rendering frame time based on the t frames (referred to as designated frames) in the art displacement file to obtain a target number of frames (ie, N).
[0173] S902: Advance the current frame by t frames.
[0174] S903, updating the art displacement to the current frame.
[0175] It should be noted that when the server updates the art displacement to the current frame, it divides the art displacement offset corresponding to the t frame (i.e., a fixed time slice) according to the sweep volume radius (i.e., a fixed step size), and performs ground calculation (called edge detection, including ground detection and edge pullback) and collision detection (ground calculation and collision detection are collectively referred to as sweep detection) on the new position determined by each divided sub-offset to determine the legitimacy of the new position; collision detection refers to the capsule sweep from the old position (called the starting position of the movement, or the i-1th sub-position) to the new position in an art displacement iteration (or traversal), and ground calculation refers to the use of terrain edge detection to determine the validity of the new position before the collision detection step.
[0176] For example, see Fig.10 , Fig.10 is a schematic diagram of an exemplary ground-based calculation provided in an embodiment of the present application; Fig.10 As shown, the exemplary process of the ground-based calculation includes S1001 to S1004. Fig.10 The steps shown are explained.
[0177] S1001. With respect to the old position 10-1 of the sphere (i.e., the virtual character), a new position is determined based on a fixed step length, and the starting point 10-2 and the end point of the sphere sweep are determined based on the maximum climbing angle configured in the art displacement file. Then, based on the sweep detection of the sphere between the starting point 10-2 and the end point, the sphere sweep collision point within the restricted height is determined, thereby determining the position 10-3 of the sphere (referred to as the initial ground position).
[0178] S1002. Use ray 10-4 downward at position 10-3 to detect whether there is a landing point for the sphere that meets the restricted height. If there is, it means that the sphere will not encounter the edge of the terrain after continuing to move; if not, it means that the position of the sphere in this artistic displacement iteration exceeds the edge of the terrain and needs to be pulled back (that is, edge pull back, also called pull back processing).
[0179] It should be noted that if the step size of each art displacement iteration (i.e., fixed step size) is relatively small (i.e., smaller than the specified step size), when ray 10-4 is used downward at position 10-3 to detect that there is no landing point of the sphere that meets the restricted height, the server can invalidate the new position, i.e., no pullback processing is required.
[0180] S1003, the center point of the sphere at position 10-3 is offset downward by the radius of the capsule body as the starting point 10-5 (called the edge detection starting point), and the old position 10-1 of the sphere is used as the end point (the same height as the starting point 10-5), and ray (called edge line) detection 10-6 is performed to find the edge point 10-7 (called the edge point position).
[0181] S1004. Since there is a terrain difference at the edge of the terrain, the edge point is not necessarily a valid sphere landing point; therefore, the 2D coordinates of the edge point are combined with the height of the starting point 10-2 to obtain the starting point 10-8 for another sphere sweep, and the sphere is swept again based on the starting point 10-8 and the restricted height, and the obtained sweep result is the valid sphere position (called sub-position).
[0182] It should be noted that the server can record the movement direction of this art displacement iteration. In the next art displacement iteration, if the movement direction is close to that of this art displacement iteration (that is, the direction difference is less than the specified direction), since the movement of the sphere has reached the edge of the terrain, the sweep detection is skipped and the position of this art displacement iteration is determined as the final new position of the next art displacement iteration; thus, repeated displacement at the edge terrain will not consume additional performance.
[0183] The process of ground detection can be found in Fig.11 , Fig.11 is a schematic diagram of an exemplary ground detection provided in an embodiment of the present application; Fig.11As shown, the capsule is initially located at the old position 11-1, and the new position is determined based on the offset of an artistic displacement iteration, and the starting position 11-4 and the ending position 11-5 of the capsule sweep are determined based on the limit height 11-3 corresponding to the maximum climbing angle 11-2; thereby, the sweep direction 11-6 calculated by touching the ground can be determined, and based on the sweep direction 11-6, the capsule sweep detection is performed between the starting position 11-4 and the ending position 11-5, and the determined position after touching the ground is the capsule sweep collision point 11-7 (called the initial ground position).
[0184] See also Fig.12 , Fig.12 is a schematic diagram of an exemplary collision detection provided by an embodiment of the present application; Fig.12 As shown, based on the old position 12-1 and the new position 12-2 of the capsule, the sweep direction 12-3 of the collision detection is determined; based on the sweep direction 12-3, the capsule is swept between the old position 12-1 and the new position 12-2 to determine the collision property between the old position 12-1 and the new position 12-2. Here, when there is a virtual obstacle between the old position 12-1 and the new position 12-2, the position before the virtual obstacle (the position where the virtual obstacle is closest to the old position 12-1) can be determined as the final new position, or the old position 12-1 can be determined as the final new position.
[0185] S904, determine whether the frame number of the current frame is less than the target frame number; if so, continue to execute S902, otherwise it indicates that the update of the art displacement corresponding to the current rendering frame time has been completed, and the processing flow ends.
[0186] It should be noted that the server inserts two layers of loops in the upper-level call and art displacement update of the art displacement update, namely, time segmentation of the logical frame passed in by the upper layer and displacement segmentation of the offset of the art displacement corresponding to each fixed time slice segmented. Here, the first layer of time segmentation can eliminate the influence of the frame rate on the calculation result; that is, although the frame rates of different clients are different, they are all based on the t frames in the same art displacement file (for example, 30 frames per second can be selected as the unit of segmentation time, that is, 0.03 seconds) for time segmentation; among them, if the corresponding time after completing the iteration of the fixed time slice is less than the overall duration corresponding to the art displacement file, then the remaining time that cannot fill a fixed time slice will not be processed and will be processed in the next upper-level call. The second layer of displacement segmentation can eliminate the influence of the terrain (that is, when the art displacement of one iteration is too long, there may be a problem of crossing illegal obstacles), among which the capsule radius can be selected as the fixed step size of displacement segmentation.
[0187] It is understandable that the motion method of virtual objects provided in the embodiment of the present application solves the inconsistency problem of artistic displacement calculation under different hardware environments by time segmenting the logical frame, and ensures that the artistic displacement calculation results under different devices can remain the same. And by performing displacement segmentation on the offset of the artistic displacement corresponding to each segmented fixed time slice, and performing sweep detection on the initial position determined by each sub-offset, the position at the edge of the terrain and the position of the virtual obstacle are pulled back, ensuring that the virtual character will not exceed the edge of the terrain or climb over the virtual obstacles that cannot be climbed during the artistic displacement update process, and repeated displacement at the edge of the terrain will not consume additional performance.
[0188] The following is a description of an exemplary structure of a virtual object motion device 255 provided in an embodiment of the present application implemented as a software module. In some embodiments, Figure 3 As shown, the software modules stored in the motion device 255 of the virtual object in the memory 250 may include:
[0189] The information acquisition module 2551 is used to acquire the movement start position and movement end time corresponding to the movement start time;
[0190] A displacement segmentation module 2552 is used to segment the offset between the movement start time and the movement end time to obtain M sub-offsets, where M is a positive integer greater than 1;
[0191] A sweep detection module 2553, configured to determine a first initial position based on the movement start position and the first sub-offset, and perform a sweep detection on the first initial position to obtain a first sub-position;
[0192] The detection iteration module 2554 is used to perform the following processing through iteration i, where 2≤i≤M, and i is a monotonically increasing integer variable: determine the i-th initial position based on the i-1-th sub-position and the i-th sub-offset, and perform a sweep detection on the i-th initial position to determine the i-th sub-position;
[0193] The object motion module 2555 is used to determine the motion trajectory of the virtual object based on the M sub-positions obtained in iteration i, and control the virtual object to move between the motion start time and the motion end time based on the motion trajectory.
[0194] In an embodiment of the present application, the information acquisition module 2551 is also used to obtain the last displacement update time and the target time; based on the specified frame, the time period between the last displacement update time and the target time is divided to obtain N start times and N end times corresponding to N sub-time periods, where N is a positive integer greater than 1; the j-th start time is determined as the start time of the movement, where 1≤j≤N, and j is a monotonically increasing integer variable; the j-th end time is determined as the end time of the movement; and the position corresponding to the j-th start time is determined as the start position of the movement.
[0195] In an embodiment of the present application, the sweep detection includes at least one of edge detection and collision detection, wherein the edge detection is used to determine whether the position of the virtual object on the virtual motion surface is the position at the edge of the virtual motion surface, and the collision detection is used to determine whether a virtual obstacle is included in the process of updating the position.
[0196] In an embodiment of the present application, when the sweep detection includes the edge detection, the sweep detection module 2553 is further used to perform ground detection on the i-th initial position based on the i-1th sub-position to obtain the i-th initial ground position; within the restricted height, when the detection ray of the i-th initial ground position intersects with the virtual motion surface, the i-th initial ground position is determined as the i-th sub-position; within the restricted height, when the detection ray of the i-th initial ground position does not intersect with the virtual motion surface, the i-th initial ground position is pulled back based on the i-1th sub-position to obtain the i-th sub-position.
[0197] In an embodiment of the present application, the sweep detection module 2553 is also used to determine the i-th edge detection starting point corresponding to the i-th initial ground position; obtain the edge line between the i-th edge detection starting point and the i-1-th sub-position on the plane corresponding to the height of the i-th edge detection starting point, and obtain the intersection position between the edge line and the virtual moving body to obtain the edge point position; combine the starting height of the ground detection and the edge point position to obtain a new starting point for the ground detection; pull back the i-th initial ground position based on the new starting point for the ground detection and the specified height to determine the i-th sub-position.
[0198] In the embodiment of the present application, the sweep detection module 2553 is further used to pull back the i-th initial ground position based on the i-1-th sub-position to obtain the i-th sub-position including the i-1-th sub-position.
[0199] In an embodiment of the present application, the sweep detection module 2553 is also used to obtain the i-th movement direction; when i is less than M, when the direction difference between the i+1-th movement direction and the i-th movement direction is less than a specified direction, the i-th sub-position is determined as the i+1-th sub-position.
[0200] In an embodiment of the present application, when the sweep detection includes the collision detection, the sweep detection module 2553 is also used to perform collision detection based on the i-1th sub-position and the i-th initial position to obtain a collision detection result; when the collision detection result is that the virtual obstacle is not included between the i-1th sub-position and the i-th initial position, the i-th initial position is determined to be the i-th sub-position; when the collision detection result is that the virtual obstacle is included between the i-1th sub-position and the i-th initial position, the i-th initial position is pulled back based on the i-1th sub-position to obtain the i-th sub-position.
[0201] In an embodiment of the present application, the sweep detection module 2553 is also used to, when the displacement segmentation step is less than the specified step, perform a pullback process on the i-th initial position based on the i-1th sub-position to obtain the i-th sub-position including the i-1th sub-position; when the displacement segmentation step is greater than or equal to the specified step, determine the pullback position corresponding to the virtual obstacle based on the i-1th sub-position, and determine the pullback position as the i-th sub-position.
[0202] In an embodiment of the present application, the information acquisition module 2551 is also used to determine the last displacement update time as the movement start time; determine the position corresponding to the last displacement update time as the movement start position; and determine the target time as the movement end time.
[0203] In an embodiment of the present application, the displacement segmentation module 2552 is also used to determine the displacement segmentation step based on the size of the virtual object; based on the displacement segmentation step, the offset between the movement start time and the movement end time is segmented to obtain M sub-offsets.
[0204] The embodiment of the present application provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device (referred to as a motion device) reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the motion method of the virtual object described in the embodiment of the present application.
[0205] The present application embodiment provides a computer-readable storage medium storing executable instructions, wherein the executable instructions are stored. When the executable instructions are executed by a processor, the processor will execute the virtual object movement method provided by the present application embodiment, for example, Figure 4 The motion method of the virtual object is shown.
[0206] In some embodiments of the present application, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.
[0207] In some embodiments of the present application, executable instructions may be in the form of programs, software, software modules, scripts or codes, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone programs or as modules, components, subroutines or other units suitable for use in a computing environment.
[0208] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0209] As an example, executable instructions may be deployed to be executed on one computer device (in which case, the one computer device is a mobile device), or on multiple computer devices located at one location (in which case, the multiple computer devices located at one location are mobile devices), or on multiple computer devices distributed at multiple locations and interconnected by a communication network (in which case, the multiple computer devices distributed at multiple locations and interconnected by a communication network are mobile devices).
[0210] To summarize, through the embodiments of the present application, when the virtual object is controlled to move between the start time and the end time of the movement, each sub-position in the obtained motion trajectory is obtained by dividing the offset of the updated displacement and performing a sweep detection on the initial position determined by each divided sub-offset. In this way, fine-grained sweep detection is achieved, and the influence of the terrain on the effectiveness of the updated position is reduced through displacement division, so that the effectiveness of each sub-position is higher; thereby, the motion effect of the rendered virtual object can be improved.
[0211] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A method for moving a virtual object, characterized in that: The method comprises: Get the movement start position and movement end time corresponding to the movement start time; The offset between the movement start time and the movement end time is divided into M sub-offsets, where M is a positive integer greater than 1; Determine a first initial position based on the movement start position and the first sub-offset, and perform a sweep detection on the first initial position to obtain a first sub-position; The following processing is performed by iteration i, where 2≤i≤M and i is a monotonically increasing integer variable: Determine the i-th initial position based on the i-1-th sub-position and the i-th sub-offset, and perform a sweep detection on the i-th initial position to determine the i-th sub-position; Determine a motion trajectory of the virtual object based on the M sub-positions obtained by iteration i, and control the virtual object to move between the motion start time and the motion end time based on the motion trajectory; The sweep detection includes edge detection, and the sweep detection is performed on the ith initial position to determine the ith sub-position, including: performing ground detection on the ith initial position based on the i-1th sub-position to obtain the ith initial ground position; within the restricted height, when the detection ray of the ith initial ground position intersects with the virtual motion surface, determining the ith initial ground position as the ith sub-position; within the restricted height, when the detection ray of the ith initial ground position does not intersect with the virtual motion surface, pulling back the ith initial ground position based on the i-1th sub-position to obtain the ith sub-position; The sweep detection of the first initial position to obtain the first sub-position includes: performing ground detection on the first initial position based on the movement starting position to obtain the first initial ground position; within the restricted height, when the detection ray of the first initial ground position intersects with the virtual movement surface, determining the first initial ground position as the first sub-position; within the restricted height, when the detection ray of the first initial ground position does not intersect with the virtual movement surface, pulling back the first initial ground position based on the movement starting position to obtain the first sub-position.
2. The method according to claim 1, characterized in that The step of obtaining the movement start position and the movement end time corresponding to the movement start time includes: Get the last displacement update time and target time; Based on the specified frame, the time period between the last displacement update time and the target time is divided to obtain N start times and N end times corresponding to the N sub-time periods, where N is a positive integer greater than 1; Determine the j-th starting time as the movement start time, where 1≤j≤N, and j is a monotonically increasing integer variable; Determine the jth end time as the movement end time; The position corresponding to the j-th start time is determined as the movement starting position.
3. The method according to claim 1 or 2, characterized in that: The sweep detection includes at least one of edge detection and collision detection, wherein the edge detection is used to determine whether the position of the virtual object on the virtual motion surface is the position at the edge of the virtual motion surface, and the collision detection is used to determine whether a virtual obstacle is included in the updated position process.
4. The method according to claim 1, characterized in that: The step of pulling back the i-th initial ground position based on the i-1th sub-position to obtain the i-th sub-position includes: Determine an i-th edge detection starting point corresponding to the i-th initial ground position; On a plane corresponding to the height of the ith edge detection starting point, obtain an edge line between the ith edge detection starting point and the (i-1)th sub-position, and obtain the intersection position between the edge line and the virtual moving body to obtain the edge point position; Combining the starting height of the ground detection and the edge point position to obtain a new starting point for the ground detection; The i-th initial ground-touching position is pulled back based on the new ground-touching detection starting point and the designated height to determine the i-th sub-position.
5. The method according to claim 1, characterized in that The step of pulling back the i-th initial ground position based on the i-1th sub-position to obtain the i-th sub-position includes: The i-th initial ground position is pulled back based on the i-1-th sub-position to obtain the i-th sub-position including the i-1-th sub-position.
6. The method according to claim 1, characterized in that After the i-th sub-position is obtained by performing a pullback process on the i-th initial ground-attached position based on the i-1-th sub-position, the method further includes: Get the i-th movement direction; When i is less than M, when the direction difference between the i+1th movement direction and the i-th movement direction is less than a specified direction, the i-th sub-position is determined as the i+1th sub-position.
7. The method according to claim 3, characterized in that When the sweep detection includes the collision detection, the sweep detection is performed on the i-th initial position to determine the i-th sub-position, including: Performing collision detection based on the i-1th sub-position and the i-th initial position to obtain a collision detection result; When the collision detection result is that the virtual obstacle is not included between the i-1th sub-position and the i-th initial position, determining the i-th initial position as the i-th sub-position; When the collision detection result is that the virtual obstacle is included between the i-1th sub-position and the i-th initial position, the i-th initial position is pulled back based on the i-1th sub-position to obtain the i-th sub-position.
8. The method according to claim 7, characterized in that The pulling back the i-th initial position based on the i-1-th sub-position to obtain the i-th sub-position includes: When the displacement segmentation step is smaller than the specified step, the i-th initial position is pulled back based on the i-1-th sub-position to obtain the i-th sub-position including the i-1-th sub-position; When the displacement segmentation step is greater than or equal to the specified step, the pullback position corresponding to the virtual obstacle is determined based on the i-1th sub-position, and the pullback position is determined as the i-th sub-position.
9. The method according to claim 2, characterized in that: After obtaining the last displacement update time and the target time, the method further includes: Determine the last displacement update time as the movement start time; Determine the position corresponding to the last displacement update time as the movement starting position; The target time is determined as the end time of the exercise.
10. The method according to claim 1 or 2, characterized in that: The offset between the movement start time and the movement end time is divided to obtain M sub-offsets, including: Determining a displacement segmentation step length based on the size of the virtual object; Based on the displacement segmentation step, the offset between the movement start time and the movement end time is segmented to obtain M sub-offsets.
11. A motion device for a virtual object, characterized in that: The motion rendering device of the virtual object comprises: An information acquisition module, used to acquire a movement start position and a movement end time corresponding to a movement start time; A displacement segmentation module, used for segmenting the offset between the movement start time and the movement end time to obtain M sub-offsets, where M is a positive integer greater than 1; A sweep detection module, used for determining a first initial position based on the movement starting position and the first sub-offset, and performing a sweep detection on the first initial position to obtain a first sub-position; a detection iteration module, configured to perform the following processing by iteration i, wherein 2≤i≤M, and i is a monotonically increasing integer variable: determining the i-th initial position based on the i-1-th sub-position and the i-th sub-offset, and performing a sweep detection on the i-th initial position to determine the i-th sub-position; an object motion module, configured to determine a motion trajectory of a virtual object based on the M sub-positions obtained by iteration i, and control the virtual object to move between the motion start time and the motion end time based on the motion trajectory; The sweep detection includes edge detection, and the detection iteration module is further used to perform ground detection on the i-th initial position based on the i-1th sub-position to obtain the i-th initial ground position; within the restricted height, when the detection ray of the i-th initial ground position intersects with the virtual motion surface, the i-th initial ground position is determined as the i-th sub-position; within the restricted height, when the detection ray of the i-th initial ground position does not intersect with the virtual motion surface, the i-th initial ground position is pulled back based on the i-1th sub-position to obtain the i-th sub-position; The sweep detection module is further used to perform ground detection on the first initial position based on the movement starting position to obtain the first initial ground position; within the restricted height, when the detection ray of the first initial ground position intersects with the virtual movement surface, the first initial ground position is determined as the first sub-position; within the restricted height, when the detection ray of the first initial ground position does not intersect with the virtual movement surface, the first initial ground position is pulled back based on the movement starting position to obtain the first sub-position.
12. A motion device for a virtual object, characterized in that: The motion device of the virtual object comprises: A memory for storing executable instructions; A processor, configured to implement the method for moving a virtual object according to any one of claims 1 to 10 when executing the executable instructions stored in the memory.
13. A computer-readable storage medium storing executable instructions, characterized in that: The executable instructions are used to implement the virtual object movement method according to any one of claims 1 to 10 when executed by a processor.
14. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the method for moving a virtual object according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Control method and device for motion track of virtual object, medium and electronic equipment
CN110496393A
Data synchronization method and device, equipment and storage medium
CN112843682A
