Virtual character visual angle adjusting method and device and medium
By calculating and rotating the perspective of the virtual character and matching the target gravity direction, the problem of viewing angle adjustment under the gravity changes of the virtual character is solved, and the immersion and user experience of the game are improved.
Patent Information
- Application Number
- CN202411310657.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-01-10
AI Technical Summary
In the game, when the gravity direction of the virtual character changes, the camera's viewing angle is difficult to adapt to the new gravity direction, resulting in insufficient immersion in the game and poor user experience.
By responding to the change of gravity state of the virtual character, calculate and rotate its view angle to match the target gravity direction, calculate the target view angle using the three-dimensional coordinate system and the countergravity direction to achieve dynamic adjustment of the view angle, independent of the world coordinate system.
Real-time consistent adjustment of virtual character perspective and gravity direction is achieved, improving the immersion and user experience of the game, and avoiding the complexity and inconvenience in traditional methods.
Smart Images

Figure CN119280821A_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 adjusting the perspective 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 of space or the moon can be simulated. For another example, a virtual character with special skills can walk on a vertical wall. However, after adjusting the gravity of the virtual character, a problem that follows is that the camera perspective also needs to change synchronously, but the angle calculation of the traditional character camera uses the world coordinate system control. The change angle in the world coordinate system is also the change angle of the camera. Once the gravity direction of the character is modified, and the world coordinate system is fixed, the character camera is difficult to adaptively control, and the character's perspective cannot adapt to the perspective changes in the new gravity direction, resulting in insufficient game immersion under gravity changes and poor user experience. Therefore, there is a need for a perspective change solution that can easily adjust the virtual characters in the game to adapt to gravity changes. Summary of the invention
[0004] The embodiments of the present invention provide a method, a device and a medium for adjusting the viewing angle of a virtual character, so as to realize a solution for conveniently adjusting the viewing angle of a virtual character in a game.
[0005] In a first aspect, an embodiment of the present invention provides a method for adjusting a virtual character's viewing angle, the method comprising:
[0006] responding to a change instruction of the gravity state of the virtual character, the gravity state including at least a current gravity direction and / or a target gravity direction of the virtual character;
[0007] On the virtual scene terrain where the virtual character moves, the current perspective of the virtual character is rotated to the target perspective according to the target gravity direction of the virtual character; wherein the current perspective is a first conventional perspective under the current gravity direction, and the target perspective is a second conventional perspective under the target gravity direction.
[0008] Optionally, rotating the current perspective of the virtual character to a target perspective according to the target gravity direction of the virtual character on the virtual scene terrain where the virtual character moves includes:
[0009] If the motion state of the virtual character is a moving state, determining a first target gravity direction of the virtual character;
[0010] Determine a first anti-gravity direction opposite to the first target gravity direction; and determine a first transverse coordinate axis direction in the three-dimensional coordinate system where the virtual character is located; wherein the three-dimensional coordinate system where the virtual character is located is a coordinate system established with the virtual character as the origin;
[0011] Calculating a first target viewing angle using the first anti-gravity direction and the first transverse coordinate axis direction;
[0012] The current perspective of the virtual character is rotated to the first target perspective.
[0013] Optionally, on the virtual scene terrain where the virtual character moves, rotating the current perspective of the virtual character to a target perspective according to the target gravity direction of the virtual character comprises:
[0014] If the motion state of the virtual character is a falling state, determining a second target gravity direction of the virtual character according to a tangent direction of the falling motion trajectory of the virtual character;
[0015] Determine a second anti-gravity direction opposite to the second target gravity direction; and determine a second transverse coordinate axis direction in the three-dimensional coordinate system where the virtual character is located; wherein the three-dimensional coordinate system where the virtual character is located is a coordinate system established with the virtual character as the origin;
[0016] Calculating a second target viewing angle using the second anti-gravity direction and the second transverse coordinate axis direction;
[0017] The current perspective of the virtual character is rotated to the second target perspective.
[0018] Optionally, on the virtual scene terrain where the virtual character moves, rotating the current perspective of the virtual character to a target perspective according to the target gravity direction of the virtual character comprises:
[0019] If the motion state of the virtual character is a continuous motion state, determining a third target gravity direction of the virtual character according to any sub-rough surface of the virtual character in the rough terrain;
[0020] Determining a third anti-gravity direction opposite to the third target gravity direction; and determining a third transverse coordinate axis direction in the three-dimensional coordinate system where the virtual character is located;
[0021] Calculating a third target viewing angle using the third anti-gravity direction and the third transverse coordinate axis direction;
[0022] The current viewing angle of the virtual character is rotated to the third target viewing angle.
[0023] Optionally, it also includes:
[0024] Obtaining a camera angle before changing the gravity of the virtual character;
[0025] Determine the world coordinates of the camera in the world coordinate system;
[0026] The rotation viewing angle is calculated based on the camera angle and the world coordinates.
[0027] Optionally, rotating the current perspective of the virtual character to a target perspective includes:
[0028] The rotational viewing angle when the user controls the viewing angle of the virtual character is obtained, and the second normal viewing angle and the rotational viewing angle are calculated by quaternion multiplication to obtain a target lens viewing angle representing the current viewing angle of the virtual character that meets the needs of the player;
[0029] The current viewing angle of the virtual character is rotated to the target lens viewing angle.
[0030] Optionally, it also includes:
[0031] Get the current gravity state in the virtual scene;
[0032] Determining a target gravity state of the virtual character after changing gravity;
[0033] Determine the angle difference between the current gravity state and the target gravity state;
[0034] When the angle difference is greater than an angle threshold, determining that the gravity of the virtual character has changed;
[0035] When the angle difference is not greater than the angle threshold, it is determined that the gravity of the virtual character does not change.
[0036] Optionally, determining the target gravity state of the virtual character after the gravity is changed includes:
[0037] Determine the motion state of the virtual character in the virtual scene;
[0038] determining a target gravity detection ray according to the motion state;
[0039] The target gravity detection ray is used to calculate a target gravity state of the virtual character in the virtual scene terrain that matches the current motion state of the virtual character.
[0040] 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 virtual character perspective adjustment method according to the first aspect.
[0041] 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 virtual character perspective adjustment method according to the first aspect.
[0042] 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. The virtual character can also realize various action skills in the virtual environment. In order to meet the diverse needs of users, the gravity direction of the virtual character can be adjusted according to the user's needs. After adjusting the gravity direction, the perspective direction of the virtual character also needs to be adjusted accordingly. If the gravity of the virtual character controlled by the player changes, the target perspective of the virtual character in the virtual scene after the gravity direction is changed is determined according to the gravity state of the virtual character; and then the current perspective of the virtual character is rotated to the target perspective. In the above manner, after determining that the gravity direction of the virtual character has changed, a basic perspective that does not depend on the world coordinate system will be established for the user, and the target perspective is calculated using the basic perspective and the newly established coordinate system. Without the need to adjust the basic parameters of the game engine, the virtual character perspective adjustment requirements can be met, and this adjustment method has good consistency with the change in gravity direction. Thus, users can get a better gaming experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] 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.
[0044] Figure 1 A schematic diagram of a flow chart of a method for adjusting the perspective of a virtual character provided in an embodiment of the present application;
[0045] Figure 2 A schematic diagram of a moving target gravity detection ray for illustrating an embodiment of the present application;
[0046] Figure 3a A schematic diagram of a falling target gravity detection ray provided in an embodiment of the present application;
[0047] Figure 3b A schematic diagram of another target gravity detection ray array provided in an embodiment of the present application;
[0048] Figure 4 A schematic diagram of a four-probe calculation scheme proposed in an embodiment of the present application;
[0049] Figure 5a , 5b 5c is a schematic diagram of a target gravity detection ray array provided in an embodiment of the present application;
[0050] Figure 6 A schematic diagram of the actual falling distance provided in the embodiment of the present application;
[0051] Figure 7 A schematic diagram of the structure of a virtual character viewing angle adjustment device provided in an embodiment of the present application;
[0052] Figure 8 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0053] 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.
[0054] 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.
[0055] 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.
[0056] In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.
[0057] With the development of game technology, in order to meet the diverse game experience of users, various innovations are made in the game scene, 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 walls. After adjusting the gravity of the virtual character, the perspective presented by the virtual character also needs to be adjusted accordingly. The existing perspective is controlled based on the world coordinate system, and the adjustment work is complicated. Therefore, a solution is needed that can realize convenient adjustment of the perspective of the virtual character in the game.
[0058] Terminology explanation:
[0059] 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.
[0060] 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.
[0061] UKismetSystemLibrary: A public method library in UE4. The detection methods used in this solution are all derived from this library.
[0062] Pitch: A component of the object's rotation angle, which refers to the object's pitch angle.
[0063] Yaw: A component of the object's rotation angle, which refers to the object's horizontal rotation angle.
[0064] Roll: A component of an object's rotation angle, referring to the object's rolling angle.
[0065] ControlRotation: The angle of the player's controller, used to determine the player's current movement direction and camera orientation.
[0066] RotationBase: The base rotation of the player, calculated using the current gravity. It only changes if gravity changes.
[0067] 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.
[0068] Quat: Quaternion, often used to represent rotation in 3D space.
[0069] 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.
[0070] 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.
[0071] 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.
[0072] To facilitate understanding, specific embodiments will be used as examples below.
[0073] like Figure 1 A flowchart of a method for adjusting the perspective of a virtual character provided in an embodiment of the present application. The method for adjusting the perspective of a virtual character is applied to an open world game scene, providing users with a rich and diverse exploration space with a better interactive effect. Figure 1 As can be seen in the figure, the method specifically includes the following steps:
[0074] Step 101: responding to an instruction to change the gravity state of the virtual character, the gravity state at least including the current gravity direction and / or the target gravity direction of the virtual character.
[0075] Step 102: On the virtual scene terrain where the virtual character is moving, rotate the current perspective of the virtual character to the target perspective according to the target gravity direction of the virtual character; wherein the current perspective is a first conventional perspective under the current gravity direction, and the target perspective is a second conventional perspective under the target gravity direction.
[0076] In practical applications, the instruction for changing the gravity state of the virtual character may be a change instruction triggered by a change in the terrain of the virtual environment, or a change instruction triggered by a change in the motion state of the virtual character. The change in the gravity state may be a change in the direction of gravity and / or a change in the magnitude of gravity. Among them, the change in the terrain of the virtual environment may be understood as a change from a ground plane to a vertical wall, from a ground plane to a cliff, from a ground plane to a curved surface, and other terrain scenes. There may be many changes in the motion state of the virtual character, including but not limited to: a translation state, a falling state, a jumping state, a rotation state, and the like. Furthermore, the corresponding target gravity state may be detected according to the motion state, which is specifically illustrated in the following embodiments.
[0077] The current gravity here refers to the gravity before the gravity state changes, and the target gravity refers to the gravity state that the virtual character is about to change to. For example, if the virtual character walks from the ground to a vertical wall, the gravity direction on the ground is the current gravity direction, and the gravity direction pointing to the vertical wall after walking to the vertical wall is the target gravity direction.
[0078] After detecting or judging that the gravity state of the virtual character has changed and determining the target gravity direction that the virtual character will reach or has reached, it means that the posture of the virtual character has changed. In order to allow game users to obtain a better game perspective, the perspective needs to be adjusted synchronously with gravity. That is, the perspective of the virtual character is rotated from the current perspective to the target perspective.
[0079] The current viewing angle mentioned here is the first conventional viewing angle under the current gravity direction. For example, if the current virtual character is on the ground plane, the current viewing angle is the first conventional viewing angle parallel to the ground plane. The first conventional viewing angle mentioned here is the basic viewing angle without user control. The user can control the viewing angle (rotation, pitch angle adjustment, etc.) based on the first conventional viewing angle. The target viewing angle mentioned here is the second conventional viewing angle under the target gravity direction. For example, if the current virtual character is on a vertical wall, the target viewing angle is the second conventional viewing angle parallel to the vertical wall. The second conventional viewing angle mentioned here is the basic viewing angle without user control. The user can control the viewing angle (rotation, pitch angle adjustment, etc.) based on the second conventional viewing angle.
[0080] Through the above scheme, when the virtual character's gravity direction changes during the execution of a game task, the virtual character's viewing angle direction is kept consistent with the virtual character's gravity direction in real time and adjusted synchronously with the gravity direction, thereby satisfying the user's demand for adjusting the gravity state while keeping the viewing angle consistent with it.
[0081] In one or more embodiments of the present application, on the virtual scene terrain where the virtual character moves, according to the target gravity direction of the virtual character, the current perspective of the virtual character is rotated to the target perspective, including: if the motion state of the virtual character is a moving state, determining the first target gravity direction of the virtual character. Determining a first anti-gravity direction opposite to the first target gravity direction; and determining a first horizontal coordinate axis direction in the three-dimensional coordinate system where the virtual character is located; wherein the three-dimensional coordinate system where the virtual character is located is a coordinate system established with the virtual character as the origin. Calculating the first target perspective using the first anti-gravity direction and the first horizontal coordinate axis direction. Rotating the current perspective of the virtual character to the first target perspective.
[0082] When calculating the target perspective (including the first target perspective, the second target perspective, and the third target perspective), it is necessary to calculate according to the actual situation. That is to say, in some cases, the game user controls the rotation perspective of the virtual character through a control device such as a mouse or a game controller. In some cases, the user does not control the perspective of the virtual character at the current moment. Generally speaking, when the gravity state changes and the target perspective is adjusted, the user's rotation perspective parameters under the current gravity state will not be passed to the perspective parameters under the target gravity state. After the perspective switch is completed, it is determined whether the user has provided the rotation perspective parameters.
[0083] It is assumed here that after the perspective switching is completed, that is, during the calculation of the target perspective, the user controls the virtual character to rotate the perspective. The perspective of the virtual character can be determined in the following way: obtain the camera angle before changing the gravity of the virtual character; determine the world coordinates of the camera in the world coordinate system; calculate the rotated perspective based on the camera angle and the world coordinates. Wherein, rotating the current perspective of the virtual character to the target perspective includes: obtaining the rotated perspective when the user controls the perspective of the virtual character, calculating the second normal perspective of the virtual character and the rotated perspective using quaternion multiplication to obtain a target perspective representing the current perspective of the virtual character that meets the player's needs; rotating the current perspective of the virtual character to the target perspective (including the first target perspective, the second target perspective, and the third target perspective). The specific implementation process will be described in the following embodiments, and will not be repeated here.
[0084] In game scenes with variable gravity, such as when characters can attach to walls or walk on walls, or in low-gravity environments such as the moon, traditional camera perspective control methods (based on the Yaw and Pitch components of the world coordinate system) will no longer apply. Therefore, a new mechanism needs to be introduced to dynamically adjust the camera perspective to match the character's actual perception and orientation. When adjusting the perspective of a virtual character based on the target gravity direction, it is necessary to first establish a three-dimensional coordinate system based on the virtual character, and then calculate the target perspective, as follows:
[0085] The base orientation direction of the virtual character RotationBase is used to describe the current base orientation direction of the virtual character in the newly created three-dimensional coordinate system. It is calculated based on the character's gravity perception and the viewing direction in the newly created three-dimensional coordinate system.
[0086] First, you need to know the current direction of gravity. This can be obtained through the game engine's physics system or specific algorithms.
[0087] Determine the character's Y-axis direction: In most games, the character's Y-axis usually represents the vertical direction (even though the character may not be upright in the actual game, such as when it is attached to a wall). However, in this solution, it can be assumed that the Y-axis is relatively stable during translation and used as a reference direction.
[0088] Calculate RotationBase: Use these two directions (the opposite direction of gravity and the direction of the character's Y axis) to create a rotation matrix (or equivalent rotation representation, such as a quaternion). This rotation matrix / quaternion is the RotationBase, which represents the current base orientation of the character.
[0089] ViewRotation is used to represent the final viewing angle of the player, which is calculated based on the base orientation RotationBase and the player's ControlRotation (controller viewing angle). The details are as follows:
[0090] The player controls the rotation angle of the virtual character through an input device (such as a mouse, keyboard, or game controller). It usually contains Yaw (horizontal rotation angle) and Pitch (pitch angle) components, but in this solution, it is regarded as an overall rotation representation (such as quaternion).
[0091] Using RotationBase as the base orientation in the base coordinate system means that any subsequent rotations will be based on this new 3D coordinate system. Apply ControlRotation to RotationBase via quaternion multiplication (or other equivalent rotation combination methods). The result of this multiplication operation is a new rotation representation that combines the character's base orientation with the player's view control.
[0092] Finally, by overriding the player's GetViewRotation method (or similar mechanism), this combined rotation representation is returned as the player's target perspective (that is, the first target perspective, the second target perspective, and the third target perspective). It should be noted that if there is a parameter rotation perspective ControlRotation, the target perspective will be calculated. If the user does not provide a rotation perspective, the final ViewRotation is the basic perspective in the newly created three-dimensional coordinate system.
[0093] For ease of understanding, the following is an example of a specific embodiment to illustrate the perspective realization scheme. The calculation process of the perspective direction under target gravity is as follows:
[0094] (1) Calculation of RotationBase:
[0095] After the gravity of the virtual character is changed from the original environment gravity to the target gravity, a problem that follows is that the camera perspective also needs to change synchronously. However, in the angle calculation of the traditional character (that is, the virtual character) camera, ControlRotation is used to control the camera angle, and ControlRotation uses the world coordinate system, that is, its Yaw component corresponds to the horizontal angle in the world coordinate system, which is also the horizontal angle of the camera, and the Pitch component corresponds to the pitch angle in the world coordinate system, which is also the pitch angle of the camera. Once the character's gravity direction is modified (for example, from the environment gravity direction perpendicular to the ground to the target gravity direction parallel to the ground), the Yaw and Pitch components in ControlRotation can no longer be used to control the character's camera horizontal and pitch angles, so the RotationBase property is introduced to describe the character's current basic orientation.
[0096] Since the character does not need to move sideways in this solution (sideways movement in this solution is actually the character moving forward facing sideways), the Y axis of the character is more stable during translation, so the calculation method of the character's RotationBase is:
[0097] RotationBase = FRotationMatrix::MakeFromZY (opposite direction of gravity, character Y axis direction)
[0098] (2) Calculation of ViewRotation:
[0099] From quaternion multiplication, we can know that QuatA*QuatB=QuatC, where the geometric meaning of QuatC is the rotation angle obtained by rotating QuatB with QuatA as the reference coordinate system. Therefore, we can substitute the previously calculated RotationBase into QuatA and the player's ControlRotation into QuatB to obtain the camera angle after gravity adjustment. By overriding the player's GetViewRotation method, the result of RotationBase*ControlRotation is returned, which is the player's gravity-adjusted lens direction (that is, the target viewing angle).
[0100] It should be noted here that if the motion state of the virtual character is a moving state, the first target gravity direction of the virtual character is determined as follows:
[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 2 This is a schematic diagram of a moving target gravity detection ray for illustrating an embodiment of the present application. Figure 2 As can be seen in the figure, suppose that in the virtual scene of the current game, there is a virtual character ( Figure 2When the virtual character (the capsule represents the character) walks or runs, a ray is emitted from a certain distance above the character's capsule (above the character refers to a certain distance in the opposite direction of the character's current gravity) in the direction of the character's current moving speed, which 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 2 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, on the virtual scene terrain where the virtual character moves, according to the target gravity direction of the virtual character, the current perspective of the virtual character is rotated to the target perspective, including: if the movement state of the virtual character is a falling state, then according to the tangent direction of the falling motion trajectory of the virtual character, the second target gravity direction of the virtual character is determined. Determine a second anti-gravity direction opposite to the second target gravity direction; and determine the second horizontal coordinate axis direction in the three-dimensional coordinate system where the virtual character is located; wherein the three-dimensional coordinate system where the virtual character is located is a coordinate system established with the virtual character as the origin. Calculate the second target perspective using the second anti-gravity direction and the second horizontal coordinate axis direction. Rotate the current perspective of the virtual character to the second target perspective.
[0107] 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 the 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.
[0108] 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.
[0109] 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.
[0110] 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 second target gravity state of the virtual character and the falling point.
[0111] Based on the collision detection results, the system can further calculate the second target gravity state of the virtual character. In the falling scene, the second target gravity state often involves the character's transition from a free fall 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.).
[0112] For ease of understanding, the following example illustrates how to determine the target gravity direction in a falling state. Figure 3a A schematic diagram of a falling target gravity detection ray 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 on 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. 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 second target gravity state and the falling point are determined based on the collision result of 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 in the same way to determine the collision result.
[0113] In one or more embodiments of the present application, when the motion state is a jumping state and / or a falling state, the character skill of the virtual character is analyzed and calculated according to the target gravity direction based on the motion state and the virtual scene terrain to obtain the target character skill control parameter, including:
[0114] Determine whether the skill display effect of the character skill is affected by the first target gravity and the second target gravity, and / or environmental gravity;
[0115] If the judgment result is that the skill display effect is only affected by the first target gravity and the second target gravity, the character skill is projected onto the unit vectors corresponding to the first target gravity and the second target gravity respectively, and the skill display effect is corrected according to the direction and magnitude of the first target gravity and the second target gravity respectively;
[0116] If the judgment result is that the skill display effect is affected by the first target gravity, the second target gravity and the environmental gravity, the character skill is projected onto the unit vectors corresponding to the first target gravity and the second target gravity respectively, and the skill display and effect are corrected according to the direction and magnitude after the first target gravity, the second target gravity and the environmental gravity are superimposed;
[0117] If the judgment result is that the skill display effect is not affected by the target gravity, the skill display effect is achieved according to the original skill parameters.
[0118] In actual applications, the character skills of the virtual character will also be adjusted accordingly when the gravity state is adjusted. Of course, the specific adjustment needs to be differentiated according to the skill type. That is, some skills are only affected by the first target gravity and the second target gravity. That is, when falling or jumping, the character skills are adjusted accordingly according to the second target gravity and the first target gravity.
[0119] If the character's skills are affected by the first target gravity, the second target gravity and the environment gravity at the same time, the three gravity will be used to adjust the character's skills. For specific ways to adjust the character's skills, please refer to the translation state and Figure 3a The corresponding embodiments will not be repeated here.
[0120] Apart from Figure 2 and Figure 3a In addition to the target gravity direction determination scheme shown, there are other determination methods, which will be illustrated below through specific embodiments.
[0121] Figure 3b A schematic diagram of another target gravity detection ray array provided in an embodiment of the present application. Figure 3a 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 3b A week of X-ray testing was performed on the center of the capsule body of the virtual character (i.e. Figure 3b 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 Figure 3a The solution shown or Figure 3b The solution shown can better meet the diverse needs of game technicians.
[0123] Through the above scheme, when the virtual character is in a falling state, the target gravity direction during the falling process is determined by the target gravity detection ray, and then the perspective of the virtual character is switched from the current perspective to the second target perspective according to the target gravity direction, so that the perspective of the virtual character can be adjusted synchronously with the gravity direction.
[0124] 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 4As 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.
[0125] 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.
[0126] 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.
[0127] 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.
[0128] 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.
[0129] 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.
[0130] 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.
[0131] In one or more embodiments of the present application, on the virtual scene terrain where the virtual character moves, the current perspective of the virtual character is rotated to the target perspective according to the target gravity direction of the virtual character, including: if the motion state of the virtual character is a continuous motion state, determining the third target gravity direction of the virtual character according to any sub-rough surface of the virtual character in the rugged terrain; determining a third anti-gravity direction opposite to the third target gravity direction; and determining the direction of the third horizontal coordinate axis in the three-dimensional coordinate system where the virtual character is located; calculating the third target perspective using the third anti-gravity direction and the third horizontal coordinate axis direction; and rotating the current perspective of the virtual character to the third target perspective.
[0132] 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 third target gravity is selected according to the weight value, and the third target gravity is calculated based on the target surface.
[0133] 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.
[0134] 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.
[0135] 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.
[0136] 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.
[0137] For the normals obtained by screening, weighted averaging is performed to determine their combined influence on the gravity of the third target. The weight distribution can be based on multiple factors, such as the size of the angle (the smaller the angle, the greater the weight), the area of the plane (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 direction of the gravity of the third target can be calculated.
[0138] In the target gravity detection ray dot 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 third 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 third target gravity state of the virtual character in the rugged terrain can be determined more accurately, thereby providing a more realistic and immersive gaming experience.
[0139] After determining the gravity direction of the third target gravity in the above manner, the third target perspective can be further calculated based on the three-dimensional coordinate system where the virtual character is located. The calculation process of the third target perspective can refer to the calculation process of the first target perspective, and will not be repeated here.
[0140] Through the above scheme, when the virtual character is in a moving state on a rugged surface, the target gravity direction during the movement on the rugged surface is determined by the target gravity detection ray, and then the perspective of the virtual character is switched from the current perspective to the third target perspective according to the target gravity direction, so that the perspective of the virtual character can be adjusted synchronously with the gravity direction.
[0141] In one or more embodiments of the present application, it also includes: obtaining the current gravity state in the virtual scene; determining the target gravity state of the virtual character after the gravity is changed. Determine the angle difference between the current gravity state and the target gravity state; when the angle difference is greater than an angle threshold, determine that the gravity of the virtual character has changed; when the angle difference is not greater than the angle threshold, determine that the gravity of the virtual character has not changed. Wherein, determining the target gravity state of the virtual character after the gravity is changed includes: determining the motion state of the virtual character in the virtual scene; determining a target gravity detection ray based on the motion state; and using the target gravity detection ray to calculate the target gravity state of the virtual character in the virtual scene terrain that matches the current motion state of the virtual character.
[0142] In actual applications, the gravity state of the virtual character may change frequently (for example, when moving on a rugged surface, the target gravity direction of the virtual character will be adjusted frequently). In order to allow users to obtain a more stable visual effect, the virtual character's gravity will be considered to have changed effectively only when the angle difference between the current gravity direction and the target gravity direction reaches a certain angle threshold, and the corresponding viewing angle will be adjusted at this time. Conversely, if the angle difference between the current gravity direction and the target gravity direction does not reach a certain angle threshold, the gravity change is considered invalid, that is, the gravity direction can be adjusted, but the corresponding viewing angle direction may not be adjusted synchronously, because the angle difference between the viewing angle corresponding to the current gravity direction and the viewing angle corresponding to the target gravity direction is small. In order to allow users to obtain a stable visual effect, the viewing angle may not be adjusted.
[0143] The related scheme of using target gravity detection ray to calculate target gravity direction has been described in the previous article. Figure 2 Each embodiment in FIG. 5 is described in detail, and will not be repeated here.
[0144] When the virtual character is in a falling state, the current falling position of the virtual character is obtained; the actual falling distance is determined according to the falling starting position and the current falling position; if the actual falling distance reaches a preset falling threshold, the target gravity of the virtual character in the falling direction is restored, the horizontal speed of the virtual character is eliminated, and the restored target movement and target skill along the direction of the environmental gravity are determined.
[0145] like Figure 6 This is a schematic diagram of the actual falling distance provided in the embodiment of the present application. Figure 6As 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.
[0146] 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. When the target gravity is restored, the horizontal speed of the virtual character will also be eliminated to avoid the effect of the virtual character flying forward continuously.
[0147] Based on the same idea, the embodiment of the present application also provides a virtual character perspective adjustment device. Figure 7 A schematic diagram of a virtual character perspective adjustment device provided in an embodiment of the present application. The method comprises:
[0148] An instruction detection module 71, for responding to an instruction of a change in the gravity state of the virtual character, wherein the gravity state at least includes a current gravity direction and / or a target gravity direction of the virtual character;
[0149] The perspective adjustment module 72 is used to rotate the current perspective of the virtual character to the target perspective according to the target gravity direction of the virtual character on the virtual scene terrain where the virtual character moves; wherein the current perspective is the first normal perspective under the current gravity direction, and the target perspective is the second normal perspective under the target gravity direction.
[0150] A viewing angle adjustment module 72, configured to determine a first target gravity direction of the virtual character if the motion state of the virtual character is a moving state;
[0151] Determine a first anti-gravity direction opposite to the first target gravity direction; and determine a first transverse coordinate axis direction in the three-dimensional coordinate system where the virtual character is located; wherein the three-dimensional coordinate system where the virtual character is located is a coordinate system established with the virtual character as the origin;
[0152] Calculating a first target viewing angle using the first anti-gravity direction and the first transverse coordinate axis direction;
[0153] The current perspective of the virtual character is rotated to the first target perspective.
[0154] A viewing angle adjustment module 72, configured to determine a second target gravity direction of the virtual character according to a tangent direction of the falling motion trajectory of the virtual character if the motion state of the virtual character is a falling state;
[0155] Determine a second anti-gravity direction opposite to the second target gravity direction; and determine a second transverse coordinate axis direction in the three-dimensional coordinate system where the virtual character is located; wherein the three-dimensional coordinate system where the virtual character is located is a coordinate system established with the virtual character as the origin;
[0156] Calculating a second target viewing angle using the second anti-gravity direction and the second transverse coordinate axis direction;
[0157] The current perspective of the virtual character is rotated to the second target perspective.
[0158] A perspective adjustment module 72, configured to determine a third target gravity direction of the virtual character according to any sub-rough surface of the virtual character in the rough terrain if the motion state of the virtual character is a continuous motion state;
[0159] Determining a third anti-gravity direction opposite to the third target gravity direction; and determining a third transverse coordinate axis direction in the three-dimensional coordinate system where the virtual character is located;
[0160] Calculating a third target viewing angle using the third anti-gravity direction and the third transverse coordinate axis direction;
[0161] The current viewing angle of the virtual character is rotated to the third target viewing angle.
[0162] A viewing angle adjustment module 72, for obtaining a camera angle before changing the gravity of the virtual character;
[0163] Determine the world coordinates of the camera in the world coordinate system;
[0164] The rotation viewing angle is calculated based on the camera angle and the world coordinates.
[0165] A perspective adjustment module 72 is used to obtain the rotation perspective when the user controls the perspective of the virtual character, and calculate the second normal perspective and the rotation perspective by quaternion multiplication to obtain a target lens perspective representing the current perspective of the virtual character that meets the needs of the player;
[0166] The current viewing angle of the virtual character is rotated to the target lens viewing angle.
[0167] Optionally, it also includes an acquisition module 73, which is used to acquire the current gravity state in the virtual scene;
[0168] Determining a target gravity state of the virtual character after changing gravity;
[0169] Determine the angle difference between the current gravity state and the target gravity state;
[0170] When the angle difference is greater than an angle threshold, determining that the gravity of the virtual character has changed;
[0171] When the angle difference is not greater than the angle threshold, it is determined that the gravity of the virtual character does not change.
[0172] An acquisition module 73 is used to determine the motion state of the virtual character in the virtual scene;
[0173] determining a target gravity detection ray according to the motion state;
[0174] The target gravity detection ray is used to calculate a target gravity state of the virtual character in the virtual scene terrain that matches the current motion state of the virtual character.
[0175] It should be noted that the functional units contained in the various modules mentioned in the foregoing text can realize the various functions described in the foregoing intelligent dialogue system, and will not be repeated here.
[0176] In one possible design, the above Figure 8 The structure of the intelligent dialogue 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.
[0177] 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 virtual character perspective adjustment method.
[0178] 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.
[0179] 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.
[0180] 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 adjusting the perspective of a virtual character, characterized in that: The method comprises: responding to a change instruction of the gravity state of the virtual character, the gravity state including at least a current gravity direction and / or a target gravity direction of the virtual character; On the virtual scene terrain where the virtual character moves, the current perspective of the virtual character is rotated to the target perspective according to the target gravity direction of the virtual character; wherein the current perspective is a first conventional perspective under the current gravity direction, and the target perspective is a second conventional perspective under the target gravity direction.
2. The method according to claim 1, characterized in that The step of rotating the current perspective of the virtual character to a target perspective according to the target gravity direction of the virtual character on the virtual scene terrain where the virtual character moves comprises: If the motion state of the virtual character is a moving state, determining a first target gravity direction of the virtual character; Determine a first anti-gravity direction opposite to the first target gravity direction; and determine a first transverse coordinate axis direction in the three-dimensional coordinate system where the virtual character is located; wherein the three-dimensional coordinate system where the virtual character is located is a coordinate system established with the virtual character as the origin; Calculating a first target viewing angle using the first anti-gravity direction and the first transverse coordinate axis direction; The current perspective of the virtual character is rotated to the first target perspective.
3. The method according to claim 1, characterized in that On the virtual scene terrain where the virtual character moves, according to the target gravity direction of the virtual character, the current perspective of the virtual character is rotated to the target perspective, including: If the motion state of the virtual character is a falling state, determining a second target gravity direction of the virtual character according to a tangent direction of the falling motion trajectory of the virtual character; Determine a second anti-gravity direction opposite to the second target gravity direction; and determine a second transverse coordinate axis direction in the three-dimensional coordinate system where the virtual character is located; wherein the three-dimensional coordinate system where the virtual character is located is a coordinate system established with the virtual character as the origin; Calculating a second target viewing angle using the second anti-gravity direction and the second transverse coordinate axis direction; The current viewing angle of the virtual character is rotated to the second target viewing angle.
4. The method according to claim 1, characterized in that: On the virtual scene terrain where the virtual character moves, according to the target gravity direction of the virtual character, the current perspective of the virtual character is rotated to the target perspective, including: If the motion state of the virtual character is a continuous motion state, determining a third target gravity direction of the virtual character according to any sub-rough surface of the virtual character in the rough terrain; Determining a third anti-gravity direction opposite to the third target gravity direction; and determining a third transverse coordinate axis direction in the three-dimensional coordinate system where the virtual character is located; Calculating a third target viewing angle using the third anti-gravity direction and the third transverse coordinate axis direction; The current viewing angle of the virtual character is rotated to the third target viewing angle.
5. The method according to claim 1, characterized in that Also includes: Obtaining a camera angle before changing the gravity of the virtual character; Determine the world coordinates of the camera in the world coordinate system; The rotation viewing angle is calculated based on the camera angle and the world coordinates.
6. The method according to claim 5, characterized in that The step of rotating the current perspective of the virtual character to a target perspective includes: The rotational viewing angle when the user controls the viewing angle of the virtual character is obtained, and the second normal viewing angle and the rotational viewing angle are calculated by quaternion multiplication to obtain a target lens viewing angle representing the current viewing angle of the virtual character that meets the needs of the player; The current viewing angle of the virtual character is rotated to the target lens viewing angle.
7. The method according to claim 1, characterized in that Also includes: Get the current gravity state in the virtual scene; Determining a target gravity state of the virtual character after changing gravity; Determine the angle difference between the current gravity state and the target gravity state; When the angle difference is greater than an angle threshold, determining that the gravity of the virtual character has changed; When the angle difference is not greater than the angle threshold, it is determined that the gravity of the virtual character does not change.
8. The method according to claim 7, characterized in that The determining the target gravity state of the virtual character after the gravity is changed includes: Determine the motion state of the virtual character in the virtual scene; determining a target gravity detection ray according to the motion state; The target gravity detection ray is used to calculate a target gravity state of the virtual character in the virtual scene terrain that matches the current motion state of the virtual character.
9. 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 8.
10. 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 8.
Citation Information
Cited By
Role viewing angle conversion method and device, equipment and medium
CN120815333A
Role perspective conversion method and device, equipment and medium thereof
CN120815333B