A control method and device of a role, an electronic device and a readable storage medium

By constructing a distance field function for obstacles and determining the target obstacle avoidance speed based on the velocity relationship between the virtual character and the obstacles, the problem of unsatisfactory obstacle avoidance performance of existing algorithms in complex scenes is solved, achieving more efficient and accurate obstacle avoidance.

CN114470777BActive Publication Date: 2025-11-04NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210129019.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-11
Publication Date
2025-11-04
Estimated Expiration
2042-02-11

AI Technical Summary

Technical Problem

Existing obstacle avoidance algorithms for virtual characters struggle to adapt to complex scenarios when updating at high speeds, resulting in unsatisfactory obstacle avoidance performance and high computational complexity, making them difficult to scale.

Method used

By constructing a distance field function for obstacles, the target obstacle avoidance speed is determined based on the velocity relationship between the target virtual character and the obstacles, and the distance field function is used to accurately and quickly avoid collisions.

Benefits of technology

It improves the accuracy and efficiency of obstacle avoidance speed determination, reduces speed adjustment jitter, and adapts to obstacles in complex scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114470777B_ABST
    Figure CN114470777B_ABST
Patent Text Reader

Abstract

The application provides a role control method and device, electronic equipment and readable storage medium, comprising: determining at least one obstacle in a preset distance range of the target virtual role which needs to be avoided; constructing a distance field function corresponding to each obstacle based on the current speed of the target virtual role and the moving speed of each obstacle; determining an obstacle avoidance condition met by the target virtual role according to the distance field function corresponding to each obstacle, and determining a target obstacle avoidance speed for controlling the target virtual role to avoid according to the obstacle avoidance condition met by the target virtual role; and controlling the target virtual role to move at the target obstacle avoidance speed. In the application, the moving speed which can produce an avoidance effect is accurately and quickly determined according to the distance field of each possible obstacle, and the accuracy and efficiency of the obstacle avoidance speed determination are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the game technical field, and particularly to a role control method and device, electronic equipment and readable storage medium. BACKGROUND

[0002] With the gradual maturity of the industry and the accumulation of player experience, the standard for picture display in today's games is gradually increasing, and the penetration collision between virtual characters is unacceptable, so how to ensure that virtual characters do not collide with other virtual characters when moving and stopping is very important.

[0003] At present, the commonly used method to prevent collision between virtual characters is dynamic avoidance, in which individuals can produce avoidance behavior to other individuals and obstacles during the process of moving to the target point, and seek the best path to the target point. In existing algorithms, individuals must be represented in a circular manner, and obstacles must be represented in a line segment or simple polygon manner. The speed updating strategy is difficult to meet various situations in games, and the obstacle avoidance effect is not ideal. SUMMARY

[0004] Therefore, the purpose of the present application is to provide a role control method and device, electronic equipment and readable storage medium, which can accurately and quickly determine the moving speed that can produce avoidance effect according to the distance field of each possible obstacle, thereby improving the accuracy and efficiency of obstacle avoidance speed determination.

[0005] In a first aspect, the embodiments of the present application provide a role control method, which provides a graphical user interface through a first terminal device, and at least part of a game scene is displayed on the graphical user interface. The control method comprises the following steps:

[0006] determining at least one obstacle that needs to be avoided within a preset distance range of a target virtual character;

[0007] constructing a distance field function corresponding to each obstacle based on the current speed of the target virtual character and the moving speed of each obstacle;

[0008] determining an obstacle avoidance condition satisfied by the target virtual character according to the distance field function corresponding to each obstacle, and determining a target obstacle avoidance speed for controlling the target virtual character to avoid according to the obstacle avoidance condition satisfied by the target virtual character; wherein the obstacle avoidance condition satisfied by the target virtual character is that the target virtual character will collide with the obstacle when moving at the current speed, or the target virtual character will not collide with the obstacle when moving at the current speed;

[0009] controlling the target virtual character to move at the target obstacle avoidance speed.

[0010] In a possible implementation, the moving speed of the obstacle includes a moving speed of zero and a moving speed not of zero;

[0011] When the moving speed of the obstacle is of zero, the distance field function corresponding to the obstacle is constructed by the following steps:

[0012] According to the shape of the obstacle, at least one target basic pattern constituting the shape of the obstacle is determined;

[0013] Based on the mapping relationship between the preset basic pattern and the distance field function and the at least one target basic pattern, the distance field function corresponding to the obstacle is determined.

[0014] In a possible implementation, when the moving speed of the obstacle is not of zero, the distance field function corresponding to the obstacle is constructed by the following steps:

[0015] Based on the boundary of the shape of the obstacle, two tangent lines from the position of the target virtual role to the boundary position of the obstacle are determined;

[0016] Based on the distance field function corresponding to the shape of the obstacle and the distance field function corresponding to each tangent line respectively calculated, a target distance field function is determined;

[0017] The target distance field function is offset by an offset amount to obtain the distance field function corresponding to the obstacle.

[0018] In a possible implementation, the offset amount is determined by the following steps:

[0019] Based on the current speed of the target virtual role and the moving speed of the obstacle, a relative speed between the target virtual role and the obstacle is determined;

[0020] Based on the relative speed and a preset adjustment coefficient, the offset amount is determined.

[0021] In a possible implementation, the obstacle avoidance condition satisfied by the target virtual role is determined by the following steps:

[0022] For each obstacle, according to the moving speed of the obstacle and the current speed of the target virtual role, a distance field value between the target virtual role and the obstacle is determined based on the distance field function corresponding to the obstacle;

[0023] From the plurality of distance field values determined, a distance field value with the minimum value is determined as a target distance field value corresponding to the target virtual role;

[0024] If the target distance field value is greater than or equal to a preset numerical threshold, it is determined that the target virtual character will not collide with the obstacle when moving at the current speed.

[0025] If the target distance field value is less than the preset numerical threshold, it is determined that the target virtual character will collide with the obstacle when moving at the current speed.

[0026] In a possible implementation, the obstacle avoidance condition met by the target virtual character is that the target virtual character will not collide with the obstacle when moving at the current speed, and the target obstacle avoidance speed is determined by the following steps:

[0027] The current speed of the target virtual character is determined as the target obstacle avoidance speed.

[0028] In a possible implementation, the obstacle avoidance condition met by the target virtual character is that the target virtual character will collide with the obstacle when moving at the current speed, and the target obstacle avoidance speed is determined by the following steps:

[0029] A plurality of sampling speeds are determined.

[0030] At least one candidate speed is determined based on a distance field value corresponding to each sampling speed.

[0031] The target obstacle avoidance speed is selected from the at least one determined candidate speed according to a preset expected speed of the target virtual character, wherein a speed direction of the expected speed is a direction of a destination of the target virtual character relative to the target virtual character.

[0032] In a possible implementation, a sampling speed is determined by the following steps:

[0033] A sampling range of a speed direction is determined according to a range in which the target virtual character rotates within a frame.

[0034] A plurality of sampling speeds are determined in the sampling range according to a preset sampling increment and based on an expected direction of the expected speed.

[0035] In a possible implementation, a candidate speed is determined by the following steps:

[0036] For each sampling speed, a distance field function of each obstacle relative to the sampling speed is constructed based on the sampling speed and a moving speed of each obstacle, and a distance field value corresponding to the sampling speed is determined according to the distance field function of each obstacle relative to the sampling speed.

[0037] A sampling speed corresponding to a distance field value greater than or equal to a preset numerical threshold is determined as a candidate speed from the plurality of sampling speeds.

[0038] In a possible implementation, the filtering, according to a preset expected speed of the target virtual role, of the target obstacle avoidance speed from the at least one candidate speed determined, includes:

[0039] determining a distance between each sampling speed and the expected speed, and determining a sampling speed with a minimum distance from the expected speed as the target obstacle avoidance speed; or

[0040] determining a change amount between each sampling speed and a current speed of the target virtual role, and determining a sampling speed with a minimum change amount from the current speed of the target virtual role as the target obstacle avoidance speed.

[0041] In a second aspect, an embodiment of the present application provides a role control apparatus, which provides a graphical user interface through a first terminal device, and at least part of a game scene is displayed on the graphical user interface. The control apparatus includes:

[0042] an obstacle determination module configured to determine at least one obstacle that needs to be avoided within a preset distance range of a target virtual role;

[0043] a function construction module configured to construct a distance field function corresponding to each obstacle based on a current speed of the target virtual role and a moving speed of each obstacle;

[0044] an avoidance speed determination module configured to determine an obstacle avoidance condition met by the target virtual role according to the distance field function corresponding to each obstacle, and determine a target obstacle avoidance speed for controlling the target virtual role to avoid the obstacle according to the obstacle avoidance condition met by the target virtual role, wherein the obstacle avoidance condition met by the target virtual role is that the target virtual role moves at the current speed and collides with the obstacle, or the target virtual role moves at the current speed and does not collide with the obstacle;

[0045] a movement control module configured to control the target virtual role to move at the target obstacle avoidance speed.

[0046] In a third aspect, an embodiment of the present application further provides an electronic device, including a processor, a storage medium and a bus. The storage medium stores machine readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium through the bus. The processor executes the machine readable instructions to perform the steps of the role control method according to any one of the first aspect.

[0047] In a fourth aspect, the embodiments of the present application further provide a computer readable storage medium, which stores a computer program. When the computer program is run by a processor, the steps of the role control method according to any one of the first aspect are executed.

[0048] The role control method, device, electronic device and readable storage medium provided by the embodiments of the present application can determine at least one obstacle within a preset distance range of the target virtual role in the game scene, construct a distance field function corresponding to each obstacle according to the current speed of the target virtual role and the moving speed of each obstacle, determine an obstacle avoidance condition met by the target virtual role according to the distance field function corresponding to each obstacle, and further determine a target obstacle avoidance speed for controlling the target virtual role to move. After the target obstacle avoidance speed that can make the target virtual role avoid the obstacle is determined, the target virtual role is controlled to move in the game scene at the target obstacle avoidance speed. In the embodiments of the present application, the moving speed that can produce an avoidance effect can be accurately and quickly determined according to the distance field of each possible obstacle, and the accuracy and efficiency of obstacle avoidance speed determination are improved.

[0049] In order to make the above objectives, characteristics and advantages of the present application more apparent, the following will describe preferred embodiments in detail, and the accompanying drawings will be described as follows. BRIEF DESCRIPTION OF DRAWINGS

[0050] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.

[0051] Figure 1 A flowchart of a role control method provided by the embodiments of the present application;

[0052] Figure 2 A distance field diagram of a moving obstacle provided by the embodiments of the present application;

[0053] Figure 3 A flowchart of another role control method provided by the embodiments of the present application;

[0054] Figure 4 A flowchart of another role control method provided by the embodiments of the present application;

[0055] Figure 5 A structural diagram of a role control device provided by the embodiments of the present application;

[0056] Figure 6 A structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0057] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will be combined with the accompanying drawings for the embodiments of the present application to make a clear and complete description of the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the accompanying drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, every other embodiment obtained by a person skilled in the art without creative work falls within the scope of protection of the present application.

[0058] First, the application scenarios applicable to the present application are introduced. The present application can be applied to the field of game technology. With the gradual maturity of the industry and the accumulation of player experience, the standard for picture display in today's games is gradually increasing, and the penetration and collision between virtual characters are unacceptable. Therefore, how to ensure that virtual characters do not collide with other virtual characters when moving and stopping is very important.

[0059] At present, the commonly used method to prevent collision between virtual characters is dynamic avoidance, which is defined as follows: an individual moves to a target point and can produce avoidance behavior to other individuals and obstacles during the process, and seeks the best path to the target point. There are different solutions to this type of problem, and the scheme based on VO algorithm is widely used, such as RVO algorithm, ORCA algorithm, etc.

[0060] Specifically, in the VO algorithm, the individual gives up all possible future collision speeds and takes full responsibility for avoidance, resulting in a large deviation of the updated speed from the original speed. Therefore, when updating the speed again, it is necessary to produce a deviation in the direction of the original speed again, and the repeated process will cause jitter. Therefore, in the RVO algorithm, the responsibility is shared by both parties to avoid, so that the updated speed will not be too large, and therefore does not need to be corrected twice. This method ensures avoidance while avoiding jitter. The ORCA algorithm proposes a linear programming-based avoidance scheme. The smallest deviation from the VO algorithm is found and applied to the individual, providing a good speed update scheme while avoiding jitter and ensuring avoidance.

[0061] However, the above algorithms have some necessary prerequisites, that is, the individual must be represented in a circular form, and the obstacle must be represented in a line segment or a simple polygon. In addition, the RVO algorithm cannot provide a good speed update scheme, and the sampling strategy of the updated speed is difficult to develop. The ORCA algorithm has high computational complexity and is difficult to extend. It is difficult to add this scheme for complex graphics, and when the individual, target connecting line and obstacle are completely perpendicular, the individual will stop, which cannot achieve the effect of dynamic avoidance.

[0062] Based on this, the embodiment of the present application provides a role control method to improve the accuracy and efficiency of obstacle avoidance speed determination.

[0063] Please refer to Figure 1 , Figure 1 The flowchart of a role control method provided by the embodiment of the present application. A graphical user interface is provided by a first terminal device, and at least part of a game scene is displayed on the graphical user interface. The control method comprises the following steps:

[0064] S101, determining at least one obstacle that needs to be avoided within a preset distance range of the target virtual role.

[0065] S102, constructing a distance field function corresponding to each obstacle based on the current speed of the target virtual role and the moving speed of each obstacle.

[0066] S103, determining the obstacle avoidance condition satisfied by the target virtual role according to the distance field function corresponding to each obstacle, and determining the target obstacle avoidance speed for controlling the target virtual role to avoid according to the obstacle avoidance condition satisfied by the target virtual role.

[0067] S104, controlling the target virtual role to move at the target obstacle avoidance speed.

[0068] The role control method provided by the embodiment of the present application can accurately and quickly determine the moving speed that can produce avoidance effect according to the distance field of each possible obstacle, thereby improving the accuracy and efficiency of obstacle avoidance speed determination.

[0069] The exemplary steps of the embodiment of the present application are described below:

[0070] S101, determining at least one obstacle that needs to be avoided within a preset distance range of the target virtual role.

[0071] In the embodiments of the present application, the target virtual character is a non-player character (NPC) in the game scene that is not controlled by the player, and the target virtual character can move in the game scene at a certain moving speed. In other embodiments, the target virtual character is a player character controlled by the player.

[0072] Here, in the embodiments of the present application, the current speed of the target virtual character is obtained as a vector, including the speed rate and the speed direction of the moving speed of the target virtual character.

[0073] Here, the setting of the obstacle can be a stationary obstacle (such as a building, a tree, etc. in the game scene), and can also be a moving obstacle (such as a player character, a non-player character, or a moving vehicle, etc.).

[0074] Here, in order to reduce the calculation amount of the obstacle avoidance calculation of the target virtual character, the position of the obstacle can be set to be within a preset distance from the target virtual character, and for the current calculation process, the obstacle that is relatively far from the target virtual character will not be calculated first.

[0075] Specifically, for the stationary obstacle, the distance between the two in the game scene can be directly calculated according to the position coordinates of the obstacle and the coordinates of the target virtual character, and a comparison is made according to the preset distance to determine whether it is an obstacle that needs to be avoided in this calculation; and for the movable obstacle, the moving speed of the obstacle and the relative speed between the target virtual character and the obstacle are also considered to comprehensively calculate the distance between the obstacle and the target virtual character, and a comparison is made according to the preset distance to determine whether it is an obstacle that needs to be avoided in this calculation.

[0076] S102, based on the current speed of the target virtual character and the moving speed of each obstacle, a distance field function corresponding to each obstacle is constructed.

[0077] In the embodiments of the present application, according to the current speed of the target virtual character and the moving speed of each obstacle, a distance field corresponding to each obstacle is constructed for each obstacle.

[0078] Here, the distance field is a field function that defines a mapping relationship from an input point to a distance. The distance field defines the nearest distance from any point in the field to all reference objects. For example, for a one-dimensional field, it is the nearest distance from any point to all points; for a two-dimensional field, it is the nearest distance from any point to the edges of all objects; for a three-dimensional field, it is the nearest distance from any point to the surfaces of all objects.

[0079] For example, for a target graphic circle, a target point with the center of the circle as the center, the distance from each point to the center needs to be calculated, and the distance relationship between the calculated distance and the radius of the circle needs to be represented, and this distance relationship is the distance field corresponding to the target graphic circle.

[0080] The distance field also includes a signed distance field, and the signed distance field (SDF) is calculated in this application. The sign is positive or negative. Specifically, after obtaining the coordinates of the nearest point and the shortest distance from any point to the surface, the dot product of the vector formed by the selected point and the nearest point obtained and the normal vector is calculated to determine whether the direction is consistent. If the direction is consistent, the distance field sign is positive, otherwise the distance field sign is negative.

[0081] It is worth noting that in the embodiments of the present application, the idea of representing the velocity region that may cause a collision based on the velocity space is used to construct the distance field. When constructing the distance field, the way of constructing the distance field is different for whether the obstacle is a stationary object (whether the moving speed of the obstacle is zero). The following will be described respectively:

[0082] (1) The moving speed of the obstacle is zero (when the obstacle is a stationary obstacle), and the distance field function corresponding to the obstacle is constructed by the following steps:

[0083] a1: determining at least one target basic graphic constituting the shape of the obstacle according to the shape of the obstacle;

[0084] a2: determining the distance field function corresponding to the obstacle based on the mapping relationship between the preset basic graphic and the distance field function and the at least one target basic graphic.

[0085] In the embodiments of the present application, when the obstacle is stationary, the shape of the obstacle can be directly determined. After the shape of the obstacle is determined, the composition constituting the shape of the obstacle is determined. If the shape of the obstacle is composed of a single simple basic shape (circle, rectangle, triangle, etc.), the corresponding distance field function can be directly determined according to the mapping relationship between the preset basic shape and the distance field, and according to the simple basic shape constituting the obstacle. If the shape of the obstacle is not composed of a single simple basic shape, but a complex shape composed of multiple simple shapes, the determined shape of the obstacle needs to be segmented. The complex shape of the obstacle can be segmented into a combination of multiple basic graphics, and the distance field function corresponding to each basic graphic is determined. The distance field function of the obstacle with a complex shape is represented by the distance field function corresponding to each basic graphic constituting the shape of the obstacle.

[0086] (II) the moving speed of the obstacle is not zero (when the obstacle is a moving obstacle), the distance field function corresponding to the obstacle is constructed by the following steps:

[0087] b1: determining two tangent lines from the position of the target virtual role to the position of the boundary of the shape of the obstacle.

[0088] In this application, for a moving obstacle, the relative speed between the target virtual role and the moving obstacle can be calculated, the distance field of the obstacle is represented by a cone-like graph, the target virtual role is abstracted as a point, and the radius of the target virtual role is superimposed on the radius of the obstacle to determine two boundaries of the shape of the obstacle, and the tangent lines from the position of the target virtual role to the position of the boundary of the shape of the obstacle are drawn.

[0089] In this way, the moving obstacle can be divided into three parts, a circle and two rays.

[0090] Please refer to Figure 2 , Figure 2 The distance field of the moving obstacle provided by the embodiments of this application is shown in Figure 2 , taking the shape of the moving obstacle as a circle as an example, the distance field of the moving obstacle can be composed of the obstacle itself (the circle 210), the ray 220 and the ray 230, as shown in Figure 2 , the target virtual role is abstracted as a point 240, and the tangent lines from the point 240 to the boundary of the circle 210 are drawn to determine the ray 220 and the ray 230.

[0091] b2: determining the target distance field function based on the distance field function corresponding to the shape of the obstacle and the distance field function corresponding to each tangent line.

[0092] In the embodiments of this application, the target distance field function is determined according to the distance field function corresponding to the shape of the obstacle and the distance field function corresponding to each tangent line calculated in step b1.

[0093] Here, for the distance field function corresponding to the obstacle of a simple shape, the distance field function corresponding to the shape of the obstacle and the distance field function corresponding to each tangent line can be combined to obtain the distance field function corresponding to the moving obstacle.

[0094] Taking the shape of the obstacle as a circle as an example, the distance field function of the moving obstacle can be represented as:

[0095] max(circle.SDF-value, min(ray1.SDF-value, ray2.SDF-value));

[0096] Wherein, the circle.SDF-value represents the distance field value of the shape of a circle; the ray1.SDF-value represents the distance field value of the ray 1; and the ray2.SDF-value represents the distance field value of the ray 2.

[0097] Here, when calculating the distance field value of the obstacle, the minimum value between the ray 1 and the ray 2 is selected, and the minimum value is compared with the distance field value of the circle, and the larger value between the two is determined as the distance field value of the obstacle.

[0098] b3: offsetting the target distance field function by the offset amount to obtain the distance field function corresponding to the obstacle.

[0099] In the embodiment of the present application, in order to avoid the phenomenon of jitter when adjusting the current speed of the target virtual role, the offset amount can be determined first, and the distance field constructed in step b2 is offset and corrected to obtain the distance field function corresponding to the obstacle.

[0100] Wherein, the reason for the jitter phenomenon when adjusting the current speed of the target virtual role is that when the speed of the obstacle is adjusted, all possible collision speeds of the target virtual role in the future are abandoned, which will cause the updated speed to deviate too much from the original speed, so that the original speed needs to be offset again when updating the speed next time, and the repeated process will cause jitter.

[0101] In order to solve the above jitter problem, the speed of both sides of the avoidance is considered, which avoids the problem of adjusting the current speed of the target virtual role too much when adjusting the speed, thereby preventing the jitter phenomenon, so that in the embodiment of the present application, the offset amount is set to avoid the jitter phenomenon, specifically, the offset amount is determined by the following steps:

[0102] c1: based on the current speed of the target virtual role and the moving speed of the obstacle, the relative speed between the target virtual role and the obstacle is determined.

[0103] In the embodiment of the present application, the relative speed between the target virtual role and the obstacle is calculated according to the current speed of the target virtual role and the moving speed of the obstacle.

[0104] Here, in order to prevent the jitter phenomenon in the speed adjustment process, the avoidance speed needs to be distributed to both the target virtual role and the obstacle, so the relative speed between the two needs to be determined when calculating.

[0105] c2: determining the offset based on the relative speed and a preset adjustment coefficient.

[0106] In the embodiments of the present application, after the relative speed between the target virtual role and the obstacle is determined, an adjustment coefficient needs to be set to finally determine the offset.

[0107] Here, the preset adjustment coefficient can be set according to the adjustment requirement or historical adjustment data, which is not specifically limited in the embodiments of the present application.

[0108] Here, the offset can be determined by the following formula:

[0109] Δs=X*(V agent1 -V agent2 );

[0110] Where Δs is the offset; X is the preset adjustment coefficient; V agent1 is the current speed of the target virtual role; V agent2 is the moving speed of the obstacle; and X can be set to 0.5 in specific embodiments.

[0111] S103, determining the avoidance condition met by the target virtual role according to the distance field function corresponding to each obstacle, and determining the target avoidance speed for controlling the target virtual role to avoid according to the avoidance condition met by the target virtual role.

[0112] In the embodiments of the present application, the avoidance condition met by the target virtual role is determined according to the distance field function corresponding to each obstacle, so that how to screen the current speed of the target virtual role is determined according to the met avoidance condition, and the target avoidance speed for controlling the target virtual role to avoid is screened out.

[0113] Where the avoidance condition met by the target virtual role is that the target virtual role moving at the current speed will collide with the obstacle, or the target virtual role moving at the current speed will not collide with the obstacle.

[0114] Here, the screening of the target obstacle avoidance speed is determined by the moving speed of the target virtual role. In the speed space, the position space information can be converted to the speed space. Specifically, for the subject A that avoids the obstacle B, both of them are abstracted as circles. At this time, A can be regarded as a particle, and the radius of A is added to the radius of B, that is, the radius length of B at this time = the radius of A + the original radius of B. At this time, two tangent lines are emitted from A to the circle where B is located. The area surrounded by the two tangent lines constitutes the VO area of B. Intuitively, as long as A selects the speed in the VO area, a collision with B will occur at some future moment. In other words, this VO area marks the speed that may collide with B. As long as the VO of all obstacles is obtained and the speed not in the VO area is selected, the avoidance can be guaranteed to be successful, that is, the target obstacle avoidance speed determined in the present application is the speed that does not collide with any obstacle.

[0115] Here, when calculating the obstacle avoidance condition, the following steps are included: (1) selecting a starting point P and a ray emitting direction Dir; (2) calculating the distance field value SDF-value of the current point; (3) stepping along the ray Dir direction by |SDF-value| length to obtain a new point P', that is, P' = P + |SDF-value| * Dir; (4) if the SDF value of P' is 0, that is, the target point is reached, or the iteration number exceeds a given value, the iteration ends, and P' is returned, otherwise, jump back to step (1) until the condition is met.

[0116] It is worth noting that according to the research on the process of calculating the obstacle avoidance condition, if the distance field value of the starting point P is greater than or equal to zero, the distance field value of the terminal point P' obtained will also be greater than or equal to zero. If the distance field value of the starting point P is less than zero, the distance field value of the terminal point will also be less than or equal to zero.

[0117] Based on the above conclusion, a way to determine the obstacle avoidance condition satisfied by the target virtual role can be given. Please refer to Figure 3 , Figure 3 The flowchart of another role control method provided by the embodiment of the present application is shown in Figure 3 The obstacle avoidance condition satisfied by the target virtual role is determined by the following steps:

[0118] S301, for each obstacle, according to the moving speed of the obstacle and the current speed of the target virtual role, based on the distance field function corresponding to the obstacle, the distance field value between the target virtual role and the obstacle is determined.

[0119] In the embodiment of the present application, the distance field value of the target virtual character relative to each obstacle needs to be calculated, and the moving speed of the obstacle and the current speed of the target virtual character are substituted into the distance field function corresponding to the obstacle to determine the corresponding distance field function value.

[0120] Here, in the traditional distance field value calculation process, the position coordinates between two points need to be substituted for calculation, while in the embodiment of the present application, the current speed of the target virtual character and the moving speed of the obstacle are substituted for calculation.

[0121] Specifically, the moving speed includes a moving rate and a moving direction, and the two constitute a speed vector. The speed vector of the target virtual character and the speed vector of the obstacle are substituted into the corresponding distance field function to obtain the distance field value between the target virtual character and the obstacle.

[0122] S302, from the determined multiple distance field values, determine the distance field value with the smallest value as the target distance field value corresponding to the target virtual character.

[0123] In the embodiment of the present application, according to the distance field calculation of each obstacle in step S301, multiple distance field values are determined, and the distance field value with the smallest value is selected from the multiple distance field values, and the selected distance field value with the smallest value is determined as the target distance field value corresponding to the target virtual character.

[0124] Here, since the distance field value calculation of each obstacle is very fast, only a few simple operations (addition operation and multiplication operation between two-dimensional vectors) are needed, and there are usually not too many obstacles around a target virtual character that needs to produce an avoidance behavior, so each obstacle corresponds to a distance field function. The distance field value of each obstacle can be calculated, and the minimum value is taken to obtain the final target distance field value.

[0125] S303, if the target distance field value is greater than or equal to a preset value threshold, it is determined that the target virtual character moving at the current speed will not collide with the obstacle.

[0126] In the embodiment of the present application, if the calculated target distance field value is greater than or equal to the preset value threshold, it can be determined that the target virtual character moving at the current speed will not collide with the obstacle.

[0127] The preset value threshold is zero.

[0128] S304, if the target distance field value is less than the preset value threshold, it is determined that the target virtual character moving at the current speed will collide with the obstacle.

[0129] In the embodiment of the present application, if the calculated target distance field value is less than the preset value threshold, it can be determined that the target virtual character will collide with the obstacle if moving at the current speed, and thus the moving speed of the target virtual character needs to be adjusted.

[0130] In a possible implementation, the target virtual character meets different obstacle avoidance conditions, and the target obstacle avoidance speed is determined in different ways, which are described as follows:

[0131] (I) The obstacle avoidance condition met by the target virtual character is that the target virtual character will not collide with the obstacle if moving at the current speed, and the target obstacle avoidance speed is determined by the following steps:

[0132] d1: The current speed of the target virtual character is determined as the target obstacle avoidance speed.

[0133] In the embodiment of the present application, if the target distance field value is greater than or equal to the preset value threshold, it is determined that the target virtual character will not collide with the obstacle if moving at the current speed.

[0134] It is worth noting that, since the obstacle avoidance speed can be determined according to the relationship between the target distance field value and the preset value threshold in the present application, when it is determined that the target virtual character will not collide with the obstacle if moving at the current speed, i.e., the current speed of the target virtual character is not in the set of speeds that can cause collision, the target virtual character can move at the current speed to avoid the obstacle.

[0135] (II) The obstacle avoidance condition met by the target virtual character is that the target virtual character will not collide with the obstacle if moving at the current speed, please refer to Figure 4 , Figure 4 The flowchart of another role control method provided by the embodiment of the present application is shown in Figure 4 , and the target obstacle avoidance speed is determined by the following steps:

[0136] S401: A plurality of sampling speeds are determined.

[0137] In the embodiment of the present application, since the current speed of the target virtual character will certainly collide with the obstacle, different sampling speeds need to be collected again to determine the avoidance speed that can avoid the obstacle.

[0138] In a possible implementation, the sampling speed is determined by the following steps:

[0139] e1: The sampling range of the speed direction is determined according to the range in which the target virtual character turns within one frame.

[0140] In the embodiments of the present application, in the game scene, the turning speed of the target virtual character in a frame may be required to be within a certain range for the purpose of clear display, and therefore, a sampling range of the speed sample can be set according to the requirement.

[0141] Here, the sampling range of the speed direction can be the same as the range of turning of the target virtual character in a frame, for example, both are not more than 5°; or the sampling range of the speed direction can be smaller than the range of turning of the target virtual character in a frame, and the specific sampling range can be limited according to the sampling requirement and sampling requirement.

[0142] e2: determining a plurality of sampling speeds according to a preset sampling increment, with the expected direction of the expected speed as a reference, in the sampling range.

[0143] In the embodiments of the present application, a plurality of sampling speeds are determined according to a preset sampling increment, with the expected direction of the expected speed as a reference, in the sampling range determined in step e1.

[0144] Here, in order to ensure that the adjusted speed direction does not deviate from the moving destination of the target virtual character, the sampling of the speed needs to be performed in the expected direction of the expected speed, with the expected direction as a reference.

[0145] Here, the speed direction of the expected speed is the direction of the destination of the target virtual character relative to the target virtual character.

[0146] It is worth noting that when determining the sampling speed, the equal-distance sampling can be performed in the sampling range through the same sampling increment, or the increment sampling of the expected speed can be performed, and the direction with a small difference from the expected speed is sampled first. If the speed obtained after sampling can meet certain requirements (for example, the distance from the expected speed is less than a certain value, which is considered to meet the requirements), the speed is immediately returned as the sampling speed of the target virtual character, the iteration number is reduced, and the speed screening efficiency is improved.

[0147] S402, determining at least one candidate speed based on the distance field value corresponding to each sampling speed.

[0148] In the embodiments of the present application, the distance field value corresponding to each sampling speed is determined according to the plurality of sampling speeds determined in step S401, and at least one candidate speed is screened.

[0149] Here, the at least one candidate speed refers to the distance field value corresponding to the sampling speed being greater than or equal to a preset numerical threshold, that is, the candidate speed is not in the speed region in which the collision may occur, and when the target virtual character travels to the destination at the candidate speed, the collision with each obstacle will not occur.

[0150] In a possible implementation, the candidate speed is determined by the following steps:

[0151] f1: for each sampling speed, a distance field function of each obstacle relative to the sampling speed is constructed based on the sampling speed and the moving speed of each obstacle, and a distance field value corresponding to the sampling speed is determined according to the distance field function of each obstacle relative to the sampling speed.

[0152] In the embodiment of the application, for each sampling speed, a distance field function of each obstacle relative to the sampling speed is constructed based on the sampling rate and the sampling direction of the sampling speed, and a distance field value corresponding to the sampling speed is determined according to the distance field function of each obstacle relative to the sampling speed.

[0153] Specifically, the determination manner of the distance field value of the sampling speed is consistent with the determination manner of the distance field value of the target virtual role, which will not be described here again.

[0154] f2: the sampling speed corresponding to the distance field value greater than or equal to a preset numerical threshold value in the plurality of sampling speeds is determined as the candidate speed.

[0155] In the embodiment of the application, the sampling speed corresponding to the distance field value greater than or equal to a preset numerical threshold value in the plurality of sampling speeds in step f1 is determined as the candidate speed, which ensures that the candidate speed is not in the speed region in which collision may occur, and when the target virtual role travels to the destination at the candidate speed, collision with each obstacle will not occur.

[0156] It is worth noting that, after the candidate speed that can avoid collision is determined, the sampling process can be directly ended, and the candidate speed is directly determined as the target obstacle avoidance speed, so as to improve the efficiency of determining the target obstacle avoidance speed; or a plurality of candidate speeds can be determined according to the speed quantity requirement, and then the target obstacle avoidance speed is screened from the candidate speeds, which helps to improve the accuracy of determining the target obstacle avoidance speed.

[0157] S403: screening the target obstacle avoidance speed from the at least one candidate speed according to a preset expected speed of the target virtual role.

[0158] In the embodiment of the application, the target obstacle avoidance speed is screened from the at least one candidate speed according to the expected speed of the target virtual role.

[0159] In a possible implementation, the step of “screening the target obstacle avoidance speed from the at least one candidate speed according to a preset expected speed of the target virtual role” comprises:

[0160] determine a distance between each sampling speed and the expected speed, and determine the sampling speed with the minimum distance from the expected speed as the target obstacle avoidance speed; or

[0161] determine a change between each sampling speed and the current speed of the target virtual character, and determine the sampling speed with the minimum change from the current speed of the target virtual character as the target obstacle avoidance speed.

[0162] In the embodiments of the present application, two ways of screening the candidate speeds are given:

[0163] One is to determine the candidate speed with the minimum distance from the expected speed as the target obstacle avoidance speed, where the distance between the candidate speed and the expected speed can be determined by the candidate speed rate and the candidate direction of the candidate speed, and the expected speed rate and the expected direction of the expected speed.

[0164] The other is to determine the sampling speed with the minimum change from the current speed of the target virtual character as the target obstacle avoidance speed, where the change between the candidate speed and the current speed can be determined by the candidate speed rate and the candidate direction of the candidate speed, and the current speed rate and the current direction of the current speed.

[0165] S104, control the target virtual character to move at the target obstacle avoidance speed.

[0166] In the embodiments of the present application, after the target obstacle avoidance speed that can avoid obstacles is determined, the target virtual character is controlled to move according to the target speed and the target direction indicated by the target obstacle avoidance speed, so as to avoid multiple obstacles in the game scene.

[0167] The role control method provided in the embodiments of the present application determines at least one obstacle in the game scene within a preset distance range of the target virtual character, constructs a distance field function corresponding to each obstacle according to the current speed of the target virtual character and the moving speed of each obstacle, determines the obstacle avoidance condition met by the target virtual character according to the distance field function corresponding to each obstacle, and further determines the target obstacle avoidance speed for controlling the target virtual character to move, and controls the target virtual character to move in the game scene at the target obstacle avoidance speed after the target obstacle avoidance speed that can make the target virtual character avoid obstacles is determined. In the embodiments of the present application, the moving speed that can produce the avoidance effect can be accurately and quickly determined according to the distance field of each possible obstacle, and the accuracy and efficiency of the obstacle avoidance speed determination are improved.

[0168] Based on the same inventive concept, the application further provides an information prompting device corresponding to the role control method. Since the device solves problems in the same principle as the role control method, the implementation of the device can be referred to the implementation of the method, and the repeated parts will not be described here.

[0169] Please refer to Figure 5 , Figure 5 The structure of a role control device provided by the application is shown in the figure. As shown in the figure Figure 5 The control device 500 includes:

[0170] An obstacle determination module 510 is configured to determine at least one obstacle within a preset distance range of a target virtual role that needs to be avoided.

[0171] A function construction module 520 is configured to construct a distance field function corresponding to each obstacle based on the current speed of the target virtual role and the moving speed of each obstacle.

[0172] An avoidance speed determination module 530 is configured to determine an avoidance condition met by the target virtual role according to the distance field function corresponding to each obstacle, and determine a target avoidance speed for controlling the target virtual role to avoid according to the avoidance condition met by the target virtual role. The avoidance condition met by the target virtual role is that the target virtual role will collide with the obstacle at the current speed, or the target virtual role will not collide with the obstacle at the current speed.

[0173] A movement control module 540 is configured to control the target virtual role to move at the target avoidance speed.

[0174] In a possible implementation, the moving speed of the obstacle includes a moving speed of zero and a moving speed not of zero.

[0175] When the moving speed of the obstacle is zero, the function construction module 520 is configured to construct the distance field function corresponding to the obstacle by the following steps:

[0176] According to the shape of the obstacle, at least one target basic figure constituting the shape of the obstacle is determined.

[0177] Based on a preset mapping relationship between the basic figure and the distance field function and the at least one target basic figure, the distance field function corresponding to the obstacle is determined.

[0178] In a possible implementation, the moving speed of the obstacle is not of zero, and the function construction module 520 is configured to construct the distance field function corresponding to the obstacle by the following steps:

[0179] two tangent lines from the position of the target virtual character to the position of the boundary of the obstacle based on the boundary of the shape of the obstacle;

[0180] determine a target distance field function based on the distance field function corresponding to the shape of the obstacle and the distance field function corresponding to each tangent line respectively;

[0181] offset the target distance field function by an offset amount to obtain an obstacle corresponding distance field function.

[0182] In a possible implementation, the function construction module 520 is configured to determine the offset amount by the following steps:

[0183] determine a relative speed between the target virtual character and the obstacle based on the current speed of the target virtual character and the moving speed of the obstacle;

[0184] determine the offset amount based on the relative speed and a preset adjustment coefficient.

[0185] In a possible implementation, the avoidance speed determination module 530 is configured to determine the avoidance condition met by the target virtual character by the following steps:

[0186] for each obstacle, determine a distance field value between the target virtual character and the obstacle based on the distance field function corresponding to the obstacle according to the moving speed of the obstacle and the current speed of the target virtual character;

[0187] determine a target distance field value corresponding to the target virtual character from the plurality of distance field values, the target distance field value being the smallest distance field value in the plurality of distance field values;

[0188] if the target distance field value is greater than or equal to a preset value threshold, determine that the target virtual character will not collide with the obstacle at the current speed;

[0189] if the target distance field value is less than the preset value threshold, determine that the target virtual character will collide with the obstacle at the current speed.

[0190] In a possible implementation, the avoidance condition met by the target virtual character is that the target virtual character will not collide with the obstacle at the current speed, and the avoidance speed determination module 530 is configured to determine the target avoidance speed by the following steps:

[0191] determine the current speed of the target virtual character as the target avoidance speed.

[0192] In a possible implementation, the obstacle avoidance condition met by the target virtual role is that the target virtual role moving at the current speed will collide with an obstacle, and the obstacle avoidance speed determination module 530 is configured to determine the target obstacle avoidance speed by the following steps:

[0193] determining a plurality of sampling speeds;

[0194] determining at least one candidate speed based on the distance field value corresponding to each sampling speed;

[0195] screening the target obstacle avoidance speed from the at least one determined candidate speed according to a preset expected speed of the target virtual role, wherein the speed direction of the expected speed is the direction of the destination of the target virtual role relative to the target virtual role.

[0196] In a possible implementation, the obstacle avoidance speed determination module 530 is configured to determine a sampling speed by the following steps:

[0197] determining a sampling range of the speed direction according to the range in which the target virtual role rotates within a frame;

[0198] determining a plurality of sampling speeds according to a preset sampling increment with the expected direction of the expected speed as a reference in the sampling range.

[0199] In a possible implementation, the obstacle avoidance speed determination module 530 is configured to determine a candidate speed by the following steps:

[0200] for each sampling speed, constructing a distance field function of each obstacle relative to the sampling speed based on the sampling speed and the moving speed of each obstacle, and determining the distance field value corresponding to the sampling speed according to the distance field function of each obstacle relative to the sampling speed;

[0201] determining a sampling speed corresponding to a distance field value greater than or equal to a preset numerical threshold as a candidate speed.

[0202] In a possible implementation, when the obstacle avoidance speed determination module 530 is configured to screen the target obstacle avoidance speed from the at least one determined candidate speed according to a preset expected speed of the target virtual role, the obstacle avoidance speed determination module 530 is configured to:

[0203] determine the distance between each sampling speed and the expected speed, and determine the sampling speed with the minimum distance to the expected speed as the target obstacle avoidance speed; or

[0204] Determine a change amount between each sampling speed and the current speed of the target virtual role, and determine a sampling speed with a minimum change amount between the current speed of the target virtual role as the target obstacle avoidance speed.

[0205] The role control apparatus provided in the embodiments of the present application determines at least one obstacle within a preset distance range of the target virtual role in the game scene, constructs a distance field function corresponding to each obstacle according to the current speed of the target virtual role and the moving speed of each obstacle, determines an obstacle avoidance condition met by the target virtual role according to the distance field function corresponding to each obstacle, and further determines a target obstacle avoidance speed for controlling the target virtual role to move. After the target obstacle avoidance speed that can make the target virtual role avoid the obstacle is determined, the target virtual role is controlled to move in the game scene at the target obstacle avoidance speed. In the embodiments of the present application, the moving speed that can produce an avoidance effect can be accurately and quickly determined according to the distance field of each possible obstacle, and the accuracy and efficiency of obstacle avoidance speed determination are improved.

[0206] Please refer to Figure 6 , Figure 6 for a structural schematic diagram of an electronic device provided in the embodiments of the present application. As shown in Figure 6 , the electronic device 600 includes a processor 610, a memory 620, and a bus 630.

[0207] The memory 620 stores machine readable instructions executable by the processor 610. When the electronic device 600 is running, the processor 610 and the memory 620 communicate through the bus 630. The machine readable instructions executed by the processor 610 can perform the steps of the role control method in the method embodiments as shown in Figure 1 、 Figure 3 and Figure 4 . For specific implementation manners, refer to the method embodiments, which will not be described here.

[0208] The embodiments of the present application further provide a computer readable storage medium, which stores a computer program. When the computer program is run by a processor, the steps of the role control method in the method embodiments as shown in Figure 1 、 Figure 3 and Figure 4 can be performed. For specific implementation manners, refer to the method embodiments, which will not be described here.

[0209] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system, device and unit described above can refer to the corresponding process in the foregoing method embodiments, which will not be described here.

[0210] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other manners. The described device embodiments are merely schematic, for example, the division of the units is only a logical function division, and there can be another division manner in actual implementation, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between different units, or the among different units, can be indirect couplings or communication connections through some interfaces, devices or units, and can be in electrical, mechanical or other forms.

[0211] The units described as separated components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. In actual implementation, some or all of the units can be selected according to actual needs to achieve the purposes of the embodiments of the present application.

[0212] In addition, each functional unit in the embodiments of the present application can be integrated in one processing unit, or each unit can exist physically as a separate unit, or two or more units can be integrated in one unit.

[0213] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a non-volatile computer readable storage medium executable by a processor. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application. The foregoing storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, and various media that can store program codes.

[0214] Finally, it should be noted that the above-described embodiments are merely specific embodiments of the present application, which are used to illustrate the technical solutions of the present application, but not to limit the same. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that any person skilled in the art can make modifications or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some of the technical features within the technical scope disclosed by the present application. The modifications, changes or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for controlling a character, characterized in that, A graphical user interface is provided through a first terminal device, the graphical user interface displaying at least a portion of the game scene, and the control method includes: Identify at least one obstacle that needs to be avoided within a preset distance range of the target virtual character; Based on the current speed of the target virtual character, the movement speed of each obstacle, and the shape of each obstacle, a distance field function corresponding to each obstacle is constructed. When the movement speed of an obstacle indicates that the obstacle is a stationary obstacle, the distance field function corresponding to the obstacle is determined according to the mapping relationship between at least one target basic graphic constituting the obstacle and the distance field function. When the movement speed of an obstacle indicates that the obstacle is a moving obstacle, the distance field function corresponding to the obstacle is determined according to the tangent at the boundary position of the obstacle's shape, the distance field function corresponding to the shape of the obstacle, and the distance field function corresponding to each tangent. Based on the distance field function corresponding to each obstacle, the obstacle avoidance conditions satisfied by the target virtual character are determined, and based on the obstacle avoidance conditions satisfied by the target virtual character, the target obstacle avoidance speed for controlling the target virtual character to avoid obstacles is determined; wherein, the obstacle avoidance conditions satisfied by the target virtual character are that the target virtual character will collide with the obstacle if it moves at the current speed, or the target virtual character will not collide with the obstacle if it moves at the current speed. Control the target virtual character to move at the target obstacle avoidance speed.

2. The control method according to claim 1, characterized in that, The movement speed of the obstacle indicates a movement rate including a movement rate of zero and a movement rate that is not zero; The obstacle's movement speed is zero. The distance field function corresponding to the obstacle is constructed through the following steps: Based on the shape of the obstacle, determine at least one target base graphic that constitutes the shape of the obstacle; Based on the preset mapping relationship between the base graphic and the distance field function, and the at least one target base graphic, the distance field function corresponding to the obstacle is determined.

3. The control method according to claim 2, characterized in that, The obstacle's movement speed is not zero. The distance field function corresponding to the obstacle is constructed through the following steps: Based on the shape of the obstacle's boundary, two tangent lines are determined from the position of the target virtual character to the position of the obstacle's boundary. Based on the distance field function corresponding to the shape of the obstacle and the distance field function corresponding to each tangent, the target distance field function is determined. The target range field function is offset according to the offset amount to obtain the range field function corresponding to the obstacle.

4. The control method according to claim 3, characterized in that, The offset is determined by the following steps: Based on the current speed of the target virtual character and the moving speed of the obstacle, the relative speed between the target virtual character and the obstacle is determined; The offset is determined based on the relative speed and a preset adjustment coefficient.

5. The control method according to claim 1, characterized in that, The obstacle avoidance conditions satisfied by the target virtual character are determined through the following steps: For each obstacle, based on the obstacle's moving speed and the target virtual character's current speed, the distance field value between the target virtual character and the obstacle is determined according to the distance field function corresponding to the obstacle; The distance field value with the smallest value is determined from the multiple determined distance field values, and is determined as the target distance field value corresponding to the target virtual character; If the target distance field value is greater than or equal to a preset value threshold, it is determined that the target virtual character will not collide with the obstacle when moving at the current speed. If the target distance field value is less than a preset value threshold, it is determined that the target virtual character will collide with an obstacle if it moves at the current speed.

6. The control method according to claim 1, characterized in that, The obstacle avoidance condition satisfied by the target virtual character is that the target virtual character will not collide with obstacles when moving at the current speed. The obstacle avoidance speed of the target is determined through the following steps: The current speed of the target virtual character is determined as the target obstacle avoidance speed.

7. The control method according to claim 1, characterized in that, The obstacle avoidance condition satisfied by the target virtual character is that the target virtual character will collide with the obstacle if it moves at the current speed. The obstacle avoidance speed of the target is determined by the following steps: Multiple sampling rates were determined; Based on the distance field value corresponding to each sampling velocity, at least one candidate velocity is determined; Based on the preset desired speed of the target virtual character, the target obstacle avoidance speed is selected from at least one determined candidate speed; wherein, the direction of the desired speed is the direction of the destination of the target virtual character relative to the target virtual character.

8. The control method according to claim 7, characterized in that, The sampling rate is determined by the following steps: The sampling range of the velocity direction is determined based on the range of rotation of the target virtual character within one frame; Within the sampling range, based on the desired direction of the desired velocity, multiple sampling velocities are determined according to a preset sampling increment.

9. The control method according to claim 7, characterized in that, Candidate velocities are determined using the following steps: For each sampling speed, based on the sampling speed and the moving speed of each obstacle, a distance field function of each obstacle relative to the sampling speed is constructed, and the distance field value corresponding to the sampling speed is determined according to the distance field function of each obstacle relative to the sampling speed. The sampling velocities whose corresponding distance field values ​​are greater than or equal to a preset threshold value among multiple sampling velocities are determined as candidate velocities.

10. The control method according to claim 7, characterized in that, The step of selecting the target obstacle avoidance speed from at least one determined candidate speed based on the preset expected speed of the target virtual character includes: Determine the distance between each sampling speed and the desired speed, and determine the sampling speed with the smallest distance to the desired speed as the target obstacle avoidance speed; or Determine the change between each sampling speed and the current speed of the target virtual character, and determine the sampling speed with the smallest change between the sampling speed and the current speed of the target virtual character as the target obstacle avoidance speed.

11. A control device for a character, characterized in that, A graphical user interface is provided through a first terminal device, the graphical user interface displaying at least a portion of the game scene, and the control device includes: The obstacle determination module is used to determine at least one obstacle that needs to be avoided within a preset distance range of the target virtual character; The function construction module is used to construct a distance field function corresponding to each obstacle based on the current speed of the target virtual character, the movement speed of each obstacle, and the shape of each obstacle. When the movement speed of an obstacle indicates that the obstacle is a stationary obstacle, the distance field function corresponding to the obstacle is determined according to the mapping relationship between at least one target basic graphic constituting the obstacle and the distance field function. When the movement speed of an obstacle indicates that the obstacle is a moving obstacle, the distance field function corresponding to the obstacle is determined according to the tangent at the boundary position of the obstacle's shape, the distance field function corresponding to the shape of the obstacle, and the distance field function corresponding to each tangent. The obstacle avoidance speed determination module is used to determine the obstacle avoidance conditions satisfied by the target virtual character based on the distance field function corresponding to each obstacle, and to determine the target obstacle avoidance speed for controlling the target virtual character to avoid obstacles based on the obstacle avoidance conditions satisfied by the target virtual character; wherein, the obstacle avoidance conditions satisfied by the target virtual character are that the target virtual character will collide with the obstacle if it moves at the current speed, or the target virtual character will not collide with the obstacle if it moves at the current speed; The movement control module is used to control the target virtual character to move at the target obstacle avoidance speed.

12. An electronic device, characterized in that, include: The device includes a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is in operation, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the control method for a role as described in any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the control method for a role as described in any one of claims 1 to 10.

Citation Information

Patent Citations

  • Virtual character moving method and apparatus

    CN105056528A

  • Collision detection method and device, storage medium and electronic device

    CN110180182A