CN114470777A - Role control method and device, electronic equipment and readable storage medium - Google Patents

Role control method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN114470777A
CN114470777A CN202210129019.0A CN202210129019A CN114470777A CN 114470777 A CN114470777 A CN 114470777A CN 202210129019 A CN202210129019 A CN 202210129019A CN 114470777 A CN114470777 A CN 114470777A
Authority
CN
China
Prior art keywords
obstacle
speed
virtual character
target virtual
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210129019.0A
Other languages
Chinese (zh)
Inventor
郑运辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202210129019.0A priority Critical patent/CN114470777A/en
Publication of CN114470777A publication Critical patent/CN114470777A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/55Controlling game characters or game objects based on the game progress
    • A63F13/57Simulating properties, behaviour or motion of objects in the game world, e.g. computing tyre load in a car race game
    • A63F13/577Simulating properties, behaviour or motion of objects in the game world, e.g. computing tyre load in a car race game using determination of contact between game characters or objects, e.g. to avoid collision between virtual racing cars

Abstract

The application provides a role control method, a role control device, an electronic device and a readable storage medium, wherein the role control method comprises the following steps: determining at least one obstacle needing to be avoided within the preset distance range of the target virtual character; 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; determining obstacle avoidance conditions met 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 conditions met by the target virtual character; and controlling the target virtual character to move at the target obstacle avoidance speed. According to the method and the device, the moving speed capable of generating the avoiding effect is accurately and quickly determined according to the distance field of each obstacle which is probably met, and the accuracy and the efficiency of determining the avoiding speed are improved.

Description

Role control method and device, electronic equipment and readable storage medium
Technical Field
The present application relates to the field of game technologies, and in particular, to a method and an apparatus for controlling a character, an electronic device, and a readable storage medium.
Background
With the gradual maturity of the industry and the accumulation of experience of players, the standards for screen display in the current games are gradually improved, and the insertion and collision among virtual characters are unacceptable, so that it is very important to ensure that the virtual characters cannot collide and insert with other virtual characters when moving and stopping.
At present, a common method for preventing virtual characters from colliding is dynamic avoidance, when an individual moves to a target point, avoidance behaviors can be generated on other individuals and obstacles, an optimal path is sought to the target point, in the existing algorithm, the individual needs to be represented by a circle, the obstacles need to be represented by line segments or simple polygons, a speed updating strategy is difficult to meet various conditions occurring in a game, and an obstacle avoidance effect is not ideal.
Disclosure of Invention
In view of this, an object of the present application is to provide a role control method, apparatus, electronic device and readable storage medium, which can accurately and quickly determine a moving speed capable of generating an avoidance effect according to a distance field of each obstacle that may be encountered, so as to improve accuracy and efficiency of determining an obstacle avoidance speed.
In a first aspect, an embodiment of the present application provides a method for controlling a character, where a first terminal device provides a graphical user interface, and at least a part of a game scene is displayed on the graphical user interface, and the method includes:
determining at least one obstacle needing to be avoided within a preset distance range of the target virtual character;
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;
determining obstacle avoidance conditions met 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 conditions met by the target virtual character; the obstacle avoidance condition met by the target virtual character is that the target virtual character moves at the current speed and can collide with an obstacle, or the target virtual character moves at the current speed and can not collide with the obstacle;
and controlling the target virtual character to move at the target obstacle avoidance speed.
In one possible embodiment, the indicated rate of movement in the speed of movement of the obstacle includes a rate of movement of zero and a rate of movement of non-zero;
the moving speed of the obstacle is zero, and a distance field function corresponding to the obstacle is constructed through the following steps:
determining at least one target basic figure forming the shape of the obstacle according to the shape of the obstacle;
and determining the distance field function corresponding to the obstacle based on the mapping relation between the preset basic graphic graph and the distance field function and the at least one target basic graphic.
In one possible embodiment, where the rate of movement of the obstacle is not zero, the distance field function corresponding to the obstacle is constructed by:
determining two tangent lines from the position of the target virtual character to the position of the obstacle boundary based on the boundary of the shape of the obstacle;
determining 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, which are respectively calculated;
and offsetting the target distance field function according to the offset to obtain a distance field function corresponding to the obstacle.
In one possible embodiment, the offset is determined by:
determining the relative speed of the target virtual character and the obstacle based on the current speed of the target virtual character and the moving speed of the obstacle;
and determining the offset based on the relative speed and a preset adjusting coefficient.
In one possible implementation, the obstacle avoidance condition satisfied by the target virtual character is determined by:
for each obstacle, determining a distance field value between the target virtual character and the obstacle based on a distance field function corresponding to the obstacle according to the moving speed of the obstacle and the current speed of the target virtual character;
determining a distance field value with the smallest value from the determined plurality of distance field values, and determining the distance field value as a 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, determining that the target virtual character moves at the current speed and cannot collide with an obstacle;
and if the target distance field value is smaller than a preset value threshold value, determining that the target virtual character moves at the current speed and can collide with an obstacle.
In a possible implementation manner, the target virtual character satisfies an obstacle avoidance condition that the target virtual character moves at a current speed without colliding with an obstacle, and the target obstacle avoidance speed is determined by the following steps:
and determining the current speed of the target virtual character as the target obstacle avoidance speed.
In a possible implementation manner, the obstacle avoidance condition that the target virtual character meets is that the target virtual character moves at the current speed and collides with an obstacle, and the target obstacle avoidance speed is determined through the following steps:
determining a plurality of sampling speeds;
determining at least one candidate velocity based on the distance field value corresponding to each sampling velocity;
screening out the target obstacle avoidance speed from the determined at least one candidate speed according to a preset expected speed of the target virtual character; wherein the speed direction of the desired speed is a direction of the destination of the target avatar relative to the target avatar.
In one possible embodiment, the sampling speed is determined by:
determining a sampling range of a speed direction according to the rotation range of the target virtual character in a frame range;
and determining a plurality of sampling speeds according to a preset sampling increment by taking the expected direction of the expected speed as a reference in the sampling range.
In one possible embodiment, the candidate speed is determined by:
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 a distance field value corresponding to the sampling speed according to the distance field function of each obstacle relative to the sampling speed;
and determining the sampling speed of which the corresponding distance field value is greater than or equal to a preset value threshold value in the plurality of sampling speeds as a candidate speed.
In a possible implementation manner, the screening out the target obstacle avoidance speed from the determined at least one candidate speed according to a preset desired speed of the target virtual character includes:
determining the distance between each sampling speed and the expected speed, and determining the sampling speed with the minimum distance from the expected speed as the target obstacle avoidance speed; or
And determining the variation between each sampling speed and the current speed of the target virtual character, and determining the sampling speed with the minimum variation between the sampling speed and the current speed of the target virtual character as the target obstacle avoidance speed.
In a second aspect, an embodiment of the present application provides a control apparatus for a character, where a graphical user interface is provided by a first terminal device, and at least a part of a game scene is displayed on the graphical user interface, the control apparatus includes:
the obstacle determining module is used for determining at least one obstacle needing to be avoided within a preset distance range of the target virtual character;
a function building module, configured to build 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;
the avoidance speed determining module is used for determining the obstacle avoidance conditions met by the target virtual character according to the distance field function corresponding to each obstacle, and determining the target obstacle avoidance speed for controlling the target virtual character to avoid according to the obstacle avoidance conditions met by the target virtual character; the target virtual character meets the obstacle avoidance condition that the target virtual character moves at the current speed and can collide with an obstacle, or the target virtual character moves at the current speed and can not collide with the obstacle;
and the movement control module is used for controlling the target virtual role to move at the target obstacle avoidance speed.
In a third aspect, an embodiment of the present application further provides an electronic device, including: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, when the electronic device runs, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to execute the steps of the method for controlling the role according to any one of the first aspect.
In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the role control method according to any one of the first aspect.
After determining at least one obstacle in a preset distance range of a target virtual character in a game scene, constructing 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; and determining obstacle avoidance conditions met by the target virtual character according to the distance field function corresponding to each obstacle, further determining a target obstacle avoidance speed for controlling the target virtual character to move, and controlling the target virtual character to move in the game scene at the target obstacle avoidance speed after determining the target obstacle avoidance speed which can enable the target virtual character to avoid the obstacle. According to the method and the device, the moving speed capable of generating the avoiding effect can be accurately and quickly determined according to the distance field of each obstacle which is possibly met, and the accuracy and the efficiency of determining the avoiding speed are improved.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 is a flowchart of a role control method according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of a distance field of a moving obstacle according to an embodiment of the present application;
FIG. 3 is a flowchart of another role control method provided in the embodiments of the present application;
FIG. 4 is a flowchart of another role control method provided in the embodiments of the present application;
fig. 5 is a schematic structural diagram of a role control device according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. Every other embodiment that can be obtained by a person skilled in the art without making creative efforts based on the embodiments of the present application falls within the protection scope of the present application.
First, an application scenario to which the present application is applicable will be described. The application can be applied to the technical field of games, along with the gradual maturity of the industry and the accumulation of player experience, the standard of picture display is gradually improved in the current games, and the interlude collision between virtual characters is unacceptable, so how to guarantee that the virtual characters can not collide and interlude with other virtual characters when moving and stopping is very important.
At present, a commonly used method for preventing collision between virtual roles is dynamic avoidance, and the following is defined: when the individual moves to the target point, the avoidance behavior can be generated for other individuals and obstacles, and the optimal path is searched for going to the target point. There are different solutions to this type of problem, and the solution implemented based on VO algorithm, such as RVO algorithm, ORCA algorithm, etc., is widely used.
Specifically, in the VO algorithm, an individual gives up all speeds that may collide in the future, and makes all the responsibility for avoiding collision, so that the updated speed deviates too much from the original speed, and therefore, the speed needs to deviate again in the original speed direction when the speed is updated next time, and the process is repeated, so that the jitter occurs. Therefore, responsibility is shared between two avoidance parties in the RVO algorithm, the updated speed is guaranteed not to be too high, secondary correction is not needed, and avoidance is guaranteed not to shake through the method. The ORCA algorithm proposes an avoidance scheme based on linear programming. And finding the minimum offset from the VO algorithm and applying the minimum offset to the individual, thereby providing a good speed updating scheme, avoiding the problem of jitter and ensuring avoidance.
However, the above algorithms all have some necessary preconditions, i.e. the individual has to be represented by a circle and the obstacle by a line segment or a simple polygon. In addition, the RVO algorithm cannot provide a good speed updating scheme, and a sampling strategy of the updating speed is difficult to make. The ORCA algorithm is high in calculation complexity and difficult to expand, the scheme is difficult to add to a complex graph, and when an individual and a target connecting line are completely vertical to an obstacle, the individual can stop, so that the effect of dynamic avoidance cannot be achieved.
Based on this, the embodiment of the application provides a role control method to improve accuracy and efficiency of determining the obstacle avoidance speed.
Referring to fig. 1, fig. 1 is a flowchart illustrating a role control method according to an embodiment of the present disclosure. Providing a graphical user interface through a first terminal device, wherein at least part of a game scene is displayed on the graphical user interface, and the control method comprises the following steps:
s101, determining at least one obstacle needing to be avoided within the preset distance range of the target virtual character.
S102, 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.
S103, determining obstacle avoidance conditions met 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 conditions met by the target virtual character.
And S104, controlling the target virtual role to move at the target obstacle avoidance speed.
According to the role control method provided by the embodiment of the application, the moving speed capable of generating the avoiding effect is accurately and quickly determined according to the distance field of each obstacle which is probably met, and the accuracy and the efficiency of determining the avoiding speed are improved.
The following describes exemplary steps in an embodiment of the present application:
s101, determining at least one obstacle needing to be avoided within the preset distance range of the target virtual character.
In the embodiment of the present application, the target virtual Character is a Non-Player Character (NPC) that is not controlled by the Player in the game scene, and the target virtual Character can move in the game scene at a certain movement speed. In other embodiments, the target virtual character is a player character controlled by a player.
Here, in the embodiment of the present application, it is acquired that the current speed of the target avatar is a vector including the speed and the speed direction of the moving speed of the target avatar.
Here, the setting for the obstacle may be a stationary obstacle (e.g., a building, a tree, etc. in a game scene), or may be a moving obstacle (e.g., a player character, a non-player character, or a moving vehicle, etc.).
In order to reduce the calculation amount of obstacle avoidance calculation for the target virtual character, the position of the obstacle can be set within a preset distance from the target virtual character, and in the current calculation process, the obstacle far away from the target virtual character is not calculated first.
Specifically, for a stationary obstacle, the distance between the obstacle and a target virtual character in a game scene can be directly calculated according to the position coordinates of the obstacle and the coordinates of the target virtual character, and comparison is performed according to a preset distance to determine whether the obstacle needs to be avoided in the calculation; and for the obstacle capable of moving, the moving speed of the obstacle and the relative speed between the obstacle and the target virtual character are also considered, the distance between the obstacle and the target virtual character is comprehensively calculated, and whether the obstacle needs to be avoided in the calculation is determined according to the comparison of the preset distance.
S102, 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.
In the embodiment of the application, a distance field corresponding to each obstacle is constructed for each obstacle according to the current speed of the target virtual character and the moving speed of each obstacle.
Here, the distance field is a field function that defines a mapping of input points to distances. The distance field defines the closest distance of any point in the field to all reference objects, for example, for one dimension, the closest distance of any point to all points; for a two-dimensional scene, the distance between any point and the edge of all objects is the nearest distance; for a three-dimensional scene, it is the closest distance of any point to the surface of all objects.
For example, for a target graph circle, taking the center of the circle as the circle, the distance between each point and the center of the circle needs to be calculated, and the distance relationship between the calculated distance and the radius of the circle needs to be represented, which is the distance field corresponding to the target graph circle.
The Distance Field also includes a Signed Distance Field (SDF), where the Signed Distance Field (SDF) is calculated in the present application, and the sign is divided into positive and negative, specifically, after the coordinate and the shortest Distance from any point to the surface are obtained, a vector formed by a selected point to the obtained closest point is used to perform a point multiplication operation with a normal vector, and whether the directions are consistent is determined, if so, the Distance Field sign is positive, otherwise, the Distance Field sign is negative.
It should be noted that, in the embodiment of the present application, the distance field is constructed by using the idea of representing a velocity region where a collision is likely to occur based on a velocity space, and when constructing the distance field, the way of constructing the distance field is different depending on whether an obstacle is a stationary object (whether the moving velocity of the obstacle is zero), which will be described below:
when the moving speed of the obstacle is zero (when the obstacle is a static obstacle), constructing a distance field function corresponding to the obstacle by the following steps:
a 1: determining at least one target basic figure forming the shape of the obstacle according to the shape of the obstacle;
a 2: and determining the distance field function corresponding to the obstacle based on the mapping relation between the preset basic graph and the distance field function and the at least one target basic graph.
In the embodiment of the application, when the obstacle is static, the shape of the obstacle can be directly determined, after the shape of the obstacle is determined, the composition of the shape of the obstacle is determined, if the shape of the obstacle is formed by a single simple basic shape (circle, rectangle, triangle, and the like), the corresponding distance field function can be directly determined according to the mapping relation between the preset basic shape and the distance field and the simple basic shape forming the obstacle; if the shape of the obstacle is not a complex shape formed by joining a plurality of simple shapes, but a simple basic shape, the determined shape of the obstacle needs to be divided, the complex shape of the obstacle can be divided into a combination of a plurality of basic patterns, the distance field function corresponding to each basic pattern is determined, and the distance field function of the obstacle having a complex shape is expressed based on the distance field function corresponding to each basic pattern forming the shape of the obstacle.
(II) when the moving speed of the obstacle is not zero (when the obstacle is a moving obstacle), constructing a distance field function corresponding to the obstacle by the following steps:
b 1: determining two tangent lines from the position of the target virtual character to the position of the obstacle boundary based on the boundary of the shape of the obstacle.
In the application, for a moving obstacle, the relative speed between a target virtual character and the moving obstacle can be calculated, a distance field of the obstacle is represented by a graph similar to a cone, the target virtual character is abstracted to be a point, the radius of the target virtual character is superposed on the radius of the obstacle, the boundaries of two strip shapes of the obstacle are determined, and a tangent line reaching the positions of the boundaries of the shapes of the obstacle is drawn from the positions of the target virtual character.
In this way, a moving obstacle can be divided into three parts, a circle and two rays.
Referring to fig. 2, fig. 2 is a schematic diagram of a distance field of a moving obstacle according to an embodiment of the present disclosure, as shown in fig. 2, taking the shape of the moving obstacle as a circle as an example, the distance field of the moving obstacle may be composed of the obstacle itself (circle 210), a ray 220 and a ray 230, as shown in fig. 2, a target virtual character is abstracted to a point 240, and a tangent line is drawn from the point 240 to the boundary of the circle 210 to determine the ray 220 and the ray 230.
b 2: and determining 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, which are respectively calculated.
In the embodiment of the present application, the target distance field function is determined based on the distance field function corresponding to the shape of the obstacle calculated in step b1 and the distance field function corresponding to each tangent.
Here, the distance field function corresponding to the obstacle having the simple shape may be found, and the distance field function corresponding to the moving obstacle may be obtained by combining the calculated distance field function corresponding to the shape of the obstacle and the distance field function corresponding to each tangent.
Where the shape of the obstacle is a circle, for example, the distance field function of the moving obstacle can be represented as:
max(circle.SDF-value,min(ray1.SDF-value,ray2.SDF-value));
sdf-value, where circle represents a distance field value that is circular in shape; SDF-value represents the distance field value of ray 1; SDF-value represents the distance field value ray2 is.
Here, when calculating the distance field value for the obstacle, the minimum value between ray1 and ray2 is selected, and the minimum value is compared with the circular distance field value, and a larger value between the two is selected and determined as the distance field value of the obstacle.
b 3: and offsetting the target distance field function according to the offset to obtain a distance field function corresponding to the obstacle.
In this embodiment, in order to avoid the phenomenon of jitter when the current speed of the target virtual character is adjusted, an offset may be determined first, and the distance field constructed in step b2 is subjected to offset correction to obtain a distance field function corresponding to the obstacle.
The reason why the shake occurs when the current speed of the target virtual character is adjusted is that when the speed of the obstacle is adjusted, all the speeds at which the target virtual character may collide in the future are abandoned, which causes the updated speed to deviate from the original speed too much, so that the speed needs to deviate again in the original speed direction when the speed is updated next time, and the shake occurs when the process is repeated.
In order to solve the above jitter problem, the problem of excessive adjustment when the current speed of the target virtual character is adjusted is avoided by considering both the speeds of the avoidance party and the target virtual character, so as to prevent the jitter phenomenon, therefore, in the embodiment of the present application, the jitter phenomenon is avoided by setting an offset, specifically, the offset is determined by the following steps:
c 1: and determining the relative speed of the target virtual character and the obstacle based on the current speed of the target virtual character and the moving speed of the obstacle.
In the embodiment of the application, the relative speed between the target virtual character and the obstacle is calculated according to the current speed of the target virtual character and the moving speed of the obstacle.
Here, in order to prevent the occurrence of the chattering phenomenon in the speed adjustment process, it is necessary to distribute the avoidance speed to both the target virtual character and the obstacle, and therefore it is necessary to determine the relative speed between them at the time of calculation.
c 2: and determining the offset based on the relative speed and a preset adjusting coefficient.
In the embodiment of the application, after the relative speed between the target virtual character and the obstacle is determined, an adjustment coefficient needs to be set, and then the offset is finally determined.
Here, the preset adjustment coefficient may be set according to an adjustment requirement or historical adjustment data, and is not specifically limited in the embodiment of the present application.
Here, the offset amount may be determined by the following formula:
Δs=X*(Vagent1-Vagent2);
wherein Δ s is an offset; x is a preset adjusting coefficient; vagent1Is the current speed of the target avatar; vagent2Is the moving speed of the obstacle; x may be set to 0.5 in a particular embodiment.
S103, determining obstacle avoidance conditions met 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 conditions met by the target virtual character.
In the embodiment of the application, the obstacle avoidance condition met by the target virtual character is determined according to the distance field function corresponding to each obstacle, so that the current speed of screening the target virtual character is determined according to the met obstacle avoidance condition, and the target obstacle avoidance speed capable of controlling the target virtual character to avoid is screened.
The obstacle avoidance condition met by the target virtual character is that the target virtual character can collide with an obstacle when moving at the current speed, or the target virtual character can not collide with the obstacle when moving at the current speed.
The screening of the target obstacle avoidance speed is determined by the moving speed of the target virtual character, in the speed space, the position space information can be converted into the speed space, specifically, for the avoided main body a, the main body a currently encounters the obstacle B, both the obstacle B and the obstacle B are abstracted into a circle, at this time, a can be used as a mass point, and the radius of a is added to the radius of B, that is, the radius length of B is equal to the radius of a + the original radius of B. At this time, two tangent lines are emitted from a to B in the circle, and the region surrounded by these two rays constitutes the VO region of B. Intuitively, as long as a selects the velocity in the VO region, it must collide with B at some future point. In other words, this block of VO regions marks the speed at which a collision with B is likely to occur. The success of avoidance can be guaranteed as long as VOs of all obstacles are obtained and the speed which is not in the VO area is selected, namely the target obstacle avoidance speed determined in the application is the screened speed which does not collide with any obstacle.
Here, when the obstacle avoidance condition is calculated, the method includes the following steps: (1) selecting a starting point P and a ray emission direction Dir; (2) calculating a distance field value SDF-value of the current point; (3) stepping the length of the absolute value SDF-value along the direction of the ray Dir to obtain a new point P ', namely P' ═ P + | SDF-value | Dir; (4) if the SDF value of P 'is 0, the target point is reached, or the iteration times exceed a given value, the iteration is ended, and P' is returned, otherwise, the step (1) is skipped until the condition is met.
It should be noted that, according to the study on the process of calculating the obstacle avoidance condition, it can be concluded that, if the distance field value of the starting point P is greater than or equal to zero, the obtained distance field value of the end point P' 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 end point is also less than or equal to zero.
Based on the above conclusion, a manner of determining an obstacle avoidance condition that the target virtual character satisfies may be provided, please refer to fig. 3, where fig. 3 is a flowchart of another method for controlling a character according to an embodiment of the present application, and as shown in fig. 3, the obstacle avoidance condition that the target virtual character satisfies is determined through the following steps:
s301, for each obstacle, determining a distance field value between the target virtual character and the obstacle based on a distance field function corresponding to the obstacle according to the moving speed of the obstacle and the current speed of the target virtual character.
In the embodiment of the present application, it is necessary to calculate a distance field value of a target virtual character relative to each obstacle, and substitute the distance field value into a distance field function corresponding to the obstacle according to a moving speed of the obstacle and a current speed of the target virtual character, so as to determine a corresponding distance field function value.
Here, in the conventional distance field value calculation process, it is necessary to carry in position coordinates between two points for calculation, and in the present embodiment, calculation is carried out by substituting the current speed of the target virtual character and the moving speed of the obstacle.
Specifically, the moving speed includes a moving speed and a moving direction, and two component speed vectors are used to obtain a distance field value between the target virtual character and the obstacle by substituting the speed vector of the target virtual character and the speed vector of the obstacle into the corresponding distance field function.
S302, a distance field value with the minimum value is determined from the determined distance field values, and the distance field value is determined to be a target distance field value corresponding to the target virtual character.
In this embodiment, distance field computation is performed on each obstacle according to step S301 to determine a plurality of distance field values, a distance field value with a smallest value is selected from the plurality of distance field values, and the selected distance field value with the smallest value is determined as a target distance field value corresponding to the target virtual character.
Here, since the distance field value calculation for each obstacle is very fast, only a few simple operations (addition and multiplication between two-dimensional vectors) are required, and there are usually not too many obstacles around a target virtual character that needs to generate avoidance behavior, each obstacle corresponds to a distance field function, and the distance field value calculation for each obstacle can be performed to obtain the minimum value thereof, so as to obtain the final target distance field value.
And S303, if the value of the target distance field is larger than or equal to a preset value threshold, determining that the target virtual character moves at the current speed and cannot collide with an obstacle.
In an embodiment of the present application, if the calculated target distance field value is greater than or equal to the preset value threshold, it may be determined that the target avatar is moving at the current speed without hitting an obstacle.
Wherein the preset numerical threshold is zero.
S304, if the target distance field value is smaller than a preset value threshold, determining that the target virtual character moves at the current speed and can collide with an obstacle.
In the embodiment of the present application, if the calculated value of the target distance field is smaller than the preset value threshold, it may be determined that the target avatar moves at the current speed and may collide with an obstacle, and at this time, the moving speed of the target avatar needs to be adjusted.
In a possible implementation manner, the target virtual character satisfies different obstacle avoidance conditions, and the manner of determining the target obstacle avoidance speed is also different, which is described below:
the obstacle avoidance condition met by the target virtual character is that the target virtual character moves at the current speed and cannot collide with an obstacle, and the target obstacle avoidance speed is determined through the following steps:
d 1: and determining the current speed of the target virtual character as the target obstacle avoidance speed.
In an embodiment of the application, if the value of the target distance field is greater than or equal to a preset value threshold, it is determined that the target avatar moves at the current speed without hitting an obstacle.
It is to be noted that, in the present application, the obstacle avoidance speed may be determined according to a relationship between the target distance field value and the preset value threshold, and when it is determined that the target avatar does not collide with the obstacle when moving at the current speed, that is, the current speed of the target avatar is not in the speed set where collision may occur, the obstacle may be avoided by moving at the current speed.
(ii) the obstacle avoidance condition that the target virtual character satisfies is that the target virtual character moves at the current speed and does not collide with an obstacle, please refer to fig. 4, fig. 4 is a flowchart of another character control method provided in the embodiment of the present application, and as shown in fig. 4, the target obstacle avoidance speed is determined through the following steps:
s401, determining a plurality of sampling speeds.
In the embodiment of the application, because the current speed of the target virtual character is certain to collide with the obstacle, different sampling speeds need to be collected again to determine the avoiding speed capable of avoiding the obstacle.
In one possible embodiment, the sampling speed is determined by:
e 1: and determining the sampling range of the speed direction according to the rotation range of the target virtual character in a frame range.
In the embodiment of the application, in a game scene, the turning speed of a target virtual character in one frame may be required not to exceed a certain range due to the requirement of display clarity, and therefore, a sampling range of speed sampling can be set according to the requirement.
Here, the sampling range of the velocity direction may be the same as the range in which the target virtual character rotates within one frame, for example, both are not more than 5 °; the sampling range in the speed direction may be smaller than the range in which the target virtual character rotates within one frame, and the specific sampling range may be specifically limited according to the sampling requirement and the sampling requirement.
e 2: and determining a plurality of sampling speeds according to a preset sampling increment by taking the expected direction of the expected speed as a reference in the sampling range.
In the embodiment of the present application, within the sampling range determined in step e1, a plurality of sampling speeds are determined according to a preset sampling increment with the desired speed direction as a reference.
Here, in order to ensure that the adjusted speed direction does not deviate from the destination of movement of the target virtual character, it is necessary to sample the speed in the desired direction of the desired speed with reference to the desired direction.
Wherein the speed direction of the desired speed is a direction of the destination of the target avatar relative to the target avatar.
It is worth noting that when the sampling speed is determined, equidistant sampling can be performed within a sampling range through the same sampling increment, incremental sampling can also be performed on the expected speed, a direction with a smaller difference with the expected speed is sampled first, and if the speed obtained after sampling can meet a certain requirement (for example, the distance from the expected speed to the expected speed is smaller than a certain value, the requirement is considered to be met), the speed can be immediately returned to be used as the sampling speed of the target virtual role, the iteration times are reduced, and the speed screening efficiency is improved.
S402, at least one candidate speed is determined based on the distance field value corresponding to each sampling speed.
In the embodiment of the application, a distance field value corresponding to each sampling speed is determined according to the plurality of sampling speeds determined in step S401, and then at least one candidate speed is screened out.
Here, the at least one candidate speed means that the distance field value corresponding to the sampling speed is greater than or equal to a preset value threshold, that is, the candidate speed is not within a speed region where a collision is likely to occur, and when the target avatar travels to the destination at the candidate speed, the target avatar will not collide with each obstacle.
In one possible embodiment, the candidate speed is determined by:
f 1: and 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 a distance field value corresponding to the sampling speed according to the distance field function of each obstacle relative to the sampling speed.
In the embodiment of the application, for each sampling speed, based on the sampling speed and the sampling direction of the sampling speed, and according to the moving speed of each obstacle, a distance field function of each obstacle relative to the sampling speed is constructed, the distance field function of the sampling speed is determined, and a distance field value corresponding to the sampling speed is determined.
Specifically, the manner of determining the distance field value of the sampling rate is the same as the manner of determining the distance field value of the target avatar, and is not described here again.
f 2: and determining the sampling speed of which the corresponding distance field value is greater than or equal to a preset value threshold value in the plurality of sampling speeds as a candidate speed.
In the embodiment of the present application, the sampling velocity of the step f1, in which the distance field value corresponding to the plurality of sampling velocities is greater than or equal to the preset value threshold, is determined as the candidate velocity, so as to ensure that the candidate velocity is not within the velocity region where collision is likely to occur, and when the target avatar travels to the destination at the candidate velocity, collision with each obstacle will not occur.
It is worth noting that when determining that the candidate speed for avoiding the target can be obtained, the sampling process can be directly ended, and the candidate speed is directly determined as the target obstacle avoiding speed, so that the efficiency of determining the target obstacle avoiding speed is improved; 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, so that the accuracy of determining the target obstacle avoidance speed is improved.
S403, screening out the target obstacle avoidance speed from the determined at least one candidate speed according to the preset expected speed of the target virtual role.
In the embodiment of the application, the target obstacle avoidance speed is screened from the determined at least one candidate speed according to the expected speed of the target virtual character.
In a possible implementation manner, the step of "screening out the target obstacle avoidance speed from the determined at least one candidate speed according to a preset expected speed of the target virtual character" includes:
determining the distance between each sampling speed and the expected speed, and determining the sampling speed with the minimum distance from the expected speed as the target obstacle avoidance speed; or
And determining the variation between each sampling speed and the current speed of the target virtual character, and determining the sampling speed with the minimum variation between the sampling speed and the current speed of the target virtual character as the target obstacle avoidance speed.
In the embodiment of the present application, two ways of screening candidate speeds are given:
one is to determine a candidate speed with the minimum distance from the expected speed as a target obstacle avoidance speed by taking the expected speed as a reference. The distance between the candidate speed and the desired speed may be determined by a candidate speed and a candidate direction of the candidate speed, and a desired speed and a desired direction of the desired speed.
And the other is that the sampling speed with the minimum variation with the current speed of the target virtual character is determined as the target obstacle avoidance speed on the basis of the current speed of the target virtual character. The amount of change between the candidate speed and the current speed may be determined by a candidate speed and a candidate direction of the candidate speed, and a current speed and a current direction of the current speed.
And S104, controlling the target virtual role to move at the target obstacle avoidance speed.
In the embodiment of the application, after the target obstacle avoidance speed capable of avoiding the obstacles is determined, the target virtual character is controlled to move according to the target speed indicated by the target obstacle avoidance speed and the target direction, so that the plurality of obstacles in the game scene are avoided.
According to the role control method provided by the embodiment of the application, after at least one obstacle in a preset distance range of a target virtual role in a game scene is determined, a distance field function corresponding to each obstacle is constructed according to the current speed of the target virtual role and the moving speed of each obstacle; and determining obstacle avoidance conditions met by the target virtual character according to the distance field function corresponding to each obstacle, further determining a target obstacle avoidance speed for controlling the target virtual character to move, and controlling the target virtual character to move in the game scene at the target obstacle avoidance speed after determining the target obstacle avoidance speed which can enable the target virtual character to avoid the obstacle. According to the method and the device, the moving speed capable of generating the avoiding effect can be accurately and quickly determined according to the distance field of each obstacle which is possibly met, and the accuracy and the efficiency of determining the avoiding speed are improved.
Based on the same inventive concept, an information prompting device corresponding to the role control method is also provided in the embodiments of the present application, and as the principle of solving the problem of the device in the embodiments of the present application is similar to the role control method in the embodiments of the present application, the implementation of the device can refer to the implementation of the method, and repeated details are not repeated.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a role control device according to an embodiment of the present disclosure. As shown in fig. 5, the control device 500 includes:
the obstacle determining module 510 is configured to determine at least one obstacle to be avoided within a preset distance range of the target virtual character;
a function construction module 520, configured to construct 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;
an avoidance speed determining module 530, configured to determine, according to the distance field function corresponding to each obstacle, an obstacle avoidance condition that the target virtual character satisfies, and determine, according to the obstacle avoidance condition that the target virtual character satisfies, a target obstacle avoidance speed at which the target virtual character is controlled to avoid; the obstacle avoidance condition met by the target virtual character is that the target virtual character moves at the current speed and can collide with an obstacle, or the target virtual character moves at the current speed and can not collide with the obstacle;
and a movement control module 540, configured to control the target virtual character to move at the target obstacle avoidance speed.
In one possible embodiment, the indicated rate of movement in the speed of movement of the obstacle comprises a rate of movement of zero and a rate of movement of non-zero;
the rate of movement of the obstacle is zero, and the function construction module 520 is configured to construct a distance field function corresponding to the obstacle by:
determining at least one target basic figure forming the shape of the obstacle according to the shape of the obstacle;
and determining the distance field function corresponding to the obstacle based on the mapping relation between the preset basic graph and the distance field function and the at least one target basic graph.
In one possible embodiment, where the rate of movement of the obstacle is not zero, the function construction module 520 is configured to construct the distance field function corresponding to the obstacle by:
determining two tangent lines from the position of the target virtual character to the position of the obstacle boundary based on the boundary of the shape of the obstacle;
determining 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, which are respectively calculated;
and offsetting the target distance field function according to the offset to obtain a distance field function corresponding to the obstacle.
In a possible implementation, the function construction module 520 is configured to determine the offset by:
determining the relative speed of the target virtual character and the obstacle based on the current speed of the target virtual character and the moving speed of the obstacle;
and determining the offset based on the relative speed and a preset adjusting coefficient.
In one possible implementation, the avoidance speed determining module 530 is configured to determine the avoidance condition that the target avatar satisfies by:
for each obstacle, determining a distance field value between the target virtual character and the obstacle based on a distance field function corresponding to the obstacle according to the moving speed of the obstacle and the current speed of the target virtual character;
determining a distance field value with the smallest value from the determined plurality of distance field values, and determining the distance field value as a 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, determining that the target virtual character moves at the current speed and cannot collide with an obstacle;
and if the target distance field value is smaller than a preset value threshold value, determining that the target virtual character moves at the current speed and can collide with an obstacle.
In a possible implementation manner, the obstacle avoidance condition satisfied by the target virtual character is that the target virtual character moves at the current speed without colliding with an obstacle, and the avoidance speed determination module 530 is configured to determine the target obstacle avoidance speed by:
and determining the current speed of the target virtual character as the target obstacle avoidance speed.
In a possible implementation manner, the obstacle avoidance condition satisfied by the target virtual character is that the target virtual character moves at a current speed and collides with an obstacle, and the avoidance speed determination module 530 is configured to determine the target obstacle avoidance speed by:
determining a plurality of sampling speeds;
determining at least one candidate velocity based on the distance field value corresponding to each sampling velocity;
screening out the target obstacle avoidance speed from the determined at least one candidate speed according to a preset expected speed of the target virtual character; wherein the speed direction of the desired speed is a direction of the destination of the target avatar relative to the target avatar.
In one possible implementation, the avoidance rate determination module 530 is configured to determine the sampling rate by:
determining a sampling range of a speed direction according to the rotation range of the target virtual character in a frame range;
and determining a plurality of sampling speeds according to a preset sampling increment by taking the expected direction of the expected speed as a reference in the sampling range.
In one possible implementation, the avoidance speed determination module 530 is configured to determine the candidate speed by:
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 a distance field value corresponding to the sampling speed according to the distance field function of each obstacle relative to the sampling speed;
and determining the sampling speed of which the corresponding distance field value is greater than or equal to a preset value threshold value in the plurality of sampling speeds as a candidate speed.
In a possible implementation manner, when the avoidance speed determining module 530 is configured to screen out the target avoidance speed from the determined at least one candidate speed according to a preset desired speed of the target virtual character, the avoidance speed determining module 530 is configured to:
determining the distance between each sampling speed and the expected speed, and determining the sampling speed with the minimum distance from the expected speed as the target obstacle avoidance speed; or
And determining the variation between each sampling speed and the current speed of the target virtual character, and determining the sampling speed with the minimum variation between the sampling speed and the current speed of the target virtual character as the target obstacle avoidance speed.
According to the role control device provided by the embodiment of the application, after at least one obstacle in a preset distance range of a target virtual role in a game scene is determined, a distance field function corresponding to each obstacle is constructed according to the current speed of the target virtual role and the moving speed of each obstacle; and determining obstacle avoidance conditions met by the target virtual character according to the distance field function corresponding to each obstacle, further determining a target obstacle avoidance speed for controlling the target virtual character to move, and controlling the target virtual character to move in the game scene at the target obstacle avoidance speed after determining the target obstacle avoidance speed which can enable the target virtual character to avoid the obstacle. According to the method and the device, the moving speed capable of generating the avoiding effect can be accurately and quickly determined according to the distance field of each obstacle which is possibly met, and the accuracy and the efficiency of determining the avoiding speed are improved.
Referring to fig. 6, fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. As shown in fig. 6, the electronic device 600 includes a processor 610, a memory 620, and a bus 630.
The memory 620 stores machine-readable instructions executable by the processor 610, when the electronic device 600 runs, the processor 610 communicates with the memory 620 through the bus 630, and when the machine-readable instructions are executed by the processor 610, the steps of the role control method in the method embodiments shown in fig. 1, fig. 3, and fig. 4 may be executed.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the role control method in the method embodiments shown in fig. 1, fig. 3, and fig. 4 may be executed.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present application, and are used for illustrating the technical solutions of the present application, but not limiting the same, and the scope of the present application is not limited thereto, and although the present application is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope disclosed in the present application; such modifications, changes or substitutions do not depart from the spirit and scope of the exemplary embodiments of the present application, and are intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (13)

1. A character control method is characterized in that a graphical user interface is provided through a first terminal device, at least part of a game scene is displayed on the graphical user interface, and the control method comprises the following steps:
determining at least one obstacle needing to be avoided within a preset distance range of the target virtual character;
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;
determining obstacle avoidance conditions met 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 conditions met by the target virtual character; the obstacle avoidance condition met by the target virtual character is that the target virtual character moves at the current speed and can collide with an obstacle, or the target virtual character moves at the current speed and can not collide with the obstacle;
and controlling the target virtual character to move at the target obstacle avoidance speed.
2. The control method according to claim 1, wherein the movement rate indicated in the movement speed of the obstacle includes a movement rate of zero and a movement rate of non-zero;
the moving speed of the obstacle is zero, and a distance field function corresponding to the obstacle is constructed through the following steps:
determining at least one target basic figure forming the shape of the obstacle according to the shape of the obstacle;
and determining the distance field function corresponding to the obstacle based on the mapping relation between the preset basic graph and the distance field function and the at least one target basic graph.
3. The control method of claim 2, wherein the rate of movement of the obstacle is non-zero, and wherein the distance field function corresponding to the obstacle is constructed by:
determining two tangent lines from the position of the target virtual character to the position of the obstacle boundary based on the boundary of the shape of the obstacle;
determining 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, which are respectively calculated;
and offsetting the target distance field function according to the offset to obtain a distance field function corresponding to the obstacle.
4. A control method according to claim 3, characterized in that the offset is determined by:
determining the relative speed of the target virtual character and the obstacle based on the current speed of the target virtual character and the moving speed of the obstacle;
and determining the offset based on the relative speed and a preset adjusting coefficient.
5. The control method according to claim 1, wherein the obstacle avoidance condition satisfied by the target virtual character is determined by:
for each obstacle, determining a distance field value between the target virtual character and the obstacle based on a distance field function corresponding to the obstacle according to the moving speed of the obstacle and the current speed of the target virtual character;
determining a distance field value with the smallest value from the determined plurality of distance field values, and determining the distance field value as a 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, determining that the target virtual character moves at the current speed and cannot collide with an obstacle;
and if the target distance field value is smaller than a preset value threshold value, determining that the target virtual character moves at the current speed and can collide with an obstacle.
6. The control method according to claim 1, wherein the obstacle avoidance condition that the target virtual character satisfies is that the target virtual character moves at the current speed without colliding with an obstacle, and the target obstacle avoidance speed is determined by:
and determining the current speed of the target virtual character as the target obstacle avoidance speed.
7. The control method according to claim 1, wherein the obstacle avoidance condition that the target virtual character satisfies is that the target virtual character moves at a current speed and collides with an obstacle, and the target obstacle avoidance speed is determined by:
determining a plurality of sampling speeds;
determining at least one candidate velocity based on the distance field value corresponding to each sampling velocity;
screening out the target obstacle avoidance speed from the determined at least one candidate speed according to a preset expected speed of the target virtual character; wherein the speed direction of the desired speed is a direction of the destination of the target avatar relative to the target avatar.
8. The control method of claim 7, wherein the sampling rate is determined by:
determining a sampling range of a speed direction according to the rotation range of the target virtual character in a frame range;
and determining a plurality of sampling speeds according to a preset sampling increment by taking the expected direction of the expected speed as a reference in the sampling range.
9. The control method according to claim 7, characterized in that the candidate speed is determined by:
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 a distance field value corresponding to the sampling speed according to the distance field function of each obstacle relative to the sampling speed;
and determining the sampling speed of which the corresponding distance field value is greater than or equal to a preset value threshold value in the plurality of sampling speeds as a candidate speed.
10. The control method according to claim 7, wherein the screening out the target obstacle avoidance speed from the determined at least one candidate speed according to a preset desired speed of the target virtual character comprises:
determining the distance between each sampling speed and the expected speed, and determining the sampling speed with the minimum distance from the expected speed as the target obstacle avoidance speed; or alternatively
And determining the variation between each sampling speed and the current speed of the target virtual character, and determining the sampling speed with the minimum variation between the sampling speed and the current speed of the target virtual character as the target obstacle avoidance speed.
11. A character control apparatus for providing a graphical user interface through a first terminal device, the graphical user interface displaying at least a portion of a game scene, the control apparatus comprising:
the obstacle determining module is used for determining at least one obstacle needing to be avoided within a preset distance range of the target virtual character;
a function building module, configured to build 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;
the avoidance speed determining module is used for determining the obstacle avoidance conditions met by the target virtual character according to the distance field function corresponding to each obstacle, and determining the target obstacle avoidance speed for controlling the target virtual character to avoid according to the obstacle avoidance conditions met by the target virtual character; the obstacle avoidance condition met by the target virtual character is that the target virtual character moves at the current speed and can collide with an obstacle, or the target virtual character moves at the current speed and can not collide with the obstacle;
and the movement control module is used for controlling the target virtual role to move at the target obstacle avoidance speed.
12. An electronic device, comprising: a processor, a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is operating, the processor executing the machine-readable instructions to perform the steps of the method of controlling a character according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that a computer program is stored thereon, which computer program, when being executed by a processor, performs the steps of the method of controlling a character according to any one of claims 1 to 10.
CN202210129019.0A 2022-02-11 2022-02-11 Role control method and device, electronic equipment and readable storage medium Pending CN114470777A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210129019.0A CN114470777A (en) 2022-02-11 2022-02-11 Role control method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210129019.0A CN114470777A (en) 2022-02-11 2022-02-11 Role control method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN114470777A true CN114470777A (en) 2022-05-13

Family

ID=81479549

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210129019.0A Pending CN114470777A (en) 2022-02-11 2022-02-11 Role control method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114470777A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115657704A (en) * 2022-08-29 2023-01-31 广州建通测绘地理信息技术股份有限公司 Passive obstacle avoidance navigation method and device for aircraft and computer equipment
CN116036601A (en) * 2023-01-28 2023-05-02 腾讯科技(深圳)有限公司 Game processing method and device, computer equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115657704A (en) * 2022-08-29 2023-01-31 广州建通测绘地理信息技术股份有限公司 Passive obstacle avoidance navigation method and device for aircraft and computer equipment
CN115657704B (en) * 2022-08-29 2023-12-01 广州建通测绘地理信息技术股份有限公司 Passive obstacle avoidance navigation method and device for aircraft and computer equipment
CN116036601A (en) * 2023-01-28 2023-05-02 腾讯科技(深圳)有限公司 Game processing method and device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN114470777A (en) Role control method and device, electronic equipment and readable storage medium
CN108379832B (en) Game synchronization method and device
CN110141862B (en) Method and device for mobile control in game, electronic equipment and storage medium
JP3816375B2 (en) VIDEO GAME DEVICE, CHARACTER DISPLAY METHOD, PROGRAM, AND RECORDING MEDIUM FOR VIDEO GAME
US8909506B2 (en) Program, information storage medium, information processing system, and information processing method for controlling a movement of an object placed in a virtual space
JP2022020672A (en) Method and apparatus for processing trajectory, roadside device, cloud control platform, and computer program
US11847714B2 (en) Information processing device, information processing method, and information processing program
CN111298443A (en) Game object control method and device, electronic equipment and storage medium
CN112206511A (en) Game action synchronization method, game action synchronization device, electronic device and storage medium
KR102096196B1 (en) How to configure model objects, servers, and systems
CN112121437B (en) Movement control method, device, medium and electronic equipment for target object
WO2021117660A1 (en) Server, processing system, processing method, and program
CN116484487B (en) Wallboard reinforcement method, device, equipment and storage medium
CN111951348A (en) Method and device for determining frame selection area and electronic equipment
EP3598392B1 (en) Traversal selection of components for a geometric model
CN111167117B (en) Random walk method of illusion object, control system and storage medium thereof
CN111701242B (en) Path fitting method and device in game scene
CN108553900A (en) A method of the stackable storage Reusability based on UE engines
JP7341801B2 (en) Video game processing program and video game processing system
CN107564058B (en) Object position display method and device
CN113384890B (en) Convex polygon collision detection method
JP5290138B2 (en) Mesh changing device, mesh changing method, and program
CN111338741A (en) Task progress display method and device and storage medium
CN108499109A (en) A method of it unilateral in real time can be scaled based on UE engine implementations article
CN112884883B (en) Automatic generation method, terminal and storage medium of game track

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination