A method and device for controlling AI characters in games
By obtaining information about the virtual character's following points and movement influencing factors, and controlling the intelligent movement of the AI character, it solves the problem of mechanical and rigid following of the AI character, achieves a more natural and realistic following effect, and enhances the game experience.
Patent Information
- Application Number
- CN202111138858.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-27
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-09-27
AI Technical Summary
AI characters in existing games are not realistic enough when following players. They are mechanical, stiff, and stupid. They cannot effectively perceive the terrain environment and obstacles, resulting in collisions and penetrations, and cannot form beautiful and natural formation movements.
By obtaining multiple follow points corresponding to the position of the virtual character, the target point of the AI character is determined and based on information on factors affecting movement, such as obstacles, distance and terrain environment, the AI character is controlled to move intelligently, avoid obstacles and adjust the movement speed. , to achieve a more natural and reasonable following.
It improves the authenticity and smoothness of the AI character's following, avoids collisions and intersections, forms a beautiful and natural formation movement, and enhances the game experience.
Smart Images

Figure CN113827974B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of pathfinding control technology, and in particular to a method for controlling an AI character in a game and a device for controlling an AI character in a game. Background Art
[0002] Currently, in many RPG (Role-Playing Game) games, there are often some AI (Artificial Intelligence) characters accompanying players. These AI characters are different from other characters that players encounter in the game world. They can fight and interact with players, provide help when players need it, and play a role in some key plots. The existence of these AI characters allows players to better integrate themselves into the game and reduce the loneliness of players in the game.
[0003] When the player moves, these AI characters also need to follow the player at all times. How AI characters follow players is a question worth studying. A good following strategy can make AI characters follow players smoothly and naturally, and produce various interesting changes and interactions during the following process, ultimately improving the realism and fun of the game. However, the AI characters in the prior art do not perform realistically when following players, and there are problems such as mechanical, stiff, and stupid following movements. Summary of the invention
[0004] In view of the fact that the above-mentioned AI character does not perform realistically when following the player, and there are problems such as the following movement being mechanical, stiff, and stupid, an embodiment of the present invention is proposed to provide an AI character control method in a game and a corresponding AI character control device in a game that overcomes the above-mentioned problems or at least partially solves the above-mentioned problems.
[0005] The embodiment of the present invention discloses a method for controlling an AI character in a game, wherein a graphical user interface is provided through a terminal device, and the content displayed by the graphical user interface includes at least part of a game scene, and the game scene includes at least one virtual character and at least one AI character corresponding to the virtual character, including:
[0006] Acquire a plurality of follow-up points corresponding to the position of the virtual character;
[0007] Determine a target point corresponding to each of the at least one AI character from the multiple follow-up points, and assign the target point to the at least one AI character;
[0008] Respectively determining motion influencing factor information corresponding to the at least one AI character;
[0009] According to the motion influencing factor information, control the at least one AI character to move to the target point.
[0010] Optionally, the sports influencing factor information includes any one of the following:
[0011] Obstacles between the at least one AI character and the target point; the distance between the at least one AI character and the virtual character; the terrain environment and moving direction of the virtual character.
[0012] Optionally, when the motion influencing factor information is an obstacle between the at least one AI character and the target point, controlling the at least one AI character to move to the target point according to the motion influencing factor information includes:
[0013] When there is no obstacle between the at least one AI character and the target point, controlling the at least one AI character to move in a straight line to the target point;
[0014] When there is an obstacle between the at least one AI character and the target point, a path finding path is determined through a path finding interface of the game engine, and the at least one AI character is controlled to move to the target point according to the path finding path.
[0015] Optionally, when there is no obstacle between the at least one AI character and the target point, controlling the at least one AI character to move in a straight line to the target point includes:
[0016] A detection ray is emitted to the target point according to the current position of the at least one AI character, and when the detection ray does not collide with the virtual object in the game scene, the at least one AI character is controlled to move in a straight line to the target point.
[0017] Optionally, when the motion influencing factor information is the distance between the at least one AI character and the virtual character, controlling the at least one AI character to move to the target point according to the motion influencing factor information includes:
[0018] determining a current moving speed of the at least one AI character according to the distance and an original moving speed of the at least one AI character;
[0019] Control at least one AI character to move to the target location according to the current moving speed.
[0020] Optionally, when the distance between the at least one AI character and the virtual character is greater than a first preset threshold, the current moving speed is greater than the original moving speed;
[0021] When the distance between the at least one AI character and the virtual character is less than a second preset threshold, the current moving speed is less than the original moving speed.
[0022] Optionally, when the motion influencing factor information is the terrain environment and the moving direction of the virtual character, controlling the at least one AI character to move to the target point according to the motion influencing factor information includes:
[0023] If the terrain environment where the virtual character is located is a narrow environment, determining a position at a preset distance in front of the virtual character as the target position according to the moving direction of the virtual character;
[0024] Control the at least one AI character to move to the target position.
[0025] Optionally, it also includes:
[0026] When the position of the virtual character changes, controlling the at least one AI character to maintain the current motion state and move within a preset time;
[0027] After the preset time, the target point is re-determined according to the changed position of the virtual character, and the at least one AI character is controlled to move to the target point according to the motion influencing factor information.
[0028] Optionally, before the step of controlling the at least one AI character to move to the target point according to the motion influencing factor information, the method further includes:
[0029] A collision body is added to the at least one AI character.
[0030] Optionally, the following points have corresponding weight values, and determining the target points corresponding to the at least one AI character from the multiple following points includes:
[0031] The target points respectively corresponding to the at least one AI character are determined from the multiple following points according to the weight values.
[0032] Optionally, after the step of acquiring a plurality of following points corresponding to the position of the virtual character, the method further includes:
[0033] sequentially determining a current operation point from the multiple follow-up points, and emitting a detection ray to the current operation point according to the position of the virtual character;
[0034] When the detection ray collides with a virtual object in the game scene, the currently operated point is removed from the multiple follow-up points.
[0035] The embodiment of the present invention further discloses an AI character control device in a game, which provides a graphical user interface through a terminal device, wherein the content displayed by the graphical user interface includes at least part of a game scene, wherein the game scene includes at least one virtual character and at least one AI character corresponding to the virtual character, including:
[0036] A point acquisition module, used to acquire a plurality of follow-up points corresponding to the position of the virtual character;
[0037] A point allocation module, used to determine the target points corresponding to the at least one AI character from the multiple follow-up points, and allocate the target points to the at least one AI character;
[0038] A factor information determination module, used to respectively determine the motion influencing factor information corresponding to the at least one AI character;
[0039] The AI character movement control module is used to control the at least one AI character to move to the target point according to the movement influencing factor information.
[0040] The embodiment of the present invention further discloses an electronic device, including:
[0041] A processor and a storage medium, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-readable instructions to perform the method as described in any one of the embodiments of the present invention.
[0042] An embodiment of the present invention further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described in any one of the embodiments of the present invention is executed.
[0043] The embodiments of the present invention include the following advantages:
[0044] In an embodiment of the present invention, multiple follow-up points corresponding to the position of a virtual character are obtained; target points corresponding to at least one AI character are determined from the multiple follow-up points, and the target points are assigned to at least one AI character; motion influencing factor information corresponding to at least one AI character is determined; and at least one AI character is controlled to move to the target point according to the motion influencing factor information. Multiple follow-up points corresponding to the position of the virtual character are generated by pre-design, and these follow-up points are assigned to different AI characters, so that the AI characters are highly versatile and can be expanded from a single AI character to multiple AI characters. The AI characters can move together in a beautiful and reasonable formation, and adjust their positions according to the positions of teammates and players at all times. Moreover, by determining the motion influencing factor information corresponding to at least one AI character, the AI character can intelligently avoid the player character or teammate character or obstacles in the environment when moving. For example, the AI character can sense the changes in the surrounding terrain and avoid it in advance before it hits an obstacle, or the movement of the AI character will not ignore the collision with the player character and the teammate character, and will not intersect with the player character and the teammate character in various ways, or the AI can predict the movement direction of the virtual character controlled by the player and respond accordingly in time to avoid hindering the movement of the virtual character controlled by the player, or when the player controls the virtual character to start and stop repeatedly, the AI character can identify this behavior based on a certain algorithm and respond more reasonably to avoid repeated stops and starts caused by mindless following. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0046] Figure 1 is a flowchart of a method for controlling an AI character in a game provided by an embodiment of the present invention;
[0047] Figure 2 is a schematic diagram of a following point provided by an embodiment of the present invention;
[0048] Figure 3 This is a method provided by an embodiment of the present invention. Figure 2 The schematic diagram of the following point being blocked by an obstacle is shown;
[0049] Figure 4 is a structural block diagram of an AI character control device in a game provided by an embodiment of the present invention;
[0050] Figure 5is a structural block diagram of an electronic device of the present invention;
[0051] Figure 6 It is a structural block diagram of a computer-readable storage medium of the present invention. DETAILED DESCRIPTION
[0052] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] In the prior art, many AI characters in games only implement the function of automatic following, but the requirements for the authenticity, smoothness and rationality of the AI characters' following movements are relatively low, so the following problems often occur:
[0054] 1. When the AI character is following the movement, it cannot perceive the changes in the terrain environment and obstacles, causing the AI character to bump into obstacles and then avoid them during the following process, giving players a feeling that the AI character is very stupid.
[0055] 2. The AI character ignores the collision with the player character and other NPC characters when following the movement, resulting in various interweavings between the AI character and the player character or other NPC characters during the following process, giving the player a feeling that the AI character is very rough.
[0056] 3. When following the movement of the player character or other teammate characters, the AI character cannot perceive the movement of the player character or other teammate characters, which causes the AI character to often hinder the movement of the player character or other teammate characters during the following process, and is unable to form a more beautiful and natural formation to move together, giving players a feeling that the AI character is very stiff.
[0057] 4. When following the movement of the player character, the AI character cannot predict the direction of the player character's movement, causing the AI character to follow the player character step by step and often stop and go, giving the player a feeling that the AI character is very mechanical.
[0058] For example, the AI character following scheme in The Last Of Us achieves the authenticity and rationality of a single player following, but its AI character following scheme is highly customized and has poor versatility, and cannot be expanded to the following movement of multiple AI characters. Another example is the AI character following scheme in Final Fantasy XV, which achieves the authenticity and smoothness of multiple people following, but this scheme has a rather arbitrary control over the movement logic of the AI characters, and cannot make the entire AI character form a beautiful and natural formation to move together, nor does it predict the movement trajectory of the player.
[0059] In order to solve the problem that the above-mentioned AI characters are not realistic enough when following players, and the following movements are relatively mechanical, stiff, and stupid, etc., in an embodiment of the present invention, multiple following points corresponding to the positions of virtual characters are obtained; target points corresponding to at least one AI character are determined from the multiple following points, and the target points are assigned to at least one AI character; motion influencing factor information corresponding to at least one AI character is determined respectively; and at least one AI character is controlled to move to the target point according to the motion influencing factor information. Multiple following points corresponding to the positions of virtual characters are generated by pre-design, and these following points are assigned to different AI characters, so that the AI characters are highly versatile and can be expanded from a single AI character to multiple AI characters. The AI characters can move together in a beautiful and reasonable formation, and adjust their positions according to the positions of teammates and players at all times. Moreover, by determining the motion influencing factor information corresponding to at least one AI character, the AI character can intelligently avoid the player character or teammate character or obstacles in the environment when moving. For example, the AI character can sense the changes in the surrounding terrain and avoid it in advance before it hits an obstacle, or the movement of the AI character will not ignore the collision with the player character and teammate character, and will not have various kinds of interweaving with the player character and teammate character, or the AI character can predict the player's movement direction and respond accordingly in time to avoid hindering the player's movement, or when the player character starts and stops repeatedly, the AI character can identify this behavior based on a certain algorithm and make a more reasonable response to avoid repeated stops and starts caused by mindless following.
[0060] In one embodiment of the present invention, the AI character control method in the game can be run on a local terminal device or a server. When the AI character control method in the game is run on a server, the AI character control method in the game can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
[0061] In an optional implementation, various cloud applications can be run under the cloud interaction system, such as cloud games. Taking cloud games as an example, cloud games refer to a game mode based on cloud computing. In the operation mode of cloud games, the operating body of the game program and the main body of the game screen presentation are separated. The storage and operation of the AI character control method in the game are completed on the cloud game server. The role of the client device is used for receiving and sending data and presenting the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a first terminal device, a TV, a computer, a handheld computer, etc.; but the AI character control method in the game is performed by the cloud game server in the cloud. When playing the game, the player operates the client device to send an operation instruction to the cloud game server. The cloud game server runs the game according to the operation instruction, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.
[0062] In an optional embodiment, taking a game as an example, a local terminal device stores a game program and is used to present a game screen. The local terminal device is used to interact with the player through a graphical user interface, that is, the game program is downloaded and installed by an electronic device and run conventionally. The local terminal device may provide the graphical user interface to the player in a variety of ways, for example, it may be rendered and displayed on a display screen of the terminal, or provided to the player through a holographic projection. For example, the local terminal device may include a display screen and a processor, the display screen is used to present a graphical user interface, the graphical user interface includes a game screen, and the processor is used to run the game, generate a graphical user interface, and control the display of the graphical user interface on the display screen.
[0063] Reference Figure 1 , shows a flowchart of a method for controlling an AI character in a game provided by an embodiment of the present invention, and provides a graphical user interface through a terminal device. The terminal device may be the local terminal device mentioned above, or a client device in a cloud gaming system. The content displayed by the graphical user interface includes at least part of a game scene, and the game scene includes at least one virtual character and at least one AI character corresponding to the virtual character, and may specifically include the following steps:
[0064] Step 101, obtaining a plurality of follow-up points corresponding to the position of the virtual character;
[0065] The game of the embodiment of the present invention can be run in a terminal device, which can be a portable mobile terminal, such as a smart phone, a wearable device, a personal digital assistant (PDA), a point of sales (POS), a car computer, etc., or an electronic device such as a laptop, a tablet computer, and an IPAD. The terminal device can have a touch screen, and for the convenience of operation, the touch screen is used to replace the mouse or keyboard. The touch screen is composed of a touch detection component and a touch screen controller. The touch detection component is installed in front of the display screen to detect the user's touch position and then transmit the relevant information to the touch screen controller. The main function of the touch screen controller is to receive touch information from the touch point detection device, convert it into touch point coordinates, and then transmit it to the central processing unit (CPU); it can also receive commands sent by the CPU and execute them. When a finger, a stylus or other operating medium applies pressure (or force) to the touch screen installed at the front end of the display, the touched position is detected by the touch screen controller and sent to the CPU through an interface (such as an RS-232 serial port, USB, etc.).
[0066] The graphical user interface is obtained by running the game application on the terminal device and rendering it on the touch screen of the terminal device. The content displayed by the graphical user interface includes at least part of the game scene, wherein the game scene may include at least one virtual character, and the virtual character may be a virtual unit of the game controlled by the player through the terminal device. In addition, the game scene may also include at least one AI character corresponding to the virtual character, which is some characters accompanying the virtual character controlled by the player and can assist the virtual character controlled by the player in fighting or interacting.
[0067] When the AI character is following, the AI character should be in a reasonable position relative to the virtual character controlled by the player. In the embodiment of the present invention, some AI character following points can be pre-designed and generated, such as Figure 2 As shown in the figure, by defining the distance and angle behind the player character, a series of points can be obtained. Since there are often multiple AI characters in the formation movement process, multiple follow-up points are required. However, the space behind the player character is limited. In order to avoid multiple AI characters standing too close together, the distance between the follow-up points and the player character can be designed to be different. According to the distance between the follow-up points and the player character, the follow-up points can also be divided into different levels, such as Figure 2 There are two levels of follow-up points, including 3 points in the first level and 2 points in the second level.
[0068] In actual game scenes, obstacles may affect some desired locations, making them unreachable. Therefore, it is also necessary to be able to sense the environment between the virtual character and the follow-up point to avoid obstacles between the location of the follow-up point or between the virtual character and the follow-up point. In a specific implementation, the environment may be sensed by emitting detection rays, which is not limited in the embodiments of the present invention.
[0069] In a preferred embodiment of the present invention, after step 101, the method may further include the following steps:
[0070] The current operation point is determined from the multiple following points in sequence; a detection ray is emitted to the current operation point according to the position of the virtual character; when the detection ray collides with a virtual object in the game scene, the current operation point is removed from the multiple following points.
[0071] Specifically, the current operation point is determined from multiple following points in turn, and a detection ray is emitted to the current operation point according to the position of the virtual character. When the detection ray collides with a virtual object in the game scene, the current operation point can be eliminated from the multiple following points; when the detection ray does not collide with the virtual object in the game scene, the step of determining the current operation point from multiple following points is returned to, and the next following point is determined as the current operation point, and the step of emitting the detection ray to the current operation point according to the position of the virtual character is continued until all the following points are traversed.
[0072] As an example, Figure 3 As shown, for Figure 2 In the following points shown, since there is an obstacle between the virtual character and the following points, the obstacle blocks two following points, namely the first layer point and the second layer point on the right side. These two following points can be eliminated to avoid assigning them to the AI character.
[0073] In addition, after obtaining multiple following points corresponding to the position of the virtual character, weights can also be set for these following points, such as "following points closest to the player are prioritized", "following points behind the player are prioritized", etc., and points equal to the number of AIs are selected through weights and assigned to AI characters through subsequent steps.
[0074] Step 102, determining target points corresponding to the at least one AI character from the multiple follow-up points, and assigning the target points to the at least one AI character;
[0075] Specifically, the goal of assigning follow-up points can be to make each AI character move as little distance as possible, and the distance moved by each AI character is preferably relatively uniform, so that the visual formation adjustment is small. In a specific implementation, the target points corresponding to at least one AI character can be determined by exhaustively enumerating the schemes for assigning follow-up points to all AI characters, calculating the sum of the distances between all AI characters and their follow-up points in each scheme, and then selecting the scheme with the smallest sum of distances as the final scheme, thereby determining the target points corresponding to at least one AI character, and assigning the target points to at least one AI character.
[0076] Step 103, respectively determining the motion influencing factor information corresponding to the at least one AI character;
[0077] The motion influencing factor information may be some information that can affect the motion state of the AI character, including obstacles between the AI character and the target point, the distance between the AI character and the virtual character, the terrain environment and movement direction of the virtual character, etc.
[0078] In a specific implementation, for each AI character, the corresponding motion influencing factor information may be one or more. For example, there may be obstacles between the AI character and the target point. At the same time, the distance between the AI character and the virtual character is far. In this case, it is necessary to re-plan the path for the AI character and control the AI character to accelerate its movement to quickly catch up with the virtual character.
[0079] Step 104: Control the at least one AI character to move to the target point according to the motion influencing factor information.
[0080] In an embodiment of the present invention, after determining the motion influencing factor information corresponding to each AI character, at least one AI character can be controlled to move to a target point according to the motion influencing factor information, so that the AI character can intelligently avoid player characters, teammate characters, or obstacles in the environment when moving.
[0081] In a preferred embodiment of the present invention, the sports influencing factor information includes any one of the following:
[0082] Obstacles between the at least one AI character and the target point; the distance between the at least one AI character and the virtual character; the terrain environment and moving direction of the virtual character.
[0083] In a specific implementation, it is possible to detect whether there is an obstacle between the AI character and the target point by means of ray detection. When there is an obstacle, the AI character needs to avoid the obstacle when moving to the target point. The distance between the AI character and the virtual character is calculated by the distance formula between the two points, and the movement speed of the AI character is controlled according to the distance between the two. When the distance between the two is far, the movement speed of the AI character is increased, and when the distance between the two is close, the movement speed of the AI character is reduced. In addition, the terrain environment in which the virtual character is located can also affect the movement of the AI character. When the environment in which the virtual character is located is relatively narrow, in order to avoid the AI character blocking the movement of the virtual character, the AI character needs to be controlled according to the terrain environment and movement direction of the virtual character.
[0084] It should be noted that the motion influencing factor information may also be set to other information as required, and the embodiment of the present invention does not limit this.
[0085] In a preferred embodiment of the present invention, when the motion influencing factor information is an obstacle between the at least one AI character and the target point, the step 104 includes:
[0086] When there is no obstacle between the at least one AI character and the target point, the at least one AI character is controlled to move in a straight line to the target point; when there is an obstacle between the at least one AI character and the target point, a path finding path is determined through the path finding interface of the game engine, and the at least one AI character is controlled to move to the target point according to the path finding path.
[0087] In an embodiment of the present invention, when there is no obstacle between the AI character and the target point, the AI character can be directly controlled to move in a straight line to the target point; when there is an obstacle between the AI character and the target point, the AI character needs to avoid the obstacle to avoid clipping. The pathfinding path can be determined through the pathfinding interface of the game engine, and the AI character can be controlled to move to the target point according to the pathfinding path.
[0088] Specifically, after setting the target point corresponding to the AI character, each AI character needs to move to the target point, which involves the problem of movement path. In most cases, the distance between the AI character and the target point is relatively close, so here we try to emit rays from the current position of the AI character to the target point to determine whether it can move in a straight line to the target point. If an obstacle is encountered, the game engine pathfinding interface is called to obtain the path.
[0089] In a preferred embodiment of the present invention, when there is no obstacle between the at least one AI character and the target point, controlling the at least one AI character to move straight to the target point comprises:
[0090] A detection ray is emitted to the target point according to the current position of the at least one AI character, and when the detection ray does not collide with the virtual object in the game scene, the at least one AI character is controlled to move in a straight line to the target point.
[0091] Specifically, for each AI character, a detection ray can be emitted to the target point according to the current position of the AI character. When the detection ray does not collide with the virtual object in the game scene, it means that there is no obstacle between the AI character and the target point. At this time, the AI character can be directly controlled to move in a straight line to the target point.
[0092] In a preferred embodiment of the present invention, when the motion influencing factor information is the distance between the at least one AI character and the virtual character, the step 104 includes:
[0093] Determine the current moving speed of the at least one AI character according to the distance and the original moving speed of the at least one AI character; and control the at least one AI character to move to the target point according to the current moving speed.
[0094] Because the AI character will inevitably encounter obstacles during the movement, and the moving route is likely to be longer than the moving path of the player character, it is necessary to increase the moving speed of the AI character at an appropriate time to ensure that the AI character can keep up with the virtual character controlled by the player, otherwise the distance between the AI character and the virtual character will become larger and larger; at the same time, when the AI character approaches the following point, the moving speed must be reduced to maintain the moving state to avoid the situation of stopping and starting. In an embodiment of the present invention, the current moving speed of the AI character can be determined according to the distance between the virtual character and the AI character and the original moving speed of the AI character, and the character can be controlled to move to the target point according to the current moving speed.
[0095] Specifically, the speed (speed_rate) can be calculated by the following formula:
[0096]
[0097] Wherein, r1 is the first preset threshold value, which is used to limit the movement of the virtual character when the distance between the virtual character and the AI character is close, r2 is the second preset threshold value, which is used to limit the movement of the virtual character when the distance between the virtual character and the AI character is far, S is the preset distance length, and distance is the distance between the virtual character and the AI character. As an example, r1=2, r2=7, s=15. After the rate is calculated, the current moving speed can be calculated according to the rate and the original moving speed, where the current moving speed is equal to the product of the original moving speed and the rate.
[0098] In an embodiment of the present invention, when the distance between the at least one AI character and the virtual character is greater than a first preset threshold, the current moving speed is greater than the original moving speed; when the distance between the at least one AI character and the virtual character is less than a second preset threshold, the current moving speed is less than the original moving speed.
[0099] Among them, the first preset threshold value can be a preset maximum distance threshold value. When the distance between the AI character and the virtual character is greater than the first preset threshold value, it means that the distance between the AI character and the virtual character is far. At this time, it is necessary to speed up the movement speed of the AI character so that the AI character can catch up with the virtual character as soon as possible. The second preset threshold value can be a preset minimum distance threshold value. When the distance between the AI character and the virtual character is less than the second preset threshold value, it means that the distance between the AI character and the virtual character is close. At this time, it is necessary to reduce the movement speed of the AI character to avoid the AI character following the virtual character too closely and blocking the movement of the virtual character. In addition, when the distance between the AI character and the virtual character is between the first preset threshold value and the second preset threshold value, the AI character can be controlled to move to the target point at a uniform speed according to the original movement speed.
[0100] In a preferred embodiment of the present invention, when the motion influencing factor information is the terrain environment and moving direction of the virtual character, the step 104 includes:
[0101] If the terrain environment where the virtual character is located is a narrow environment, a position at a preset distance in front of the virtual character is determined as a target position according to the moving direction of the virtual character; and the at least one AI character is controlled to move to the target position.
[0102] In an embodiment of the present invention, if the terrain environment where the virtual character is located is a narrow environment, a position at a preset distance in front of the virtual character is determined as the target position according to the moving direction of the virtual character, and the AI character is controlled to move to the target position.
[0103] Specifically, in order to prevent the characters from interweaving, physical capsules are added to the player characters and AI characters, so the virtual characters controlled by the player and the AI characters will block each other. In order to improve the gaming experience, the AI characters need to avoid the movement of the player characters. In open areas, the AI characters only need to add a certain offset according to the moving direction of the virtual characters to successfully avoid the virtual characters. However, in narrow areas, the AI characters do not have so much space for avoidance. For example, the player character leads the AI characters across a single-plank bridge. At this time, the player character wants to turn back, and these AI characters can no longer continue to move in formation. Here, the method of letting these AI characters temporarily not maintain formation, but to find a path to a distant position in the moving direction of the virtual characters is adopted. In this way, the AI characters and the virtual characters move in the same direction and will not block the virtual characters.
[0104] In the implementation, it is necessary to detect the environment where the virtual character is located in real time, and to detect whether the terrain environment where the virtual character is located is a narrow environment by presetting a narrow zone detection method. As an example, by emitting detection rays, detection rays are emitted around the virtual character. Rays shorter than a certain distance are obstacle rays, and rays longer than a certain distance are non-obstruction rays. The proportion of obstacle rays to the total number of rays is counted. If the proportion value is higher than a certain preset threshold (preset value, such as 0.8), it means that the virtual character is in a narrow zone, that is, whether the terrain environment where the virtual character is located is a narrow environment.
[0105] In a preferred embodiment of the present invention, the method may further include the following steps:
[0106] When the position of the virtual character changes, the at least one AI character is controlled to maintain the current motion state and move within a preset time; after the preset time, the target point is re-determined according to the changed position of the virtual character, and according to the motion influencing factor information, the at least one AI character is controlled to move to the target point.
[0107] In an embodiment of the present invention, the preset time may be a pre-set time length used to control the delayed response of the AI character. When the position of the virtual character changes, the AI character is controlled to maintain the current motion state and move within the preset time. After the preset time, the target point is re-determined according to the changed position of the virtual character, and at least one AI character is controlled to move to the target point according to the motion influencing factor information.
[0108] Specifically, if the behavior of the AI character is exactly the same as the virtual character controlled by the player, that is, when the virtual character takes a step, the AI character also takes a step, and when the virtual character stops, the AI character also stops instantly. At the same time, if the movement trend of the AI character and the virtual character is exactly the same, the performance will be similar to "following closely", which will affect the perception and be unnatural. Therefore, a delayed response and inertial following mechanism is adopted here, that is, when the position of the virtual character changes, the AI character system will not refresh the following point immediately, but there will be a certain time delay; at the same time, due to delayed response, sometimes the AI character will have no point to follow, so here the AI character is allowed to continue to move in the current state for a certain period of time. This mechanism can effectively alleviate the phenomenon of the AI character "following closely" and make the performance more natural.
[0109] In a preferred embodiment of the present invention, before step 104, the method further includes:
[0110] A collision body is added to the at least one AI character.
[0111] In an embodiment of the present invention, a collision body may be added to the AI character so that the AI character can intelligently avoid obstacles in the environment during movement.
[0112] In a preferred embodiment of the present invention, the following points have corresponding weight values, and the determining of the target points corresponding to the at least one AI character from the multiple following points includes:
[0113] The target points respectively corresponding to the at least one AI character are determined from the multiple following points according to the weight values.
[0114] In the embodiment of the present invention, the following points may be set to have corresponding weight values, and when determining the target point, the target point corresponding to each AI character is determined from multiple following points according to the weight value.
[0115] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0116] Reference Figure 4, shows a structural block diagram of an AI character control device in a game provided by an embodiment of the present invention, wherein a graphical user interface is provided through a terminal device, and the content displayed by the graphical user interface includes at least part of a game scene, and the game scene includes at least one virtual character and at least one AI character corresponding to the virtual character, and specifically may include the following modules:
[0117] A point acquisition module 401 is used to acquire a plurality of follow-up points corresponding to the position of the virtual character;
[0118] A point allocation module 402 is used to determine the target points corresponding to the at least one AI character from the multiple follow-up points, and allocate the target points to the at least one AI character;
[0119] A factor information determination module 403, used to respectively determine the motion influencing factor information corresponding to the at least one AI character;
[0120] The AI character movement control module 404 is used to control the at least one AI character to move to the target point according to the motion influencing factor information.
[0121] In a preferred embodiment of the present invention, the sports influencing factor information includes any one of the following:
[0122] Obstacles between the at least one AI character and the target point; the distance between the at least one AI character and the virtual character; the terrain environment and moving direction of the virtual character.
[0123] In a preferred embodiment of the present invention, when the motion influencing factor information is an obstacle between the at least one AI character and the target point, the AI character movement control module 404 includes:
[0124] A first movement control submodule, configured to control the at least one AI character to move in a straight line to the target point when there is no obstacle between the at least one AI character and the target point;
[0125] The second movement control submodule is used to determine a path finding path through the path finding interface of the game engine when there is an obstacle between the at least one AI character and the target point, and control the at least one AI character to move to the target point according to the path finding path.
[0126] In a preferred embodiment of the present invention, the first movement control submodule includes:
[0127] An obstacle detection unit is used to emit a detection ray to the target point according to the current position of the at least one AI character, and when the detection ray does not collide with the virtual object in the game scene, control the at least one AI character to move in a straight line to the target point.
[0128] In a preferred embodiment of the present invention, when the motion influencing factor information is the distance between the at least one AI character and the virtual character, the AI character movement control module 404 includes:
[0129] a current moving speed determining submodule, configured to determine a current moving speed of the at least one AI character according to the distance and an original moving speed of the at least one AI character;
[0130] The third movement control submodule is used to control at least one AI character to move to the target point according to the current movement speed.
[0131] In a preferred embodiment of the present invention, when the distance between the at least one AI character and the virtual character is greater than a first preset threshold, the current moving speed is greater than the original moving speed;
[0132] When the distance between the at least one AI character and the virtual character is less than a second preset threshold, the current moving speed is less than the original moving speed.
[0133] In a preferred embodiment of the present invention, when the motion influencing factor information is the terrain environment and moving direction of the virtual character, the AI character movement control module 404 includes:
[0134] a target position determination submodule, for determining, if the terrain environment in which the virtual character is located is a narrow environment, a position at a preset distance in front of the virtual character according to the moving direction of the virtual character as a target position;
[0135] The fourth movement control submodule is used to control the at least one AI character to move to the target position.
[0136] In a preferred embodiment of the present invention, it also includes:
[0137] A motion state maintaining submodule, used to control the at least one AI character to maintain a current motion state and move within a preset time when the position of the virtual character changes;
[0138] The target point refresh submodule is used to redetermine the target point according to the changed position of the virtual character after the preset time, and control the at least one AI character to move to the target point according to the motion influencing factor information.
[0139] In a preferred embodiment of the present invention, it also includes:
[0140] The collision body adding module is used to add a collision body to the at least one AI character.
[0141] In a preferred embodiment of the present invention, the point allocation module 402 includes:
[0142] The target point determination submodule is used to determine the target points corresponding to the at least one AI character from the multiple following points according to the weight value.
[0143] In a preferred embodiment of the present invention, the device further comprises:
[0144] A point detection module, used to determine the point of current operation from the multiple follow-up points in sequence, and emit a detection ray to the point of current operation according to the position of the virtual character;
[0145] The point removal module is used to remove the currently operated point from the multiple follow-up points when the detection ray collides with the virtual object in the game scene.
[0146] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0147] The embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, including:
[0148] A processor 501 and a storage medium 502, wherein the storage medium 502 stores machine-readable instructions executable by the processor 501, and when the electronic device is running, the processor 501 executes the machine-readable instructions to execute the method as described in any one of the embodiments of the present invention. The specific implementation method and technical effect are similar and will not be repeated here.
[0149] The embodiment of the present invention also provides a computer readable storage medium, such as Figure 6 As shown, the storage medium stores a computer program 601, and the computer program 601 is executed by a processor to execute a method as described in any one of the embodiments of the present invention. The specific implementation method and technical effect are similar and will not be described here.
[0150] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0151] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0152] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0153] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0154] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0155] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0156] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0157] The above is a detailed introduction to an AI character control method in a game and an AI character control device in a game provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for a person skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for controlling an AI character in a game, characterized in that: Providing a graphical user interface through a terminal device, wherein the content displayed by the graphical user interface includes at least a portion of a game scene, wherein the game scene includes at least one virtual character and at least one AI character corresponding to the virtual character, including: Acquire a plurality of following points corresponding to the position of the virtual character; wherein, when a plurality of AI characters form a formation to follow the movement of the at least one virtual character, the plurality of following points are divided into different levels according to different distances from the virtual character; Determine a target point corresponding to each of the at least one AI character from the multiple follow-up points, and assign the target point to the at least one AI character; Respectively determining motion influencing factor information corresponding to the at least one AI character; According to the motion influencing factor information, control the at least one AI character to move to the target point; wherein the motion influencing factor information includes any one of the following: obstacles between the at least one AI character and the target point; the distance between the at least one AI character and the virtual character; the terrain environment and moving direction of the virtual character; The method further comprises: When the position of the virtual character changes, controlling the at least one AI character to maintain the current motion state and move within a preset time; After the preset time, the target point is re-determined according to the changed position of the virtual character, and the at least one AI character is controlled to move to the target point according to the motion influencing factor information.
2. The method according to claim 1, characterized in that When the motion influencing factor information is an obstacle between the at least one AI character and the target point, controlling the at least one AI character to move to the target point according to the motion influencing factor information includes: When there is no obstacle between the at least one AI character and the target point, controlling the at least one AI character to move in a straight line to the target point; When there is an obstacle between the at least one AI character and the target point, the at least one AI character is controlled to move to the target point according to a preset path finding path.
3. The method according to claim 2, characterized in that When there is no obstacle between the at least one AI character and the target point, controlling the at least one AI character to move straight to the target point includes: A detection ray is emitted to the target point according to the current position of the at least one AI character, and when the detection ray does not collide with the virtual object in the game scene, the at least one AI character is controlled to move in a straight line to the target point.
4. The method according to claim 1, characterized in that When the motion influencing factor information is the distance between the at least one AI character and the virtual character, controlling the at least one AI character to move to the target point according to the motion influencing factor information includes: determining a current moving speed of the at least one AI character according to the distance and an original moving speed of the at least one AI character; Control at least one AI character to move to the target location according to the current moving speed.
5. The method according to claim 4, characterized in that When the distance between the at least one AI character and the virtual character is greater than a first preset threshold, the current moving speed is greater than the original moving speed; When the distance between the at least one AI character and the virtual character is less than a second preset threshold, the current moving speed is less than the original moving speed.
6. The method according to claim 1, characterized in that When the motion influencing factor information is the terrain environment and the moving direction of the virtual character, controlling the at least one AI character to move to the target point according to the motion influencing factor information includes: If the terrain environment where the virtual character is located is a narrow environment, determining a position at a preset distance in front of the virtual character as the target position according to the moving direction of the virtual character; Control the at least one AI character to move to the target position.
7. The method according to claim 1, characterized in that Before the step of controlling the at least one AI character to move to the target point according to the motion influencing factor information, the method further includes: A collision body is added to the at least one AI character.
8. The method according to claim 1, characterized in that The following points have corresponding weight values, and determining the target points corresponding to the at least one AI character from the multiple following points includes: The target points respectively corresponding to the at least one AI character are determined from the multiple following points according to the weight values.
9. The method according to claim 1, characterized in that: After the step of acquiring a plurality of follow-up points corresponding to the position of the virtual character, the method further includes: sequentially determining a current operation point from the multiple follow-up points, and emitting a detection ray to the current operation point according to the position of the virtual character; When the detection ray collides with a virtual object in the game scene, the currently operated point is removed from the multiple follow-up points.
10. A device for controlling an AI character in a game, characterized in that: Providing a graphical user interface through a terminal device, wherein the content displayed by the graphical user interface includes at least a portion of a game scene, wherein the game scene includes at least one virtual character and at least one AI character corresponding to the virtual character, including: A point acquisition module, used to acquire a plurality of follow-up points corresponding to the position of the virtual character; wherein, when a plurality of AI characters form a formation to follow the movement of at least one virtual character, the plurality of follow-up points are divided into different levels according to different distances from the virtual character; A point allocation module, used to determine the target points corresponding to the at least one AI character from the multiple follow-up points, and allocate the target points to the at least one AI character; A factor information determination module, used to respectively determine the motion influencing factor information corresponding to the at least one AI character; wherein the motion influencing factor information includes any one of the following: obstacles between the at least one AI character and the target point; the distance between the at least one AI character and the virtual character; the terrain environment and moving direction of the virtual character; An AI character movement control module, configured to control the at least one AI character to move to the target point according to the movement influencing factor information; The device also includes: A motion state maintaining submodule, used for controlling the at least one AI character to maintain a current motion state and move within a preset time when the position of the virtual character changes; The target point refresh submodule is used to redetermine the target point according to the changed position of the virtual character after the preset time, and control the at least one AI character to move to the target point according to the motion influencing factor information.
11. An electronic device, characterized in that: include: A processor and a storage medium, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-readable instructions to perform the method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 9 is executed.
Citation Information
Patent Citations
Character control device, character control method, recording medium, and program
CN101151076A
