Virtual character gravity state determination method, equipment and medium
By constructing target gravity detection rays and collision detection, the virtual character's gravity state is adjusted, which solves the problem in the existing technology that dynamic gravity cannot adapt to various terrains in open world games, and achieves the satisfaction and immersion of diverse dynamic gravity requirements. gaming experience.
Patent Information
- Application Number
- CN202411310756.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-01-24
AI Technical Summary
The dynamic gravity implementation solution in existing games cannot support good adaptation of various terrains in open world games, and cannot experience the chain impact of gravity changes on other gameplay after gravity changes, resulting in limited immersive open world game experience.
By responding to changes in the state of gravity of the virtual character, obtain the motion of virtual characters in the virtual scene, build a target gravity detection ray, and determine the target gravity state through the collision detection detection to interact with the terrain of the virtual scene, thereby adjusting the state of gravity of the virtual role.
Achieve the satisfaction of diversified dynamic gravity needs in open world games, support the adaptation of various terrain, and experience the impact of chain of gravity changes on other gameplay after gravity changes. Essence
Smart Images

Figure CN119345693A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of Internet technology, and in particular to a method, device and medium for determining the gravity state of a virtual character. Background Art
[0002] With the development of game technology, the game development process often uses existing game engines to develop corresponding functions. For some basic functions, default parameter settings are usually used. For example, in open world games, the game engine provides default gravity parameters, which can be used directly without developers doing too much processing.
[0003] In some game scenes or some game characters, they are not limited to conventional ground movements. For example, the weightlessness effect in space or on the moon can be simulated. In another example, a virtual character with special skills can walk on a vertical wall. Currently, third-person games with dynamic gravity gameplay include "Bayonetta" and "Gravity Rush". The former only has dynamic gravity effects in specific terrains, with many restrictions, and players cannot actively change gravity; the latter uses gravity change as the main gameplay, but the terrain is relatively simple and lacks combat processes;
[0004] In the above games, dynamic gravity is either a limited auxiliary gameplay or a single gameplay, without mutual coordination with other gameplays in the game. In large-scale open world game projects, players are faced with an open world where they can freely explore, solve puzzles, and fight. Therefore, a dynamic gravity implementation solution is needed that can support good adaptation to various terrains. After changing the gravity, players can experience the chain effect of gravity changes on other gameplays in the open world, such as movement, combat, skill casting, etc., so as to achieve the goal of immersive open world games. Summary of the invention
[0005] The embodiments of the present invention provide a method, device and medium for determining the gravity state of a virtual character, so as to meet the diversified dynamic gravity requirements of the virtual characters in the game.
[0006] In a first aspect, an embodiment of the present invention provides a method for determining a gravity state of a virtual character, the method comprising:
[0007] In response to a change instruction of the gravity state of the virtual character, obtaining the motion state of the virtual character in the virtual scene, wherein the gravity state includes at least one of the gravity direction and the gravity acceleration;
[0008] determining a target gravity detection ray according to the motion state;
[0009] performing collision detection between the target gravity detection ray and the virtual scene terrain, and determining the target gravity state based on the collision detection result;
[0010] Based on the target gravity state, the gravity state of the virtual character is adjusted.
[0011] Optionally, the motion state is a moving state,
[0012] The step of determining the target gravity detection ray according to the motion state includes: constructing the target gravity detection ray at a preset distance above the character along a tangent direction of the motion trajectory of the virtual character;
[0013] The step of performing collision detection between the target gravity detection ray and the virtual scene terrain and determining the target gravity state based on the collision detection result includes:
[0014] Calculating the collision result between the target gravity detection ray and the virtual scene terrain according to a preset collision detection algorithm;
[0015] The target gravity state of the virtual character is determined according to the normal information of the virtual scene terrain obtained from the collision result.
[0016] Optionally, before constructing the target gravity detection ray at a position above the character at a preset distance along the tangent direction of the motion trajectory of the virtual character, the method further includes:
[0017] Setting a height planning configuration parameter according to the motion attributes of the virtual object;
[0018] If the height of the object in the moving direction of the virtual character is less than the height planning configuration parameter, the virtual character automatically crosses the object during the movement.
[0019] Optionally, the motion state is a falling state,
[0020] The constructing of the target gravity detection ray according to the motion state includes: constructing the target gravity detection ray from the center position of the virtual character along the current speed direction of the virtual character;
[0021] The step of performing collision detection between the target gravity detection ray and the virtual scene terrain and determining the target gravity state based on the collision detection result includes:
[0022] The collision result between the target gravity detection ray and the virtual scene terrain is calculated according to a preset collision detection algorithm, and the target gravity state and falling point of the virtual character are determined according to the collision result.
[0023] Optionally, calculating the collision result between the target gravity detection ray and the virtual scene terrain according to a preset collision detection algorithm, and determining the target gravity state and falling point of the virtual character according to the collision result, includes:
[0024] After constructing the target gravity detection ray, obtaining a collision result between the target gravity detection ray and the virtual scene terrain; the collision result includes a collision intersection point and a motion trajectory tangent line at the collision intersection point;
[0025] The collision intersection in the collision result is used as the falling point, and the normal direction of the plane where the falling point is located is used as the target gravity direction.
[0026] Optionally, the acquiring the motion state of the virtual character in the virtual scene and determining the target gravity detection ray according to the motion state further includes:
[0027] If the terrain of the virtual scene is a rugged surface, target gravity detection rays are arranged in the horizontal and vertical directions with the virtual character as the center, and a target gravity detection ray dot matrix is constructed by a plurality of the target gravity detection rays;
[0028] A collision result set between the target gravity detection ray dot matrix and the virtual scene terrain is calculated according to a preset collision detection algorithm, and a target gravity state of the virtual character is determined according to a combination of the collision results and preset result screening conditions.
[0029] Optionally, the motion state is rotational movement, and the virtual scene terrain is a rotating terrain;
[0030] The step of constructing a target gravity detection ray according to the motion state includes:
[0031] Determine the rotation angle of the virtual character;
[0032] If the rotation angle is greater than the angle threshold, multiple target gravity states are determined by interpolation;
[0033] If the rotation angle is not greater than the angle threshold, the tangent direction of the rotation direction is used as the target gravity state.
[0034] Optionally, it also includes:
[0035] When the virtual character is in a falling state, obtaining a current falling position of the virtual character;
[0036] Determining an actual falling distance according to the falling starting position and the current falling position;
[0037] If the actual falling distance reaches the preset falling threshold, the target gravity of the virtual character in the falling direction is restored, and the horizontal speed of the virtual character is eliminated.
[0038] Optionally, after calculating the target gravity of the virtual character in the virtual scene terrain that matches the current motion state of the virtual character using the target gravity detection ray, the method further includes:
[0039] In response to a skill control operation on the virtual character, determining whether a skill display effect is affected by target gravity and / or environmental gravity;
[0040] If the judgment result is that the skill display effect is not affected by the target gravity, the skill display effect is realized according to the original skill parameters;
[0041] If the result of the judgment is that the skill display effect is only affected by the target gravity, the skill display effect is modified according to the target gravity state and size;
[0042] If the judgment result is that the skill display effect is affected by the target gravity and the environmental gravity, the skill display and effect are corrected according to the direction and magnitude of the superposition of the target gravity and the environmental gravity.
[0043] In a second aspect, an embodiment of the present invention further provides an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, at least one program, a code set or an instruction set is loaded and executed by the processor to implement the method for determining the gravity state of a virtual character according to the first aspect.
[0044] In a third aspect, an embodiment of the present invention further provides a computer-readable medium having stored thereon at least one instruction, at least one program, a code set or an instruction set, wherein the at least one instruction, at least one program, a code set or an instruction set is loaded and executed by a processor to implement the method for determining the gravity state of a virtual character according to the first aspect.
[0045] In an embodiment of the present invention, in an open world game scene, a user can control a virtual character to freely explore, solve puzzles, and fight. The virtual environment is varied and can provide users with effective scenes of various terrains, and the virtual character can also perform various action skills in the virtual environment. Therefore, a method of constructing a corresponding target gravity detection ray according to the motion state of the virtual character in the virtual scene is proposed. The target gravity state of the virtual character in the virtual scene terrain is calculated using the collision result of the target gravity detection ray and the virtual scene terrain. In the above manner, when the user controls the virtual character to perform various tasks in the virtual scene, a target gravity detection ray is constructed according to the motion state of the current virtual character, and then the target gravity detection ray is used to determine the target gravity state that can meet the motion requirements of the virtual character. The gravity state of the virtual character can be adjusted as needed, so that the virtual character is not limited by factors such as game scenes, game skills and game environments, and can meet diverse gravity requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 A schematic diagram of a flow chart of a method for determining a gravity state of a virtual character provided in an embodiment of the present application;
[0048] Figure 2a A schematic diagram of a moving target gravity detection ray for illustrating an embodiment of the present application;
[0049] Figure 2b A schematic diagram of another target gravity detection ray in a moving state as illustrated in an embodiment of the present application;
[0050] Figure 3a , 3b A schematic diagram of a falling gravity ray detection provided in an embodiment of the present application;
[0051] Figure 3c A schematic diagram of another falling target gravity detection ray provided in an embodiment of the present application;
[0052] Figure 4 A schematic diagram of a four-probe calculation scheme proposed in an embodiment of the present application;
[0053] Figure 5a , 5b 5c is a schematic diagram of a target gravity detection ray array provided in an embodiment of the present application;
[0054] Figure 6 A schematic diagram of the actual falling distance provided in the embodiment of the present application;
[0055] Figure 7 A schematic diagram of the structure of a device for determining the gravity state of a virtual character provided in an embodiment of the present application;
[0056] Figure 8 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings, and "multiple" generally includes at least two.
[0059] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0060] In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.
[0061] With the development of game technology, in order to meet the diverse game experience of users, various innovations are made in the game scenes, so that users can obtain a real and novel game experience. In existing games, in order to enable users to obtain a more realistic game experience, a gravity environment is set in the game scene. As a result, when users manipulate the game characters, they experience an experience effect that is closer to the real world. However, in some game scenes, for example, a virtual character with special climbing skills requires the virtual character to have the ability to fly over eaves and walk on walls. It is necessary to adjust the gravity performance of the virtual character. However, in many games, the gravity state of the virtual character is not allowed to be adjusted at will, or the user is only allowed to adjust it in individual scenes or terrains. This limitation directly affects the user's game experience. Therefore, a solution is needed that can adjust the gravity accordingly according to the various motion states of the virtual character.
[0062] Terminology explanation:
[0063] CharacterMovementComponent: The character movement component provided by the UE4 engine. Since UE4 adopts a component-based design approach, the GamePlay framework provided by UE4 provides developers with a relatively perfect mobile solution to solve the most core basic operation of player movement. The core function of this mobile solution is completed by the mobile component MovementComponent.
[0064] ECollisionChannel::ECC_Terrain: A custom collision channel for gravity terrain detection. All the terrain detection for climbing in this article uses the ECollisionChannel::ECC_Terrain collision channel.
[0065] UKismetSystemLibrary: A public method library in UE4. The detection methods used in this solution are all derived from this library.
[0066] Pitch: A component of the object's rotation angle, which refers to the object's pitch angle.
[0067] Yaw: A component of the object's rotation angle, which refers to the object's horizontal rotation angle.
[0068] Roll: A component of an object's rotation angle, referring to the object's rolling angle.
[0069] ControlRotation: The angle of the player's controller, used to determine the player's current movement direction and camera orientation.
[0070] RotationBase: The base rotation of the player, calculated using the current gravity. It only changes if gravity changes.
[0071] GetViewRotation: The method by which the player obtains the viewing angle. Overriding this method can customize the player's viewing direction, and the player's viewing angle determines the player's movement direction.
[0072] Quat: Quaternion, often used to represent rotation in 3D space.
[0073] FRotationMatrix::MakeFromZY(VectorZ,VectorY): A method provided by UE to construct a rotation angle, indicating that the Z axis of the new angle points in the direction of the parameter VectorZ, and the Y axis points in the direction of VectorY.
[0074] PhysWalking: The method in CharacterMovementComponent that is responsible for the player's walking logic. This method simulates the walking / driving speed changes of characters or vehicles under physical gravity.
[0075] PhysFalling: The method in CharacterMovementComponent responsible for the player's falling logic. This method simulates the change in speed of a character or vehicle falling under physical gravity.
[0076] To facilitate understanding, specific embodiments will be used as examples below.
[0077] like Figure 1 A flowchart of a method for determining the gravity state of a virtual character provided in an embodiment of the present application. Figure 1 As can be seen in the figure, the method includes the following steps:
[0078] Step 101: In response to a change instruction of the gravity state of the virtual character, the motion state of the virtual character in the virtual scene is obtained, wherein the gravity state includes at least any one of the gravity direction and gravity acceleration.
[0079] Step 102: Determine a target gravity detection ray according to the motion state.
[0080] Step 103: performing collision detection between the target gravity detection ray and the virtual scene terrain, and determining the target gravity state based on the collision detection result.
[0081] Step 104: Based on the target gravity state, adjust the gravity state of the virtual character.
[0082] In an open world game scenario, users can control virtual characters to complete a given task. In the process of completing a task, the virtual character may go to various virtual scenes and perform various actions. In the process of the virtual character's execution, the gravity state of the virtual character may change accordingly. The change in gravity state mentioned here can be any one or more of the change in gravity direction and the change in gravity acceleration.
[0083] Among them, the impact of changes in gravity acceleration on the virtual character can be reflected in the virtual character's jumping height and falling speed along the current gravity direction. Generally speaking, the greater the magnitude of gravity acceleration, the smaller the jumping height and the faster the falling speed. Conversely, the smaller the magnitude of gravity acceleration, the greater the jumping height and the slower the falling speed. During the process of gravity acceleration, it works in conjunction with the direction. When the virtual character's movement direction is in the same direction as the acceleration direction, the virtual character will accelerate; when the virtual character's movement direction is opposite to the acceleration direction, the virtual character will decelerate.
[0084] Gravity direction change means that in the virtual scene, the direction of gravity is not only directed to the ground, but also to the wall, roof, etc., so that the virtual character has an adsorption effect on the corresponding contact surface. When the gravity direction changes, the corresponding virtual character's perspective also needs to be adjusted accordingly.
[0085] There are many kinds of virtual scenes or virtual terrains in which the gravity state changes, such as plane moving scenes, jumping or falling scenes with height differences, and virtual character rotation scenes. The gravity state changes in different ways in different scenes. For example,
[0086] When the virtual character moves on a plane and walks toward a wall in a virtual scene, the gravity direction in the gravity state of the virtual character is adjusted from vertically downward to vertically toward the wall.
[0087] For example, in a scene where a virtual character actively jumps off a cliff, or passively falls off a cliff, under the influence of the original gravity direction and gravity magnitude, the virtual character will dynamically adjust the gravity direction during the fall, thereby making the effect of the virtual character's falling process more realistic.
[0088] The change instructions mentioned here may be change instructions for a virtual character (evolving from character A to character B), change instructions for a skill change (e.g., enabling a new skill), or change instructions for a scene change (e.g., switching from an earth scene to a moon scene).
[0089] There can be multiple motion states, including translation state, falling state, jumping state, rotation state, etc. The methods of gravity detection in different motion states are not exactly the same. For example, in the translation state, a target gravity detection ray is constructed to switch from the current gravity state to the target gravity state. The following will explain different motion states and corresponding gravity direction adjustment schemes through specific embodiments, which will not be repeated here.
[0090] The target gravity detection ray mentioned here refers to the collision detection between the target gravity detection ray and the terrain in the surrounding virtual scene when the gravity state changes. The possible contact points of the virtual character are comprehensively determined based on the collision points between the target gravity detection ray and the terrain, and the target gravity direction is determined by using different types of detection rays. The collision detection mentioned here can be understood as the intersection between the target gravity detection ray and the terrain in the surrounding virtual environment. The following will be explained in detail through specific embodiments, please refer to the subsequent embodiments.
[0091] In practical applications, before adjusting the gravity state, it is necessary to understand the current motion state of the virtual character, including its position, speed, acceleration, and possible rotation state.
[0092] The motion state can be obtained through the physical system or character controller of the game engine, or the state identifier of the motion state, that is, the virtual character has different corresponding state identifiers in different motion states. When the user controls the virtual character to switch the motion state, the state identifier also changes accordingly.
[0093] In different motion states, different target gravity detection ray types are used, and the corresponding methods of judging target gravity are also different. For example, when standing still, walking, running, jumping, climbing, etc., target gravity detection rays in the tangent direction of the motion trajectory and target gravity detection rays in the falling state may be used.
[0094] According to the motion state of the virtual character and the current gravity state, select the appropriate target gravity detection ray type. For example, when walking on a wall, a horizontal target gravity detection ray may be required, while when walking on normal ground, a vertical downward target gravity detection ray may be required.
[0095] Target gravity detection rays are emitted, which start from a reference point of the virtual character (such as the sole of the foot, the center of the body, etc.) and extend along the expected direction of gravity.
[0096] Use the game engine's collision detection system to detect whether these rays collide with terrain, obstacles, or other interactive objects in the virtual scene. According to the results of the collision detection (such as the location of the collision point, the type of collision object, etc.), determine the target gravity state. For example, if the ray collides with a wall, it may mean that the character should be adsorbed on the wall and adjust the gravity direction accordingly. If the ray collides with other non-adsorbable terrain (for example, a thin line), adsorption is not allowed, and the corresponding gravity state will not be generated at the collision position.
[0097] Ensure that all relevant game systems and components (such as the physics engine, AI system, animation system, etc.) receive notifications of changes in gravity status and update their status and behavior accordingly. For example, whether the skill effects of the virtual character are consistent with the target gravity status, whether the clothing and hair effects are consistent with the target gravity status, etc. These need to be synchronized to other related components for corresponding adjustments after determining the target gravity status.
[0098] Through the above scheme, after receiving the gravity state change instruction for the virtual character provided by the user, the corresponding type of target gravity detection ray can be further constructed according to the motion state of the virtual character. Then, the target gravity detection ray is used to perform collision detection with the virtual scene terrain, and the state of the target gravity is determined based on the collision detection result. Through the above method, the gravity state of the virtual character can be adjusted in time according to the state of the virtual character, and the gravity state adjustment response is timely and accurate.
[0099] In one or more embodiments of the present application, the motion state is a moving state.
[0100] The determining of the target gravity detection ray according to the motion state includes: constructing the target gravity detection ray at a preset distance above the character along the tangent direction of the motion trajectory of the virtual character. The performing of collision detection between the target gravity detection ray and the virtual scene terrain and determining the target gravity state based on the collision detection result includes: calculating the collision result between the target gravity detection ray and the virtual scene terrain according to a preset collision detection algorithm; and determining the target gravity state of the virtual character based on the normal information of the virtual scene terrain obtained according to the collision result.
[0101] In practical applications, if the motion state of the virtual character is in a translation state, that is, the virtual character is walking, running, or other translation states on a plane such as the ground. In this state, a target gravity detection ray can be constructed along the tangent direction of the motion trajectory. Since the virtual character is in translation motion on a plane, the tangent direction of the corresponding translation motion state is the motion direction of the current virtual character. Construct a target gravity detection ray in the motion direction.
[0102] It is easy to understand that the gravity detection line is a ray that can be infinitely extended along a certain direction (that is, the translation direction of the virtual character). When the target gravity detection ray collides with the object in front (that is, the direction of movement), it means that the terrain in front meets the conditions for the gravity state change. The target gravity state can be calculated based on the collision result between the target gravity detection ray and the terrain in front.
[0103] like Figure 2a This is a schematic diagram of a moving target gravity detection ray for illustrating an embodiment of the present application. Figure 2a As can be seen in the figure, suppose that in the virtual scene of the current game, there is a virtual character (the capsule in Figure 2 represents the character) walking or running, and a ray is emitted in the direction of the character's current moving speed at a certain distance above the character's capsule (the character's above refers to the character's certain distance in the opposite direction of the current gravity). This is the target gravity detection ray. Since the motion state of the virtual character is a translation state, when constructing the target gravity detection ray, the target gravity detection ray is constructed along the tangent direction of the motion trajectory.
[0104] It should be noted that, in a preferred embodiment, when constructing the target gravity detection ray, it is necessary to construct the target gravity detection ray at a certain distance above the capsule body of the virtual character. For example, the target gravity detection ray is constructed at a position 5 centimeters above the virtual character. The upper distance position mentioned here is set according to the actual scene and needs. For another example, if the virtual character is an elf character or a flying saucer character that can float and move without contacting the ground, the target gravity detection ray can be constructed from the center position of the virtual character along the tangent direction of the movement. Of course, in the above-mentioned scenario of constructing the target gravity detection ray for the translation state, the choice of the starting position of the ray can be modified or adjusted according to actual needs, and does not constitute a limitation on the technical solution of the present application. It can be selected or adjusted as needed in actual applications.
[0105] Furthermore, it is assumed that the target gravity detection ray is constructed from a certain distance above the virtual character, and then Figure 2a It can be seen that the target gravity detection ray collides with the wall in front of it, and the collision result can be known. That is, the intersection point of the target gravity detection ray and the wall in front can be known, and the gravity direction can be determined along the direction of the target gravity detection ray.
[0106] In one or more embodiments of the present application, before constructing the target gravity detection ray at a preset distance above the character along the tangent direction of the motion trajectory of the virtual character, it also includes: setting a height planning configuration parameter according to the motion attribute of the virtual object; if the height of the object in the moving direction of the virtual character is less than the height planning configuration parameter, the virtual character automatically crosses the object during the movement. Conversely, if the height of the object is greater than the height planning configuration parameter, the virtual character will change the gravity state.
[0107] Figure 2b This is another schematic diagram of a target gravity detection ray in a moving state for illustrating an embodiment of the present application. In practical applications, when constructing a target gravity detection ray, the target gravity detection ray may be able to be aligned with the object in front (that is, Figure 2a The wall in the middle) may collide, or it may not collide (such as Figure 2b There are many reasons why no collision occurs. One is that there is no collidable object in front, or the object type does not meet the collision conditions (for example, there is a rope or a leaf in front), or the object in front is lower than the target gravity detection ray, which will cause the target gravity detection ray to have no collision result. If there is no collision result, or the collision result is illegal (for example, a collision with a rope, optical fiber, flowers, or leaves, these objects do not allow the virtual character to be attached, and the collision result is considered illegal). The virtual character can automatically cross the object directly. For example, directly cross a low wall, directly cross flowers, directly cross leaves, etc.
[0108] like Figure 2b This is another schematic diagram of a moving target gravity detection ray for illustrating an embodiment of the present application. Figure 2b As can be seen in the figure, the wall in front of the virtual character is a low wall, and the target gravity detection ray has no intersection with the wall, which means there is no collision result. Then the virtual character will not experience a change in gravity state due to the low wall, and the virtual character can directly cross the low wall.
[0109] Further assume that in the game scene, there is a virtual character 1 with a relatively short height (for example, an anthropomorphic mouse) and another virtual character 2 with a relatively tall height (for example, an anthropomorphic elephant). The height of the target gravity detection ray 1 constructed for the virtual character 1 is at position 1, and the height of the target gravity detection ray 2 constructed for the virtual character 2 is at position 2. Assume that when constructing the target gravity detection ray, the construction starts at a position 5 cm above the virtual character, but because the height difference between the virtual character 1 and the virtual character 2 is large (assuming a difference of 10 cm), the collision results of the target gravity detection ray 1 and the target gravity detection ray 2 are different. The target gravity detection ray 1 collides with the low wall in front and produces a corresponding collision result, and the gravity state of the virtual character 1 needs to be changed accordingly. However, the target gravity detection ray 2 does not collide with the low wall in front and does not produce a collision result, so the virtual character 2 can directly cross the low wall.
[0110] Through the above scheme, in the translation state, by reasonably constructing the target gravity detection ray and using the collision result between the target gravity detection ray and the surrounding virtual environment terrain, the final target gravity state, including the target gravity direction, target gravity acceleration, etc., can be adjusted in real time according to the changes in the motion state of the virtual character.
[0111] In one or more embodiments of the present application, the motion state is a falling state. The determining of the target gravity detection ray according to the motion state includes: constructing the target gravity detection ray from the center position of the virtual character along the current speed direction of the virtual character.
[0112] The collision detection is performed based on the target gravity detection ray and the virtual scene terrain, and the target gravity state is determined based on the collision detection result, including: calculating the collision result between the target gravity detection ray and the virtual scene terrain according to a preset collision detection algorithm, and determining the target gravity state and falling point of the virtual character according to the collision result.
[0113] In practical applications, when the motion state is determined to be a falling state, in order to ensure the naturalness and accuracy of the virtual character's behavior and interaction with the environment, in this special motion state, the construction method of the target gravity detection ray needs to be adjusted accordingly to adapt to the dynamic changes in the falling process.
[0114] Specifically, when the virtual character is in a falling state, that is, in the process of free fall from a high altitude or falling continuously without touching the supporting surface after jumping, the target gravity detection ray is constructed from the center position of the virtual character along its current velocity direction. Therefore, when constructing the target gravity detection ray, the direction of the target gravity detection ray should be consistent with the current velocity direction to accurately predict and respond to the upcoming collision.
[0115] The specific steps to construct the target gravity detection ray are as follows: first, determine the center point of the virtual character, which usually represents the center of mass or geometric center of the character; second, calculate the velocity direction based on the current velocity vector of the character; finally, start from the center point and emit a ray along this velocity direction, which is the target gravity detection ray in the falling state. In order to make the action effect of the virtual character more realistic, the speed during the falling process can be considered to be affected by factors such as wind resistance and changes in gravity acceleration. In actual applications, it may be necessary to regularly update the direction of the ray to reflect the latest motion status of the character.
[0116] Next, the preset collision detection algorithm is used to perform detailed collision detection on the target gravity detection ray and the virtual scene terrain. This step aims to accurately determine whether the target gravity detection ray collides with the virtual environment terrain (such as the ground, platform edge, obstacles, etc.) and obtain specific information about the collision, including the location of the collision point, the normal direction of the collision surface, etc. This information is crucial for determining the target gravity state and falling point of the virtual character.
[0117] Based on the collision detection results, the system can further calculate the target gravity state of the virtual character. In the falling scene, the target gravity state often involves the character's transition from a free-falling state to a ground-supported state. At the same time, based on the location of the collision point, the character's final landing point can be determined, which is of great significance for subsequent animation playback, physical effect simulation (such as collision impact force feedback) and game logic processing (such as checking whether it has fallen into a trap, triggering events, etc.).
[0118] In summary, constructing target gravity detection rays and performing collision detection for the falling state can not only improve the realism of physical simulation in games or virtual environments, but also provide accurate data support for character behavior decisions, thereby enhancing the immersion and satisfaction of the user experience.
[0119] For ease of understanding, the following example illustrates the falling state. Figure 3a , 3b A schematic diagram of a falling state provided in an embodiment of the present application. Figure 3aAs can be seen in the figure, the virtual character capsule (that is, the side view of the character) is the way to fall after jumping. At the starting position of the jump, there is an oblique upward speed. At this time, the direction of the target gravity detection ray is consistent with the speed of the virtual character or the tangent direction of the motion trajectory. As the horizontal speed decays, the speed direction and motion trajectory of the virtual character also change accordingly, and the direction of the target gravity detection ray in the corresponding tangent direction of the motion trajectory is also adjusted accordingly. However, before the gravity changes (that is, before the target gravity detection ray collides with the surrounding terrain environment), the gravity direction is always downward. It can be seen that in the case of jumping and falling, the process of constructing the target gravity detection ray is more complicated and will change accordingly with the change of the motion trajectory. In this case, there are also multiple possibilities for the collision result. For example, in the oblique upward stage of jumping, the target gravity detection ray collides with the oblique upper object, and a collision result will be generated on the oblique upper object. Then, the target gravity state and the falling point are determined based on the collision result at this position. If no collision occurs in the jumping and rising stage, the virtual character will fall downward next, and the target gravity detection ray will be constructed and the collision result will be judged in the same way.
[0120] from Figure 3b As can be seen in the figure, the virtual character capsule (that is, the side view of the character) falls directly. At the beginning of the fall, there is a downward speed, and the direction of the target gravity detection ray is consistent with the speed of the virtual character or the tangent direction of the motion trajectory. As the horizontal speed decays, the speed direction and motion trajectory of the virtual character also change accordingly, and the direction of the target gravity detection ray in the tangent direction of the corresponding motion trajectory is also adjusted accordingly. However, before the gravity changes (that is, before the target gravity detection ray collides with the surrounding terrain environment), the gravity direction is always downward. During the fall, the constructed target gravity detection ray will be used to perform collision detection with the surrounding environment to obtain the collision result, and then the falling point and target gravity direction are determined based on the collision result.
[0121] Figure 3c A schematic diagram of another target gravity detection ray array provided in an embodiment of the present application. Figures 3a to 3b In addition to the current speed direction detection described in the previous section, the virtual character's current horizontal plane (perpendicular to the virtual character's current gravity and passing through the center of the virtual character (that is, Figure 3c A week of X-ray testing was performed on the center of the capsule body of the virtual character (i.e. Figure 3c When the character in the virtual character falls, it searches for the surrounding landing plane. If multiple rays detect suitable planes, the closest plane is selected. In this way, the preferred collision plane in the surrounding virtual environment can be quickly selected by using a circle of detection rays built based on the center of the virtual character.
[0122] In practical applications, game technicians can choose to use Figures 3a to 3b The solution shown or Figure 3c The solution shown can better meet the diverse needs of game technicians.
[0123] In the falling state, the collision result between the target gravity detection ray and the virtual scene terrain is calculated according to a preset collision detection algorithm, and the target gravity state and falling point of the virtual character are determined according to the collision result, including: after constructing the target gravity detection ray, obtaining the collision result between the target gravity detection ray and the virtual scene terrain; the collision result includes a collision intersection point and a tangent line of the motion trajectory at the collision intersection point. The collision intersection point in the collision result is used as the falling point, and the normal direction of the plane where the falling point is located is used as the target gravity direction.
[0124] In practical applications, the calculation of the collision result between the target gravity detection ray and the virtual scene terrain according to the preset collision detection algorithm, and then determining the target gravity state and falling point of the virtual character according to these collision results, specifically includes the following steps:
[0125] Construct target gravity detection rays: Construct one or more target gravity detection rays at the current position of the virtual character or at a point determined according to a specific motion state (such as the virtual character's jumping, falling, etc.). These rays usually extend along the direction of gravity (or possible directions, such as the anti-gravity direction when jumping upwards) to detect potential collisions with the virtual scene terrain.
[0126] The collision between the target gravity detection ray and the virtual scene terrain is calculated using a preset collision detection algorithm. The collision detection algorithm can be a four-probe algorithm, or it can be implemented based on space partitioning (such as octree, quadtree), bounding volume hierarchy (BVH), distance field or ray tracing.
[0127] After the collision detection is completed, the collision results are obtained. These results usually include: Collision intersection point: the specific point where the target gravity detection ray intersects with the virtual scene terrain, which will be used as the virtual character's falling point. The collision intersection point in the collision result is directly designated as the virtual character's falling point. This means that the virtual character will physically contact the terrain at this point and may change its motion state as a result.
[0128] After determining the fall point, it is necessary to estimate the normal direction of the plane at that point as the target gravity direction. This usually involves analyzing the local geometry of the terrain. In some cases, the normal of the terrain grid at that point can be used directly; in more complex terrain, it may be necessary to estimate it through methods such as interpolation or surface fitting.
[0129] According to the estimated target gravity direction, combined with the current motion state of the virtual character (such as speed, acceleration, rotation, etc.), the new gravity state is calculated and applied. This may include adjusting the character's falling speed, rotation angle, and triggering related physical effects (such as bouncing, sliding, etc.).
[0130] Through the above steps, a relatively accurate and dynamic detection and calculation scheme for the falling point and target gravity state can be implemented, providing a more realistic and natural experience for the movement and interaction of virtual characters in complex virtual scenes.
[0131] Among them, this application also proposes a preferred solution for calculating target gravity. Figure 4 A schematic diagram of a four-probe calculation scheme proposed in the embodiment of the present application. Figure 4 As can be seen in the figure, a scheme for determining the target gravity direction using four probes is used. A four-probe ray matrix is constructed at the intersection position; the intersection of any ray in the four-probe ray matrix and the surrounding objects is determined; the first vector and the second vector are constructed in the vertical direction and the horizontal direction respectively with the intersection as the starting point; the target normal is determined based on the dot product operation result of the first vector and the second vector; the target gravity matching the current motion state of the virtual character is calculated using the target normal.
[0132] Specifically, a four-probe ray lattice is constructed: at the collision intersection (i.e., the falling point), four equidistant and mutually perpendicular rays are constructed to form a cross or square probe ray lattice. These rays should be long enough to ensure that they can intersect with the terrain or obstacles in the virtual scene.
[0133] For each probe ray, calculate its collision intersection with the virtual scene terrain. These collision intersections will be used for subsequent calculations. Take each collision intersection as the starting point and construct two vectors: one vertically upward (or other vertical directions defined by the scene) as the first vector; the other is along the tangent direction of the terrain surface (an approximation of the horizontal direction) as the second vector. Note that the tangent direction here may need to be estimated based on the local terrain information at the collision point.
[0134] The dot product operation is performed on the first vector and the second vector of each collision intersection. Since the sign of the dot product can represent the angle between the two vectors (positive when the angle between the two vectors is less than 90 degrees and negative when it is greater than 90 degrees), the local curvature or tilt direction of the terrain can be inferred by analyzing the signs of these dot products.
[0135] By combining the information of all collision intersections, a more accurate target normal direction can be estimated through weighted average or other statistical methods. This direction will be used as the target gravity direction. Based on the calculated target normal direction and the current motion state of the virtual character (such as speed, acceleration, etc.), the corresponding target gravity is calculated and applied to achieve more realistic physical effects and dynamic reactions.
[0136] Of course, in addition to the four-probe solution, calculations can also be performed based on the size of the contact area. For example, the contact area can be detected first, that is, when a collision occurs, the contact area between the virtual character and the virtual scene terrain is detected. This usually involves polygon or mesh collision processing in the collision detection algorithm. According to the shape and size of the contact area, the contact area is calculated. This may require the use of area calculation formulas for geometric figures, such as the area formulas for triangles, rectangles, or polygons. Based on the geometric characteristics and distribution of the contact area, an average normal direction is estimated. This can be achieved by weighted averaging the normals of the boundary points of the contact area, or by using more complex surface reconstruction techniques to estimate. Similar to the four-probe solution, based on the estimated target normal direction, combined with the current state of the virtual character, the corresponding target gravity is calculated and applied. This solution based on the size of the contact area may be more suitable for complex terrain or large-area contact situations, and can provide a smoother and more natural gravity transition effect.
[0137] Through the above method, in the falling state, the corresponding target gravity detection ray is constructed according to the specific falling mode (jumping fall or free fall fall). Then, the collision result of the target gravity detection ray is used to determine the falling point and the corresponding target gravity direction, which can be adjusted in real time according to the change of the virtual character's motion state.
[0138] In one or more embodiments of the present application, the method of obtaining the motion state of the virtual character in the virtual scene and determining the target gravity detection ray according to the motion state also includes: if the terrain of the virtual scene is a rugged surface, arranging the target gravity detection rays horizontally and vertically with the virtual character as the center, and constructing a target gravity detection ray dot matrix from multiple target gravity detection rays; calculating a set of collision results between the target gravity detection ray dot matrix and the virtual scene terrain according to a preset collision detection algorithm, and determining the target gravity state of the virtual character according to a combination of the collision results and preset result screening conditions.
[0139] like Figure 5a , 5b 5c is a schematic diagram of a target gravity detection ray array provided in an embodiment of the present application. Figure 5aAs can be seen in , the normals of each plane in the discontinuous plane can be determined first; then the angle between the current gravity line of the virtual character and the multiple normals can be determined; the multiple normals can be screened according to the angle. The normals obtained by screening are weighted averaged to obtain the weight value of each normal; when there are multiple intersections between the target gravity detection ray and the rugged surface in the target gravity detection ray lattice, the target surface in the rugged surface for calculating the target gravity is selected according to the weight value, and the target gravity is calculated based on the target surface.
[0140] Specifically, if Figure 5c As shown, when the virtual character is in a virtual scene of a rugged surface, for example, the rugged surface can be divided into regions and the normal of each rugged surface can be determined. In a virtual scene of a rugged terrain, it is first necessary to identify the various non-continuous planes that make up the terrain (such as steps and slopes of different heights). For each such plane, calculate the normal vector of its surface. This can usually be achieved by analyzing the geometric relationship between the vertex heights and adjacent vertices of the terrain mesh in this area. The normal vector is perpendicular to the plane and points to the outside or top of the terrain.
[0141] Figure 5a 5b represents the top view of the ray lattice, and 5c represents the side view of the ray lattice. Figure 5a and 5b As shown, the position of the virtual character is determined as the center point of ray emission. Starting from the position of the virtual character, multiple rays are evenly distributed in the horizontal direction (left and right sides) to detect terrain changes on the left and right sides of the character. Starting from the position of the virtual character, rays are emitted in the vertical direction (upper and lower sides), especially the rays emitted downward are used to detect the ground conditions under the feet of the virtual character, and the rays emitted upward (if applicable) are used to detect whether there are hanging objects or obstacles above. In addition, rays centered on the virtual character can be added in other directions as needed. Set the length of each ray, the detection interval (that is, the angle or distance between the rays), and the possible penetration (whether to penetrate specific objects (such as leaves, flowers, etc.) to continue detection). The specific collision algorithm can adopt the method described above, which will not be repeated here. Please refer to the various embodiments described above.
[0142] Determine the current direction of the virtual character's gravity line (in most cases, this is the direction perpendicular to the ground plane of the virtual scene). Then, calculate the angle between this gravity line and each plane normal determined previously. The size of the angle reflects the degree of deviation between the gravity direction and the plane normal direction.
[0143] Multiple normals are screened based on the size of the angle. Generally speaking, the smaller the angle, the closer the normal direction of the plane is to the direction of gravity, so the plane is more likely to be the main source of gravity currently exerted on the virtual character. A threshold can be set to remove large angles or only keep normals with angles less than the threshold for subsequent processing.
[0144] For the normals obtained by screening, weighted averaging is performed to determine their combined influence on the target gravity. The weight distribution can be based on multiple factors, such as the angle size (the smaller the angle, the greater the weight), the plane area (the larger the area, the greater the possible influence), the distance between the virtual character and the plane (the closer the distance, the more direct the influence), etc. Through weighted averaging, the contribution of each normal in determining the target gravity direction can be calculated.
[0145] In the target gravity detection ray matrix, if there are multiple intersection points, that is, the target gravity detection ray of the virtual character intersects with the rugged surface at multiple locations, then the target surface needs to be selected based on the weight value calculated previously. The target surface is one of those planes with the highest weight value and the greatest impact on the direction of gravity. Once the target surface is determined, the target gravity can be calculated based on the normal direction of the surface. This usually means adjusting the gravity direction to be consistent with the normal direction of the target surface (or fine-tuning it according to the weight) to ensure that the behavior of the virtual character on the rugged surface is more realistic and in line with the laws of physics. Through the above steps, the target gravity state of the virtual character in the rugged terrain can be determined more accurately, providing a more realistic and immersive gaming experience.
[0146] In one or more embodiments of the present application, the motion state is rotational movement (or the virtual scene terrain is a rotating terrain, that is, the user's viewing effect is that the virtual character is stationary but the terrain is moving). Determining the target gravity detection ray according to the motion state includes: determining the rotation angle of the virtual character; if the rotation angle is greater than an angle threshold, determining multiple target gravity states by interpolation; if the rotation angle is not greater than the angle threshold, using the tangent direction of the rotation direction as the target gravity state.
[0147] In actual applications, if the virtual character is in a state of rotational movement, or the terrain of the virtual scene where the virtual character is located is in a state of rotational movement relative to the virtual character, it is necessary to further determine the size of the rotation angle of the rotational movement. If the rotation angle is not large (for example, the rotation angle is less than the angle threshold), the target gravity state of the virtual character can be directly adjusted. Since the angle deviation is not large, direct adjustment will not make the user feel that the gravity direction jumps and changes.
[0148] On the contrary, if the rotation angle is greater than the angle threshold, the target gravity state needs to be gradually adjusted by interpolation, that is, the gravity direction is adjusted step by step. Through the above scheme, when determining the target gravity direction, corresponding adjustments are made according to the rotation angle, so that the adjustment process is more natural and the game users get a better gaming experience.
[0149] In one or more embodiments of the present application, it also includes: when the virtual character is in a falling state, obtaining the current falling position of the virtual character; determining the actual falling distance according to the falling starting position and the current falling position; if the actual falling distance reaches a preset falling threshold, restoring the target gravity of the virtual character in the falling direction, and eliminating the horizontal speed of the virtual character.
[0150] like Figure 6 This is a schematic diagram of the actual falling distance provided in the embodiment of the present application. Figure 6 As can be seen in the figure, during the falling process of the virtual character, the gravity state needs to be controlled according to the actual falling distance. If the gravity state is not controlled or restricted, when the falling distance is long enough, the virtual character will appear in a flying state, which is obviously inconsistent with the actual situation (not consistent with the movement state affected by gravity in the open world). Therefore, the gravity state needs to be adjusted accordingly according to the change of the actual falling distance.
[0151] The actual falling distance here refers to the distance from the starting position to the current falling position. During the falling process of the virtual character, the current falling position is constantly changing. When the actual falling distance reaches the preset distance threshold, the target gravity state of the virtual character will be restored. That is, the target gravity state of the virtual character in the falling direction will be restored.
[0152] When the target gravity is restored, the horizontal speed of the virtual character will also be eliminated to avoid the virtual character from appearing to be flying forward continuously.
[0153] In one or more embodiments of the present application, after calculating the target gravity of the virtual character in the virtual scene terrain that matches the current motion state of the virtual character using the target gravity detection ray, the method further includes:
[0154] In response to a skill control operation on the virtual character, determining whether a skill display effect is affected by target gravity and / or environmental gravity;
[0155] If the judgment result is that the skill display effect is not affected by the target gravity, the skill display effect is realized according to the original skill parameters;
[0156] If the result of the judgment is that the skill display effect is only affected by the target gravity, the skill display effect is modified according to the target gravity state and size;
[0157] If the judgment result is that the skill display effect is affected by the target gravity and the environmental gravity, the skill display and effect are corrected according to the direction and magnitude of the superposition of the target gravity and the environmental gravity.
[0158] When the gravity state is adjusted according to the movement state, it is also necessary to further determine whether the skill display effect needs to be adjusted accordingly.
[0159] During the adjustment process, it is necessary to make adjustments according to different situations. This is because different types of skills are affected by gravity to different degrees and in different ways. There are mainly three situations:
[0160] The first one is that the skill display effect is not affected by the target's gravity state. For example, the skill display effect of a virtual character using game skills to control the freezing of a lake is not affected by gravity changes because the gravity state of environmental objects in the open world game scene has not changed, that is, the lake water is still controlled by environmental gravity.
[0161] The second type is only affected by the target's gravity state. For example, in the game, the virtual character has changed the gravity state (for example, walking on the vertical plane of the wall), and the virtual character uses the fire-breathing skill during the execution of the task. Since the direction of the flame is less affected by gravity, the flame effect of the virtual character's fire-breathing is only affected by the target's gravity state, and the gravity state is adjusted together with the virtual character.
[0162] The third type is being affected by two gravity forces at the same time. For example, if the virtual character has changed the gravity state (for example, walking on the vertical plane of the wall), and the virtual character uses the javelin throwing skill during the task, the javelin will be affected by both gravity forces, and after being thrown forward for a distance, it will eventually fall to the ground under the action of environmental gravity. Regardless of which gravity is affected, the skill display effect can be adjusted in a timely and accurate manner.
[0163] Based on the same idea, the embodiment of the present application also provides a device for determining the gravity state of a virtual character. Figure 7 A schematic diagram of a structure for determining the gravity state of a virtual character provided in an embodiment of the present application. The device comprises:
[0164] An acquisition module 71 is used to acquire the motion state of the virtual character in the virtual scene in response to a change instruction of the gravity state of the virtual character, wherein the gravity state includes at least one of the gravity direction and the gravity acceleration;
[0165] The determination module 72 is used to determine the target gravity detection ray according to the motion state.
[0166] The detection module 73 is used to perform collision detection between the target gravity detection ray and the virtual scene terrain, and determine the target gravity state based on the collision detection result.
[0167] The adjustment module 74 is used to adjust the gravity state of the virtual character based on the target gravity state.
[0168] Optionally, the motion state is a moving state. A determination module 72 is configured to construct the target gravity detection ray at a position of a preset distance above the character along a tangent direction of the motion trajectory of the virtual character;
[0169] A detection module 73, used for calculating the collision result between the target gravity detection ray and the virtual scene terrain according to a preset collision detection algorithm;
[0170] The target gravity state of the virtual character is determined according to the normal information of the virtual scene terrain obtained from the collision result.
[0171] A detection module 73, used to set a height planning configuration parameter according to the motion properties of the virtual object;
[0172] If the height of the object in the moving direction of the virtual character is less than the height planning configuration parameter, the virtual character automatically crosses the object during the movement.
[0173] Optionally, the motion state is a falling state,
[0174] The determination module 72 is used to construct the target gravity detection ray from the center position of the virtual character along the current speed direction of the virtual character.
[0175] The detection module 73 is used to calculate the collision result between the target gravity detection ray and the virtual scene terrain according to a preset collision detection algorithm, and determine the target gravity state and falling point of the virtual character according to the collision result.
[0176] The detection module 73 is used to obtain the collision result between the target gravity detection ray and the virtual scene terrain after constructing the target gravity detection ray; the collision result includes a collision intersection point and a motion trajectory tangent line at the collision intersection point;
[0177] The collision intersection in the collision result is used as the falling point, and the normal direction of the plane where the falling point is located is used as the target gravity direction.
[0178] The acquisition module 71 is used for arranging target gravity detection rays in the horizontal and vertical directions with the virtual character as the center if the terrain of the virtual scene is a rugged surface, and constructing a target gravity detection ray dot matrix from a plurality of the target gravity detection rays;
[0179] A collision result set between the target gravity detection ray dot matrix and the virtual scene terrain is calculated according to a preset collision detection algorithm, and a target gravity state of the virtual character is determined according to a combination of the collision results and preset result screening conditions.
[0180] Optionally, the motion state is rotational movement, and the virtual scene terrain is a rotating terrain;
[0181] The determination module 72 is used to determine the rotation angle of the virtual character; if the rotation angle is greater than the angle threshold, multiple target gravity states are determined by interpolation; if the rotation angle is not greater than the angle threshold, the tangent direction of the rotation direction is used as the target gravity state.
[0182] A determination module 72, configured to obtain a current falling position of the virtual character when the virtual character is in a falling state;
[0183] Determining an actual falling distance according to the falling starting position and the current falling position;
[0184] If the actual falling distance reaches the preset falling threshold, the target gravity of the virtual character in the falling direction is restored, and the horizontal speed of the virtual character is eliminated.
[0185] Optionally, the adjustment module 74 is further used to determine whether the skill display effect is affected by target gravity and / or environmental gravity in response to the skill control operation on the virtual character;
[0186] If the judgment result is that the skill display effect is not affected by the target gravity, the skill display effect is realized according to the original skill parameters;
[0187] If the result of the judgment is that the skill display effect is only affected by the target gravity, the skill display effect is modified according to the target gravity state and size;
[0188] If the judgment result is that the skill display effect is affected by the target gravity and the environmental gravity, the skill display and effect are corrected according to the direction and magnitude of the superposition of the target gravity and the environmental gravity.
[0189] It should be noted that the functional units included in the modules mentioned above can realize the various functions described in the device for determining the gravity state of a virtual character, and will not be repeated here.
[0190] In one possible design, the above Figure 8 The structure of the virtual character gravity state determination device shown can be implemented as an electronic device. Figure 8 As shown, the electronic device may include: a processor 81 and a memory 82. The memory 82 stores executable code, and when the executable code is executed by the processor 81, the processor 81 can at least implement the lip animation generation method provided in the above embodiment. The structure of the electronic device may also include a communication interface 83 for communicating with other devices or communication networks.
[0191] In addition, an embodiment of the present invention provides a non-transitory machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor in a server or a computer, the processor executes the operations provided in the above embodiments. Figure 1 The corresponding method for determining the gravity state of the virtual character.
[0192] The device embodiments described above are merely illustrative, wherein the modules described as separate components may or may not be physically separated. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Those of ordinary skill in the art may understand and implement the present invention without creative effort.
[0193] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on such an understanding, the above technical solution can essentially or contribute to the part in the form of a computer product, and the present invention can be implemented in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer-usable program codes.
[0194] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for determining the gravity state of a virtual character, characterized in that: The method comprises: In response to a change instruction of the gravity state of the virtual character, obtaining the motion state of the virtual character in the virtual scene, wherein the gravity state includes at least one of the gravity direction and the gravity acceleration; determining a target gravity detection ray according to the motion state; performing collision detection between the target gravity detection ray and the virtual scene terrain, and determining the target gravity state based on the collision detection result; Based on the target gravity state, the gravity state of the virtual character is adjusted.
2. The method according to claim 1, characterized in that: The motion state is a moving state, The step of determining the target gravity detection ray according to the motion state includes: constructing the target gravity detection ray at a preset distance above the character along a tangent direction of the motion trajectory of the virtual character; The step of performing collision detection between the target gravity detection ray and the virtual scene terrain and determining the target gravity state based on the collision detection result includes: Calculating a collision result between the target gravity detection ray and the virtual scene terrain according to a preset collision detection algorithm; The target gravity state of the virtual character is determined according to the normal information of the virtual scene terrain obtained from the collision result.
3. The method according to claim 2, characterized in that Before constructing the target gravity detection ray at a position above the character at a preset distance along the tangent direction of the motion trajectory of the virtual character, the method further includes: Setting a height planning configuration parameter according to the motion attributes of the virtual object; If the height of the object in the moving direction of the virtual character is less than the height planning configuration parameter, the virtual character automatically crosses the object during the movement.
4. The method according to claim 1, characterized in that: The motion state is a falling state, The constructing of the target gravity detection ray according to the motion state includes: constructing the target gravity detection ray from the center position of the virtual character along the current speed direction of the virtual character; The step of performing collision detection between the target gravity detection ray and the virtual scene terrain and determining the target gravity state based on the collision detection result includes: The collision result between the target gravity detection ray and the virtual scene terrain is calculated according to a preset collision detection algorithm, and the target gravity state and falling point of the virtual character are determined according to the collision result.
5. The method according to claim 4, characterized in that The step of calculating the collision result between the target gravity detection ray and the virtual scene terrain according to a preset collision detection algorithm, and determining the target gravity state and falling point of the virtual character according to the collision result, comprises: After constructing the target gravity detection ray, obtaining a collision result between the target gravity detection ray and the virtual scene terrain; the collision result includes a collision intersection point and a motion trajectory tangent line at the collision intersection point; The collision intersection in the collision result is used as the falling point, and the normal direction of the plane where the falling point is located is used as the target gravity direction.
6. The method according to claim 1 or 2, characterized in that: The step of obtaining the motion state of the virtual character in the virtual scene and determining the target gravity detection ray according to the motion state further includes: If the terrain of the virtual scene is a rugged surface, target gravity detection rays are arranged in the horizontal and vertical directions with the virtual character as the center, and a target gravity detection ray dot matrix is constructed by a plurality of the target gravity detection rays; A collision result set between the target gravity detection ray dot matrix and the virtual scene terrain is calculated according to a preset collision detection algorithm, and a target gravity state of the virtual character is determined according to a combination of the collision results and preset result screening conditions.
7. The method according to claim 1, characterized in that The motion state is rotational movement, and the virtual scene terrain is a rotating terrain; The step of constructing a target gravity detection ray according to the motion state includes: Determine the rotation angle of the virtual character; If the rotation angle is greater than the angle threshold, multiple target gravity states are determined by interpolation; If the rotation angle is not greater than the angle threshold, the tangent direction of the rotation direction is used as the target gravity state.
8. The method according to claim 4, characterized in that Also includes: When the virtual character is in a falling state, obtaining a current falling position of the virtual character; Determining an actual falling distance according to the falling starting position and the current falling position; If the actual falling distance reaches the preset falling threshold, the target gravity of the virtual character in the falling direction is restored, and the horizontal speed of the virtual character is eliminated.
9. The method according to claim 1, characterized in that: After calculating the target gravity of the virtual character in the virtual scene terrain that matches the current motion state of the virtual character using the target gravity detection ray, the method further includes: In response to a skill control operation on the virtual character, determining whether a skill display effect is affected by target gravity and / or environmental gravity; If the judgment result is that the skill display effect is not affected by the target gravity, the skill display effect is realized according to the original skill parameters; If the result of the judgment is that the skill display effect is only affected by the target gravity, the skill display effect is modified according to the target gravity state and size; If the judgment result is that the skill display effect is affected by the target gravity and the environmental gravity, the skill display and effect are corrected according to the direction and magnitude of the superposition of the target gravity and the environmental gravity.
10. An electronic device comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, at least one program, a code set or an instruction set is loaded and executed by the processor to implement the method according to any one of claims 1 to 9.
11. A computer-readable medium having stored thereon at least one instruction, at least one program, code set or instruction set, wherein the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the method according to any one of claims 1 to 9.
Citation Information
Cited By
Virtual character climbing control method and device, electronic equipment and storage medium
CN120860600A
Game gravity effect simulation method, electronic equipment and medium
CN121513454A