Virtual character climbing control method and device, electronic equipment and storage medium
By detecting collision points using multi-directional spherical rays, the climbing posture of the virtual character is adjusted to precisely conform to the surface shape of the target, solving the problem of mismatch between climbing posture and surface shape in existing technologies and improving the stability and realism of virtual character climbing.
Patent Information
- Application Number
- CN202511150823.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-18
- Publication Date
- 2025-10-31
AI Technical Summary
Existing technologies struggle to accurately capture the geometric features of complex climbing objects during virtual character climbing, leading to a mismatch between posture adjustments and surface morphology, resulting in issues such as clipping or abrupt changes in orientation.
Multi-directional spherical rays are used to detect collision points. The climbing posture of the virtual character is adjusted to match the surface morphology of the climbing object. This includes firing spherical rays at the climbing object from at least three different positions to obtain the location information of the collision points, and adjusting the climbing posture based on this information.
It improves the climbing stability and movement continuity of virtual characters in complex terrain, enhances the realism and stability of game interaction, and avoids clipping or sudden changes in posture.
Smart Images

Figure CN120860600A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a virtual character climbing control method, device, electronic device, and storage medium. Background Technology
[0002] In 3D virtual scenes, the interaction between virtual characters and complex terrain or object surfaces is one of the core technologies for achieving an immersive gaming experience. However, existing technologies have significant limitations when characters perform climbing actions. Existing technologies often rely on simple ray detection, which struggles to accurately capture the geometric features of complex climbing objects. This leads to a mismatch between the virtual character's posture adjustments and the actual surface shape of the climbing object, resulting in unnatural phenomena such as clipping or sudden changes in orientation. Summary of the Invention
[0003] The main objective of this application is to propose a virtual character climbing control method, device, electronic device, and storage medium, which uses multi-directional spherical rays to detect collision points and adjusts the climbing posture of the virtual character to accurately conform to the geometry of the target surface.
[0004] This application provides a method for controlling climbing in a virtual character, including the following steps:
[0005] When the virtual character enters a climbing posture, based on the current position of the virtual character, spherical rays are emitted from at least three different positions toward the climbing object, resulting in at least three spherical rays;
[0006] When all three spherical rays detect a collision point on the climbing object, the position information of the collision point is obtained.
[0007] Based on the location information of the collision point, the climbing posture of the virtual character is adjusted to match the surface shape of the climbing object.
[0008] In one embodiment, the step of emitting spherical rays at the climbing object from at least three different locations, based on the current position of the virtual character, includes at least one of the following:
[0009] Using the center of the capsule of the virtual character as a reference, spherical rays are emitted towards the climbing object from at least three positions: upper left, upper right, lower left, and lower right.
[0010] Using the center of the capsule of the virtual character as a reference, spherical rays are emitted from six positions: upper left, upper right, lower left, lower right, and lower right towards the climbing object;
[0011] Using the center of the capsule of the virtual character as a reference, spherical rays are emitted towards the climbing object along six positions: upper left, middle left, lower left, upper right, middle right, and lower right.
[0012] Using the center of the capsule of the virtual character as a reference, spherical rays are emitted towards the climbing object at nine positions: upper left, upper right, upper left center, middle left center, middle right center, lower left center, and lower right center.
[0013] In one embodiment, adjusting the climbing posture of the virtual character to match the surface morphology of the climbing object based on the location information of the collision point includes:
[0014] The normal vector of the climbing object is determined based on the position information of the at least three collision points;
[0015] The orientation and position of the virtual character are calculated based on the normal vector.
[0016] In one embodiment, determining the normal vector of the climbing object based on the position information of the at least three collision points includes:
[0017] If there are three collision points, the perpendicular line to the plane containing the center line of the three collision points is determined as the normal vector of the climbing object.
[0018] If there are four collision points, the normal vector of the climbing object is obtained by cross-multiplying the vector from the lower left collision point to the upper right collision point with the vector from the lower right collision point to the upper left collision point.
[0019] If the number of collision points is six, the six collision points are divided into two groups, each group containing four collision points. The local normal vector is calculated by the cross product of the vectors of the four collision points in each group, and the average of the two groups of local normal vectors is taken as the normal vector of the climbing object.
[0020] If there are nine collision points, the nine collision points are divided into four groups, each group containing four collision points. The local normal vector is calculated by the cross product of the vectors of the four collision points in each group, and the average of the four local normal vectors is taken as the normal vector of the climbing object.
[0021] In one embodiment, calculating the facing and position of the virtual character based on the normal vector includes:
[0022] A new coordinate system for the virtual character is constructed based on the normal vector;
[0023] Under the new coordinate system, the position of the virtual character is corrected to obtain the new position of the virtual character.
[0024] In one embodiment, the method includes:
[0025] If the virtual character has no displacement input during the climbing process, the spherical ray detection of the current frame is disabled, and the normal vector of the previous frame and the climbing posture of the virtual character are used.
[0026] In one embodiment, the method further includes:
[0027] When the virtual character climbs along a preset direction, if a collision point is detected, the movement scaling factor is increased. The increased movement scaling factor is used to adjust the displacement step size of the virtual character per frame. If no collision point is detected, the movement scaling factor is decreased. If the climbing direction of the virtual character changes, the movement scaling factor is reset.
[0028] This application also provides a virtual character climbing control device, including:
[0029] The detection module is used to emit spherical rays from at least three different positions toward the climbing object when the virtual character enters a climbing posture, based on the current position of the virtual character, to obtain at least three spherical rays;
[0030] The processing module is used to acquire the position information of the collision point when all three spherical rays detect a collision point on the climbing object;
[0031] An adjustment module is used to adjust the climbing posture of the virtual character to match the surface morphology of the climbing object based on the position information of the collision point.
[0032] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described virtual character climbing control method.
[0033] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned virtual character climbing control method.
[0034] The virtual character climbing control method provided in this application involves, when the virtual character enters a climbing posture, emitting spherical rays from at least three different positions towards the climbing object, based on the virtual character's current position, to obtain at least three spherical rays; when all at least three spherical rays detect a collision point on the climbing object, acquiring the position information of the collision point; and adjusting the virtual character's climbing posture based on the collision point position information to match the surface morphology of the climbing object. This application uses multi-directional spherical rays to detect collision points and adjusts the virtual character's climbing posture to precisely conform to the geometry of the target surface. Attached Figure Description
[0035] Figure 1 This is one of the schematic diagrams of linear ray detection in existing technology;
[0036] Figure 2This is the second schematic diagram of linear ray detection in existing technology;
[0037] Figure 3 This is a flowchart illustrating the virtual character climbing control method provided in the embodiments of this application;
[0038] Figure 4 This is one of the schematic diagrams of spherical ray detection provided in the embodiments of this application;
[0039] Figure 5 This is the second schematic diagram of spherical ray detection provided in the embodiments of this application;
[0040] Figure 6 This is the third schematic diagram of spherical ray detection provided in the embodiments of this application;
[0041] Figure 7 This is the fourth schematic diagram of spherical ray detection provided in the embodiments of this application;
[0042] Figure 8 This is the fifth schematic diagram of spherical ray detection provided in the embodiments of this application;
[0043] Figure 9 This is one of the schematic diagrams provided in the embodiments of this application for determining the normal vector;
[0044] Figure 10 This is the second schematic diagram of determining the normal vector provided in the embodiments of this application;
[0045] Figure 11 This is the third schematic diagram of determining the normal vector provided in the embodiments of this application;
[0046] Figure 12 This is the fourth schematic diagram of determining the normal vector provided in the embodiments of this application;
[0047] Figure 13 This is the fifth schematic diagram of determining the normal vector provided in the embodiments of this application;
[0048] Figure 14 This is a schematic diagram of the coordinate system provided in the embodiments of this application;
[0049] Figure 15 This is a schematic diagram of the structure of the virtual character climbing control device provided in the embodiments of this application;
[0050] Figure 16 This is a schematic diagram of the structure of an embodiment of the electronic device provided in this application. Detailed Implementation
[0051] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0052] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0053] First Embodiment
[0054] A game engine is software used to develop video games. Game engines provide game developers with an editable development environment and standardized interfaces through pre-built toolsets, such as graphics rendering, physics simulation, audio processing, and animation control. This allows developers to quickly implement game development based on existing foundations, significantly lowering the development threshold and improving efficiency. Common game engines include Unity and UE4. UE4 (Unreal Engine 4) provides ray tracing technology, such as LineTrace, SphereTrace, CapsuleTrace, and BoxTrace, which can be used for physics collision detection, character movement logic, and obstacle detection. In the climbing function of virtual characters, current technology typically uses LineTrace to detect walls. However, LineTrace is sensitive to terrain undulations. For example, when there are pits or gaps with significant depth changes in the wall, LineTrace struggles to detect collision points, causing players to experience stuttering, clipping, or inability to navigate complex terrain while climbing or moving. Figure 1 As shown, LineTrace is used for wall climbing detection. When a linear ray is fired to a gap in the wall, if there is no solid collider or geometric occlusion at the gap, the ray will pass directly through the gap without triggering any collision detection, resulting in the inability to obtain a valid collision point location. For example, as... Figure 2As shown, when a virtual character encounters an outer corner greater than 90 degrees, LineTrace may fail to cover the area behind the corner due to the linear propagation characteristics of the rays. LineTrace only emits straight rays in a single direction, and outer corners (such as L-shaped walls) create detection blind spots at the corners. When the virtual character approaches the corner, the original ray direction may fail to reach the new wall surface because it is parallel to or deviates from it. For example, the linear nature of LineTrace makes it difficult to detect thin or irregularly shaped climbing objects. If the surface of the climbing object is too narrow (such as a thin column or thin wall) or has an irregular structure (such as steps or cutouts), the linear ray may fail to collide with the surface of the climbing object and return a result of collision point detection failure. When a virtual character attempts to climb a vertical thin column, if the linear ray is not directly facing the column surface or the column diameter is smaller than the ray length, collision detection cannot be achieved, making it difficult to identify a valid climbing contact surface, thus preventing the virtual character from climbing thin or irregularly shaped climbing objects. All of the above situations have affected the player's gaming experience.
[0055] To address the challenges of existing technologies, this application provides a virtual character climbing control method. The virtual character climbing control method provided in this application can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application implementing the virtual character climbing control method, but is not limited to the above forms.
[0056] The virtual character climbing control method provided in this application will be described in detail below with reference to the accompanying drawings and specific embodiments. Please refer to... Figure 3 Virtual character climbing control methods may include:
[0057] Step S1: When the virtual character enters the climbing posture, based on the current position of the virtual character, emit spherical rays from at least three different positions toward the climbing object to obtain at least three spherical rays.
[0058] Optionally, climbing refers to the mechanism by which players, controlling virtual characters, move in vertical or inclined spaces using body movements, tools, or environmental interactions. Climbing objects are interactive physical or virtual structures in the game that characters can attach to or use for leverage to achieve vertical / inclined movement. They typically possess support, grip points, or feedback characteristics, such as rock walls or building surfaces. When the virtual character enters a climbing posture, based on the virtual character's current position, spheres with physical radii are emitted from at least three different positions (e.g., upper left, upper right, lower left, lower right, etc.) towards the climbing object. By adjusting the radius and emission angle of the spheres, the presence of climbable collision points on the climbing object is detected.
[0059] Optionally, the radius of the spherical ray can be adapted to the range of motion of the virtual character's limbs and the surface features of the object being climbed. For example, the radius of the spherical ray can be set slightly larger than the minimum contact area of the virtual character or the object being climbed (such as the radius of the character's capsule or the reach of the hand), ensuring coverage of possible collision areas while avoiding false detections due to an excessively wide ray. It should be noted that the character's capsule is a common component used in game development to represent the physical collision shape of a character. It typically consists of two hemispheres and a cylinder, forming a capsule-like shape, used to detect collisions between the virtual character and the environment, trigger events, and control the movement of the virtual character.
[0060] Step S2: When at least three spherical rays detect collision points on the climbing object, obtain the location information of the collision points.
[0061] Optionally, when the spherical ray collides with the environment, the position information of the collision point, such as coordinates, is recorded. If collision detection fails, the radius of the spherical ray can be gradually increased within a preset range for re-detection until a collision point is detected. If no collision point can be detected within the preset range, the virtual character is controlled to revert to the position of the previous frame or exit the climbing process.
[0062] Step S3: Based on the location information of the collision point, adjust the climbing posture of the virtual character to match the surface shape of the climbing object.
[0063] Optionally, the normal direction of the collision surface of the climbing object is determined based on the detected collision point coordinates. This can be done based on three or four collision point coordinates, or by combining the average of normal data determined from multiple sets of local collision point coordinates. The orientation adjustment parameters of the virtual character are then determined using the normal direction of the climbing wall, enabling adaptive climbing posture adjustment for the virtual character in complex terrain. Thus, by fusing multi-directional spherical ray detection with collision data, the climbing stability and motion continuity of the character in concave, sloping, or discontinuous structures are significantly improved.
[0064] Optionally, such as Figure 4 As shown, in this embodiment of the application, when using a spherical ray to detect gaps on the surface of a climbing object, because the spherical ray has a radius, when the width of the gap is less than twice the radius (the width of the spherical ray path is twice the radius), the sphere cannot fall into the gap due to its own geometric dimensions, resulting in a collision point between the sphere's surface and the sides of the gap, thus outputting a collision result. Linear rays, however, have zero width, and when probing gaps, they will pass directly through the gap, leading to missed detections. Furthermore, this embodiment of the application can also improve the probability of collision point detection by adjusting the radius of the spherical ray, enabling virtual characters to climb on climbing objects with complex geometric characteristics (such as fences, openwork structures, etc.). Figure 5 As shown, spherical ray detection can achieve a wheel-like effect, allowing virtual characters to traverse small gaps during climbing. Using spherical ray detection, virtual characters can climb walls with gaps.
[0065] Optionally, such as Figure 6 As shown, when a virtual character approaches a corner, the spherical ray can obtain collision information through the contact points between the sphere's surface and the wall. At the outer corner where the left and right walls meet, if the character moves to the right, the left center of the sphere cannot directly detect the right wall due to the greater distance, but the edge of the spherical ray will still collide with the right wall, thus recording the collision point at that location. At this time, the normal direction of the collision point will deflect due to the offset of the contact position, making the normal corresponding to the left center of the sphere more inclined to point to the upper left, while the normal corresponding to the right center of the sphere is biased to the upper right. The difference in the normal direction allows the virtual character's body to naturally conform to the corner shape, ultimately presenting a smooth turning effect. Compared to linear rays in a single direction, the spherical ray, through redundant detection of edge contact points and normal correction, avoids clipping or abrupt posture changes caused by the loss of collision points at corners, improving the realism and stability of game interaction.
[0066] Optionally, such as Figure 7 As shown, when multiple spherical rays are densely arranged around a virtual character, such as with spacing smaller than the diameter, the detection area of the spherical rays forms a continuous envelope. When facing extremely thin climbing objects (such as railings, ropes, or metal poles), the edge of the sphere will always be in contact with the surface of the object. When the diameter of the climbing object is smaller than the radius of the spherical ray, the spherical ray can obtain collision information through the contact point at the edge region, avoiding missed detections due to the object's thinness. Furthermore, if the climbing object is too thin and collision detection fails, the radius of the spherical ray can be increased so that it envelops the entire climbing object, ensuring collision detection and eliminating the blind spot of linear rays for small climbing objects.
[0067] Optionally, in recessed walls, the wall geometry has minute bumps and depressions. If linear rays are used, even slight movements of the virtual character can cause the ray to hit a bump or fall into a depression, resulting in significant variations in the depth data of the detected collision point. Detection points in adjacent frames may traverse different bumps and depressions, causing abrupt changes in the direction of the calculated normal vector. For example... Figure 8 As shown, this embodiment of the application uses a spherical ray to detect the contact surface between the sphere and the wall. When the virtual character moves horizontally along the wall, as the sphere of the spherical ray sweeps across the concave area, multiple points where the sphere contacts the concave and convex areas can form a line (e.g., ...). Figure 8 (The black line shown in the image). Therefore, when a virtual character moves along a wall, even if the wall has slight bumps, the depth change of the collision point detected by the spherical ray is small, which can prevent the virtual character from emitting jitter or twitching during movement.
[0068] Optionally, when using capsule-shaped rays for detection, if the virtual character rotates, causing the launch point to shift, the contact surface of the capsule will change the collision point distribution due to axial deflection, such as changing from top contact to side contact. When using box-shaped rays for detection, when the launch point rotates, the edges or vertices of the box may preferentially contact the target, resulting in a collision shape completely different from the original direction. In other words, due to the asymmetry of their geometric structures, capsule-shaped rays and box-shaped rays will produce different collision results depending on the launch point, thus causing the virtual character's posture jitter or directional deviation.
[0069] The spherical ray used in this embodiment has central geometric symmetry. In collision detection, for any target position, regardless of the direction of the emission starting point on the surface of the sphere (such as front, back, left, right), as long as the center of the sphere moves in the same direction and emits the spherical ray, the position and contact shape of the collision point with the target will always be completely consistent. This makes the collision detection result unaffected by the offset of the emission starting point, thereby improving the accuracy of virtual character posture adjustment and the continuity of actions.
[0070] In one embodiment, based on the virtual character's current position, spherical rays are emitted towards the climbing object from at least three different locations, including at least one of the following:
[0071] Using the center of the virtual character's capsule as a reference, spherical rays are emitted towards the climbing object from at least three positions: upper left, upper right, lower left, and lower right.
[0072] Using the center of the virtual character's capsule as a reference, spherical rays are emitted from six positions: upper left, top right, upper right, lower left, bottom right, and lower right towards the climbing object;
[0073] Using the center of the virtual character's capsule as a reference, spherical rays are emitted from six positions: upper left, middle left, lower left, upper right, middle right, and lower right, toward the climbing object.
[0074] Using the center of the virtual character's capsule as a reference, spherical rays are emitted from nine positions: top left, top right, top left, center right, bottom left, bottom right, and bottom right, towards the climbing object.
[0075] Optionally, when the virtual character enters a climbing posture, if the climbing object is a regular plane, spherical rays can be emitted from at least three different positions around the center point of the virtual character's capsule body as a reference. The starting position of the spherical rays can be any three or four positions from the upper left, upper right, lower left, and lower right of the center point, covering the main contact areas between the virtual character and the climbing object (such as hands and feet). Then, the climbing posture of the virtual character on the climbing object can be quickly determined by the position information of the three or four collision points.
[0076] When a virtual character is climbing on complex or irregular surfaces, such as uneven surfaces, spherical rays can be emitted from six positions (upper left, upper right, lower left, lower right, and lower right) or six positions (upper left, middle left, lower left, upper right, middle right, and lower right) from the center point towards the climbing object, forming a hemispherical scan of the environment around the virtual character. For example, the spherical rays formed at the upper and lower positions are used to detect overhead obstacles or foot support, while the oblique spherical rays formed at the upper left and upper right positions capture the side contact points of the virtual character, ensuring stable attachment when the virtual character is climbing on complex or irregular surfaces.
[0077] When a virtual character is climbing on extreme terrain, spherical rays can be emitted from nine positions: top left, center left, bottom left, top right, center right, bottom right, top center, and bottom center, providing more comprehensive coverage of the climbing environment around the virtual character. For example, a spherical ray emitted from the center position can detect vertical collisions, while a spherical ray emitted from the center left or center right position can capture lateral support points, preventing the virtual character from losing balance during climbing due to missed detections on one side.
[0078] In this way, taking the center of the virtual character's capsule as a reference, spherical rays are emitted from multiple different positions to scan the climbing environment. The number and starting position of the spherical rays can be selected according to the complexity of the environment, ensuring that the virtual character can achieve a natural and stable climbing effect in any terrain.
[0079] In one embodiment, adjusting the climbing posture of the virtual character to match the surface morphology of the climbing object based on the location information of the collision point includes:
[0080] Determine the normal vector of the climbing object based on the location information of at least three collision points;
[0081] The virtual character's orientation and position are calculated based on the normal vector.
[0082] Optionally, spherical rays are emitted from at least three different locations, using the center of the virtual character's capsule as a reference, to obtain the positional information of at least three collision points. The normal vector of the climbing object's surface is calculated using the coordinates of these at least three collision points. This normal vector can be used to characterize the tilt direction and curvature features of the climbing object's surface. Then, the target orientation of the virtual character is calculated based on the normal vector through coordinate system transformation. For example, the rotation axis of the character's root skeleton can be aligned with the normal direction, keeping the character's body in contact with the climbing surface. If the climbing object is a slope, the character's posture will automatically adjust to a tilted standing position; if it is a right-angled wall, the character will rotate to a vertical climbing state.
[0083] In one embodiment, determining the normal vector of the climbing object based on the location information of at least three collision points includes:
[0084] If there are three collision points, the perpendicular line to the plane containing the line connecting the centers of the three collision points is determined as the normal vector of the climbing object.
[0085] If there are four collision points, the normal vector of the climbing object is obtained by cross-multiplying the vector from the lower left collision point to the upper right collision point with the vector from the lower right collision point to the upper left collision point.
[0086] If there are six collision points, divide the six collision points into two groups, each group containing four collision points. Calculate the local normal vector by the cross product of the vectors of the four collision points in each group, and take the average of the two local normal vectors as the normal vector of the climbing object.
[0087] If there are nine collision points, divide the nine collision points into four groups, with each group containing four collision points. Calculate the local normal vector by the cross product of the vectors of the four collision points in each group, and take the average of the four local normal vectors as the normal vector of the climbing object.
[0088] Optionally, if there are three collision points, obtain the three-dimensional coordinates of the three collision points, and determine a plane based on the three-dimensional coordinates, i.e., the surface plane of the climbing object. Construct two sets of vectors using the three-dimensional coordinates of the three collision points and perform a cross product operation to obtain the normal vector of the plane.
[0089] Optionally, such as Figure 9 As shown, if there are four collision points, obtain the three-dimensional coordinates of the four collision points, namely the three-dimensional coordinates of the bottom left collision point, the top right collision point, the bottom right collision point, and the top left collision point. Construct a set of vectors based on the bottom left to top right (e.g., Figure 9 (As shown by the red arrow in the middle), construct another set of vectors based on the bottom right to top left (as shown by the red arrow in the middle). Figure 9(As shown by the blue arrows in the middle), these two vectors represent the lateral and longitudinal extension directions of the surface of the climbing object, respectively. The normal vector is obtained by performing a cross product operation on the two sets of vectors. The plane formed by four-point collision data has higher geometric stability and symmetry than that formed by three-point collision data. By performing a cross product of two sets of diagonal vectors (such as bottom left → top right and bottom right → top left), the normal direction offset caused by local surface unevenness can be effectively suppressed, improving the detection accuracy under complex terrain (such as curved surfaces or irregular structures).
[0090] like Figure 10 As shown, for a wall with continuous prismatic protrusions, if the normal direction of the wall is calculated only based on local collision points (such as...), Figure 10 If the direction indicated by the red arrow is not consistent with the orientation of the wall structure, the normal direction may point to a local perpendicular direction on a slope, which is inconsistent with the overall orientation of the wall structure. This leads to a mismatch between the calculated pose of the virtual character and the actual surface structure. However, by using the cross product of two sets of vectors determined by the four collision points, a normal direction that better matches the overall structural characteristics can be calculated (e.g., ...). Figure 10 (as indicated by the blue arrow in the middle), thus ensuring that the virtual character faces the same physical characteristics as the object being climbed, enhancing the realism of the interaction and the stability of the movement.
[0091] Optionally, if there are six collision points, the six collision points can be divided into two groups, such as... Figure 11 Groups A and B as shown, or, as... Figure 12 Groups C and D, as shown, each contain four collision points. For each group of four points, two sets of vectors are constructed (e.g., the vectors from bottom left to top right and from bottom right to top left in group A). The local normal vector for each group is calculated using a cross product operation. The average of the two sets of local normal vectors is taken as the final normal vector of the climbing object. This effectively suppresses errors caused by local surface unevenness or noise in a single set of data, improving the stability of the normal direction.
[0092] Optionally, if there are nine collision points, the nine collision points can be divided into four groups according to their spatial distribution or geometric characteristics, such as... Figure 13 The groups E, F, G, and H shown each contain four collision points. Two sets of vectors are constructed for each group's four points (e.g., bottom left → top right and bottom right → top left), and the local normal vector for each group is calculated using a cross product operation. The average of the four local normal vectors is taken as the final normal vector for the climbing object. By fusing multiple sets of data, errors caused by local surface irregularities or noise in a single set are suppressed, improving the stability and adaptability of the normal direction.
[0093] In one embodiment, calculating the virtual character's facing and position based on the normal vector includes:
[0094] A new coordinate system for virtual characters is constructed based on normal vectors;
[0095] Under the new coordinate system, the position of the virtual character is corrected to obtain the new position of the virtual character.
[0096] Optionally, a new coordinate system for the virtual character is constructed based on the normal vector. Specifically, the default upward direction (0,0,1) is cross-multiplied with the wall normal N to obtain the rightward direction vector R = (0,0,1) × N. The rightward direction R is then cross-multiplied with the wall normal N to obtain the corrected upward direction U = R × N. This ultimately forms a local coordinate system composed of N (forward), R (rightward), and U (upward) (e.g., ...). Figure 14 (As shown), used to align the character's pose with the climbing surface.
[0097] Next, the virtual character's position is corrected based on the new coordinate system. Assuming four collision points are detected by the spherical ray, the world coordinates of these four collision points are taken, and the average coordinates of the collision points are calculated as (150, 80, 300). Four detection points emitting spherical rays corresponding to the collision points are determined, and the offsets of these detection points relative to the center of the character's capsule are calculated as (0, -20, 20), (0, 20, 20), (0, -20, -50), and (0, 20, -50), respectively. The average offset of the detection points is then calculated as (0, 0, -15).
[0098] The average coordinates of the collision points and the average offset of the detection points are transformed to a new coordinate system, and alignment is achieved through matrix transformation or vector projection. The average coordinates of the collision points can be subtracted from the average offset of the detection points, and the difference between the virtual character's radius and the detection radius can be calculated by moving backward (N) along the forward direction of the new coordinate system. The new coordinate system faced by the virtual character is forward (0,1,0), right (0,-1,0), and up (0,0,1), with a climbing radius of 40 and a spherical detection radius of 20. Therefore, the new position coordinates of the virtual character are as follows:
[0099]
[0100] The calculated new coordinates are set as the root position of the virtual character's capsule. The rotation matrix of the virtual character's skeleton is then adjusted in the forward / right / upward directions of the new coordinate system, allowing the character's posture to naturally conform to the climbing surface. In this way, by dynamically constructing a coordinate system and performing geometric correction, the problem of character position offset caused by traditional single-point detection is solved, ensuring the character remains stably attached in complex terrain. Furthermore, a radius compensation mechanism avoids clipping or suspension phenomena caused by differences in detection range.
[0101] In one embodiment, the virtual character climbing control method includes:
[0102] If the virtual character has no displacement input during the climbing process, the spherical ray detection of the current frame is disabled, and the normal vector and the climbing posture of the virtual character from the previous frame are used.
[0103] Optionally, when a virtual character is detected to have no displacement input during climbing, spherical ray detection in the current frame is disabled, and the surface normal vector of the climbing object and the character's climbing posture data calculated in the previous frame are reused. By reusing the normal vector from the previous frame, the contact direction between the virtual character and the surface of the climbing object remains unchanged, avoiding abrupt posture changes due to missing detection. If displacement input resumes in subsequent frames, spherical ray detection is re-enabled, and the normal vector and posture parameters are updated. This avoids performance loss due to redundant calculations.
[0104] In one embodiment, the virtual character climbing control method further includes:
[0105] When the virtual character climbs along a preset direction, if a collision point is detected, the movement scaling factor is increased to adjust the virtual character's displacement step size per frame; if no collision point is detected, the movement scaling factor is decreased; if the virtual character's climbing direction changes, the movement scaling factor is reset.
[0106] Optionally, the movement scaling factor is a parameter used to adjust the displacement step size of the virtual character per frame during climbing, with an initial value of 1. As the virtual character climbs along a preset direction, collision points on the current climbing path are detected in real time. If a valid collision point is detected, it means the climbing surface can support the character's movement, so the movement scaling factor is increased to accelerate the character's displacement speed and improve climbing efficiency. If no collision point is detected, the movement scaling factor is decreased to avoid missing collision points. When the virtual character's climbing direction changes, the movement scaling factor is reset to its initial value to ensure step size adaptation in the new direction. Thus, the virtual character's step size is adjusted in real time based on collision detection results to adapt to different terrain features and balance movement efficiency and stability.
[0107] The virtual character climbing control method provided in this application involves, when the virtual character enters a climbing posture, emitting spherical rays from at least three different positions towards the climbing object, based on the virtual character's current position, to obtain at least three spherical rays; when all at least three spherical rays detect a collision point on the climbing object, acquiring the position information of the collision point; and adjusting the virtual character's climbing posture based on the collision point position information to match the surface morphology of the climbing object. This application uses multi-directional spherical rays to detect collision points and adjusts the virtual character's climbing posture to precisely conform to the geometry of the target surface.
[0108] Second Embodiment
[0109] Please see Figure 15 Based on the same technical concept as the first embodiment, this application provides a virtual character climbing control device 500, including:
[0110] The detection module 501 is used to emit spherical rays from at least three different positions toward the climbing object when the virtual character enters the climbing posture, based on the current position of the virtual character, so as to obtain at least three spherical rays;
[0111] Processing module 502 is used to acquire the position information of the collision point when at least three spherical rays detect a collision point on the climbing object;
[0112] The adjustment module 503 is used to adjust the climbing posture of the virtual character to match the surface shape of the climbing object based on the position information of the collision point.
[0113] In one embodiment, emitting spherical rays in at least three preset directions based on the current position of the virtual character includes at least one of the following:
[0114] Using the center of the capsule of the virtual character as a reference, spherical rays are emitted towards the climbing object from at least three positions: upper left, upper right, lower left, and lower right.
[0115] Using the center of the capsule of the virtual character as a reference, spherical rays are emitted from six positions: upper left, upper right, lower left, lower right, and lower right towards the climbing object;
[0116] Using the center of the capsule of the virtual character as a reference, spherical rays are emitted from six positions: upper left, middle left, lower left, upper right, middle right, and lower right, toward the climbing object;
[0117] Using the center of the capsule of the virtual character as a reference, spherical rays are emitted towards the climbing object from nine positions: upper left, upper right, upper left center, middle left center, middle right center, lower left center, and lower right center.
[0118] In one embodiment, adjusting the climbing posture of the virtual character to match the surface morphology of the climbing object based on the location information of the collision point includes:
[0119] The normal vector of the climbing object is determined based on the position information of the at least three collision points;
[0120] The orientation and position of the virtual character are calculated based on the normal vector.
[0121] In one embodiment, determining the normal vector of the climbing object based on the position information of the at least three collision points includes:
[0122] If there are three collision points, the perpendicular line to the plane containing the center line of the three collision points is determined as the normal vector of the climbing object.
[0123] If there are four collision points, the normal vector of the climbing object is obtained by cross-multiplying the vector from the lower left collision point to the upper right collision point with the vector from the lower right collision point to the upper left collision point.
[0124] If the number of collision points is six, the six collision points are divided into two groups, each group containing four collision points. The local normal vector is calculated by the cross product of the vectors of the four collision points in each group, and the average of the two groups of local normal vectors is taken as the normal vector of the climbing object.
[0125] If there are nine collision points, the nine collision points are divided into four groups, each group containing four collision points. The local normal vector is calculated by the cross product of the vectors of the four collision points in each group, and the average of the four local normal vectors is taken as the normal vector of the climbing object.
[0126] In one embodiment, calculating the facing and position of the virtual character based on the normal vector includes:
[0127] A new coordinate system for the virtual character is constructed based on the normal vector;
[0128] Under the new coordinate system, the position of the virtual character is corrected to obtain the new position of the virtual character.
[0129] In one embodiment, the processing module 502 is further configured to include:
[0130] If the virtual character has no displacement input during the climbing process, the spherical ray detection of the current frame is disabled, and the normal vector of the previous frame and the climbing posture of the virtual character are used.
[0131] In one embodiment, the processing module 502 is further configured to include:
[0132] When the virtual character climbs along a preset direction, if a collision point is detected, the movement scaling factor is increased. The increased movement scaling factor is used to adjust the displacement step size of the virtual character per frame. If no collision point is detected, the movement scaling factor is decreased. If the climbing direction of the virtual character changes, the movement scaling factor is reset.
[0133] For detailed implementation of the embodiments of this application, please refer to the first embodiment, which will not be repeated here.
[0134] Optionally, embodiments of this application also provide an electronic device, including a processor and a memory. The memory stores a program or instructions that can run on the processor. When the program or instructions are executed by the processor, they implement the various steps of the virtual character climbing control method embodiments described above and achieve the same technical effect. To avoid repetition, they will not be described again here. It should be noted that the electronic device in the embodiments of this application includes the aforementioned mobile electronic device and non-mobile electronic device.
[0135] Figure 16 To illustrate the hardware structure of the electronic device according to the embodiments of this application, the electronic device includes:
[0136] The processor 601 can be implemented using a general-purpose central processing unit (CPU), microprocessor, application specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.
[0137] The memory 602 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 602 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 602 and is called and executed by the processor 601 to execute the control method of the DC steam generator of the embodiments of this application.
[0138] The input / output interface 603 is used to implement information input and output;
[0139] The communication interface 604 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0140] Bus 605 transmits information between various components of the device (e.g., processor 601, memory 602, input / output interface 603, and communication interface 604);
[0141] The processor 601, memory 602, input / output interface 603, and communication interface 604 are connected to each other within the device via bus 605.
[0142] The electronic device provided in this application embodiment can implement all the steps of the above-described virtual character climbing control method embodiment and achieve the same technical effect. To avoid repetition, it will not be described again here.
[0143] This application also provides a computer-readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various steps of the above-described virtual character climbing control method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0144] The processor is the processor in the electronic device described in the above embodiments. The computer-readable storage medium includes computer-readable storage media such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0145] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface and the processor are coupled. The processor is used to run programs or instructions to implement the various steps of the above-described virtual character climbing control method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0146] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0147] This application provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the various steps of the virtual character climbing control method embodiment described above, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0148] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0149] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0150] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A virtual character climbing control method, characterized in that, Includes the following steps: When the virtual character enters a climbing posture, based on the current position of the virtual character, spherical rays are emitted from at least three different positions toward the climbing object, resulting in at least three spherical rays; When all three spherical rays detect a collision point on the climbing object, the position information of the collision point is obtained. Based on the location information of the collision point, the climbing posture of the virtual character is adjusted to match the surface shape of the climbing object.
2. The virtual character climbing control method according to claim 1, characterized in that, The method of emitting spherical rays from at least three different locations relative to the current position of the virtual character includes at least one of the following: Using the center of the capsule of the virtual character as a reference, spherical rays are emitted towards the climbing object from at least three positions: upper left, upper right, lower left, and lower right. Using the center of the capsule of the virtual character as a reference, spherical rays are emitted from six positions: upper left, upper right, lower left, lower right, and lower right towards the climbing object; Using the center of the capsule of the virtual character as a reference, spherical rays are emitted from six positions: upper left, middle left, lower left, upper right, middle right, and lower right, toward the climbing object; Using the center of the capsule of the virtual character as a reference, spherical rays are emitted towards the climbing object from nine positions: upper left, upper right, upper left center, middle left center, middle right center, lower left center, and lower right center.
3. The virtual character climbing control method according to claim 1 or 2, characterized in that, The step of adjusting the climbing posture of the virtual character to match the surface morphology of the climbing object based on the position information of the collision point includes: The normal vector of the climbing object is determined based on the position information of the at least three collision points; The orientation and position of the virtual character are calculated based on the normal vector.
4. The virtual character climbing control method according to claim 3, characterized in that, Determining the normal vector of the climbing object based on the position information of the at least three collision points includes: If there are three collision points, the perpendicular line to the plane containing the center line of the three collision points is determined as the normal vector of the climbing object. If there are four collision points, the normal vector of the climbing object is obtained by cross-multiplying the vector from the lower left collision point to the upper right collision point with the vector from the lower right collision point to the upper left collision point. If the number of collision points is six, the six collision points are divided into two groups, each group containing four collision points. The local normal vector is calculated by the cross product of the vectors of the four collision points in each group, and the average of the two groups of local normal vectors is taken as the normal vector of the climbing object. If there are nine collision points, the nine collision points are divided into four groups, each group containing four collision points. The local normal vector is calculated by the cross product of the vectors of the four collision points in each group, and the average of the four local normal vectors is taken as the normal vector of the climbing object.
5. The virtual character climbing control method according to claim 3, characterized in that, The step of calculating the facing and position of the virtual character based on the normal vector includes: A new coordinate system for the virtual character is constructed based on the normal vector; Under the new coordinate system, the position of the virtual character is corrected to obtain the new position of the virtual character.
6. The virtual character climbing control method according to claim 1, characterized in that, The method includes: If the virtual character has no displacement input during the climbing process, the spherical ray detection of the current frame is disabled, and the normal vector of the previous frame and the climbing posture of the virtual character are used.
7. The virtual character climbing control method according to claim 1, characterized in that, The method further includes: When the virtual character climbs along a preset direction, if a collision point is detected, the movement scaling factor is increased. The increased movement scaling factor is used to adjust the displacement step size of the virtual character per frame. If no collision point is detected, the movement scaling factor is decreased. If the climbing direction of the virtual character changes, the movement scaling factor is reset.
8. A virtual character climbing control device, characterized in that, include: The detection module is used to emit spherical rays from at least three different positions toward the climbing object when the virtual character enters a climbing posture, based on the current position of the virtual character, to obtain at least three spherical rays; The processing module is used to acquire the position information of the collision point when all three spherical rays detect a collision point on the climbing object; An adjustment module is used to adjust the climbing posture of the virtual character to match the surface morphology of the climbing object based on the position information of the collision point.
9. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the virtual character climbing control method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the virtual character climbing control method as described in any one of claims 1 to 7.