Virtual character control method and device, equipment, storage medium and program product
By performing collision detection and position matching in the virtual scene, the AI-controlled second virtual character is controlled to perform actions on the first virtual character controlled by the player, which solves the long research and development cycle, weak generalization, and high consumption of computing resources in the existing technology. problems and achieved rapid implementation.
Patent Information
- Application Number
- CN202411281534.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2025-01-14
AI Technical Summary
In the prior art, the solution of training AI-controlled NPCs through machine learning methods has a long R&D cycle, weak generalization, and consumes more computing resources, which cannot meet the needs of rapid implementation.
A method for controlling a virtual character is proposed. By determining the interactable area corresponding to the first virtual character in the virtual scene, collision detection and position matching are performed, and the second virtual character is controlled to perform specified actions toward the first virtual character.
In more complex virtual scenes, the AI-controlled second virtual character is controlled through collision detection and position matching, achieving the effects of a shorter development cycle, stronger generalization, and less consumption of computing resources, meeting the need for rapid implementation.
Smart Images

Figure CN119303302A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of electronic computers and Internet technology, and in particular to a method, device, equipment, storage medium and program product for controlling a virtual character. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the disclosure that are recited in the claims. No description herein is admitted to be prior art by inclusion in this section.
[0003] In electronic games based on electronic computers and Internet technologies, there are usually NPCs (non-player characters) controlled by AI (Artificial Intelligence) that compete with player characters controlled by players to enrich the gameplay and experience of the game.
[0004] In the related art, in order to improve the intelligence of the AI-controlled NPC, attempts are usually made to train the AI-controlled NPC through machine learning methods such as reinforcement learning and transfer learning.
[0005] However, the solution of training AI-controlled NPCs through machine learning methods has a long R&D cycle, weak generalization, and high consumption of computing resources, which cannot meet the needs of rapid implementation. Summary of the invention
[0006] In view of this, the purpose of the present disclosure is to provide a control method, device, equipment, storage medium and program product for a virtual character, which at least to a certain extent solve one of the technical problems in the related art.
[0007] Based on the above purpose, the first aspect of the exemplary embodiment of the present disclosure provides a method for controlling a virtual character, including:
[0008] Determine an interactive area corresponding to a first virtual character in a virtual scene, perform collision detection in the virtual scene based on the interactive area to obtain a candidate area, and add the candidate area to a candidate area set;
[0009] Based on the historical game data, determining a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character when the second virtual character in the virtual scene hits the first virtual character, and adding the position data pair to a position data pair set, wherein the first virtual character and the second virtual character are in hostile camps;
[0010] Matching the candidate area in the candidate area set with the position data pair in the position data pair set to obtain a matching number corresponding to the candidate area, where the matching number is used to indicate the number of data pairs when both the first position and the second position in the position data pair are located in the candidate area;
[0011] In response to determining that the distance between the current position of the second virtual character and a first candidate area in the candidate area set is less than a first distance threshold, and the number of matches corresponding to the first candidate area is not zero, determining that the second position of the position data pair is located in an alternative position data pair in the first candidate area, and determining a second candidate area corresponding to the first position of the alternative position data pair;
[0012] In response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold, controlling the second virtual character to perform a designated action toward the first virtual character.
[0013] Based on the same inventive concept, a second aspect of the exemplary embodiment of the present disclosure provides a control device for a virtual character, comprising:
[0014] A candidate area determination module is configured to determine an interactive area corresponding to a first virtual character in a virtual scene, perform collision detection in the virtual scene based on the interactive area, obtain a candidate area, and add the candidate area to a candidate area set;
[0015] a position data pair determination module configured to determine, based on historical game data, a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character when the second virtual character in the virtual scene hits the first virtual character, and add the position data pair to a position data pair set, wherein the first virtual character and the second virtual character are in an enemy camp;
[0016] an area and position matching module, configured to match the candidate area in the candidate area set with the position data pair in the position data pair set, and obtain a matching number corresponding to the candidate area, wherein the matching number is used to indicate the number of data pairs when both the first position and the second position in the position data pair are located in the candidate area;
[0017] a distance determination module, configured to, in response to determining that the distance between the current position of the second virtual character and a first candidate area in the candidate area set is less than a first distance threshold, and the number of matches corresponding to the first candidate area is not zero, determine that the second position of the position data pair is located in the candidate position data pair in the first candidate area, and determine a second candidate area corresponding to the first position of the candidate position data pair;
[0018] The action execution module is configured to control the second virtual character to execute a specified action toward the first virtual character in response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold.
[0019] Based on the same inventive concept, a third aspect of the exemplary embodiment of the present disclosure provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in the first aspect is implemented.
[0020] Based on the same inventive concept, a fourth aspect of the exemplary embodiments of the present disclosure provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method described in the first aspect.
[0021] Based on the same inventive concept, a fifth aspect of the exemplary embodiments of the present disclosure provides a computer program product, including computer program instructions. When the computer program instructions are executed on a computer, the computer executes the method described in the first aspect.
[0022] As can be seen from the above, the control method, device, equipment, storage medium and program product of virtual characters provided by the embodiments of the present disclosure include: determining an interactive area corresponding to a first virtual character in a virtual scene, performing collision detection in the virtual scene based on the interactive area to obtain a candidate area, and adding the candidate area to a candidate area set; determining, based on historical game data, a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character when a second virtual character in the virtual scene hits the first virtual character, and adding the position data pair to a position data pair set, wherein the first virtual character and the second virtual character are in an enemy camp; performing collision detection on the candidate areas in the candidate area set and the position data pairs in the position data pair set. According to the matching, the number of matches corresponding to the alternative area is obtained, and the number of matches is used to indicate the number of data pairs when the first position and the second position in the position data pair are both located in the alternative area; in response to determining that the distance between the current position of the second virtual character and the first alternative area in the set of alternative areas is less than a first distance threshold, and the number of matches corresponding to the first alternative area is not zero, determining that the second position of the position data pair is located in the alternative position data pair in the first alternative area, and determining the second alternative area corresponding to the first position of the alternative position data pair; in response to determining that the distance between the current position of the first virtual character and the second alternative area is less than a second distance threshold, controlling the second virtual character to perform a specified action to the first virtual character. Through the present disclosure, in a more complex virtual scene, the second virtual character is controlled to perform a specified action to the first virtual character based on collision detection and position matching, with a shorter R&D cycle, stronger generalization, less consumption of computing resources, and the ability to meet the needs of rapid implementation. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the present disclosure or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0024] Figure 1 A schematic diagram of an application scenario of a method for controlling a virtual character provided by an exemplary embodiment of the present disclosure;
[0025] Figure 2 A schematic flow chart of a method for controlling a virtual character provided by an exemplary embodiment of the present disclosure;
[0026] Figure 3a A schematic diagram of a collision detection method provided for an exemplary embodiment of the present disclosure;
[0027] Figure 3b Another schematic diagram of a collision detection method provided for an exemplary embodiment of the present disclosure;
[0028] Figure 4 A schematic diagram of a candidate area set provided for an exemplary embodiment of the present disclosure;
[0029] Figure 5 A schematic diagram of a set of position data pairs provided for an exemplary embodiment of the present disclosure;
[0030] Figure 6 A schematic diagram of position and area matching provided for an exemplary embodiment of the present disclosure;
[0031] Figure 7 A schematic diagram of a position and area matching result provided for an exemplary embodiment of the present disclosure;
[0032] Figure 8 A schematic diagram of ray detection provided for an exemplary embodiment of the present disclosure;
[0033] Fig. 9 A schematic diagram of a structure of a control device for a virtual character provided by an exemplary embodiment of the present disclosure;
[0034] Fig.10 A schematic structural diagram of an electronic device provided by an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0035] It is understandable that before using the technical solutions disclosed in the embodiments of this application, the type, scope of use, usage scenarios, etc. of the personal information involved in this application should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0036] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present application according to the prompt message.
[0037] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0038] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation method of the present application. Other methods that meet the relevant laws and regulations may also be applied to the implementation method of the present application.
[0039] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0040] In order to make the purpose, technical solutions and advantages of the present disclosure more clear, the principles and spirit of the present disclosure will be described with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present disclosure, and are not intended to limit the scope of the present disclosure in any way. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0041] It should be understood herein that any number of elements in the drawings is for illustration rather than limitation, and any naming is only for distinction rather than having any limiting meaning.
[0042] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the embodiments of the present disclosure do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connecting" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly. The article "one" or "a" before an element does not exclude the existence of multiple such elements.
[0043] The principle and spirit of the present disclosure are explained in detail below with reference to several representative embodiments of the present disclosure.
[0044] As described in the background technology, in electronic games based on electronic computers and Internet technologies, there are usually NPCs (non-player characters) controlled by AI (Artificial Intelligence) that compete with player characters controlled by players to enrich the gameplay and experience of the game.
[0045] In the related art, in order to improve the intelligence of the AI-controlled NPC, attempts are usually made to train the AI-controlled NPC through machine learning methods such as reinforcement learning and transfer learning.
[0046] However, the inventors of the present disclosure found that the solution of training AI-controlled NPCs through machine learning methods has a long research and development cycle, weak generalization, consumes a lot of computing resources, and cannot meet the needs of rapid implementation.
[0047] Specifically, the present disclosure provides an exemplary specific application scenario and provides an explanation based on the application scenario, in which:
[0048] The game characters include a first virtual character and a second virtual character. For example, a second virtual character competes against four first virtual characters. The main task of the first virtual character is to repair the cipher machine in the shortest time, open the door and escape from the manor to win the final victory. The main task of the second virtual character is to chase the first virtual character.
[0049] Assuming that the ratio of first and second avatar players is roughly the same, it is inevitable that the second avatar player will have to wait for a long time to wait for four first avatars to start the game. Due to the imbalance in the player ratio, different levels of AI strength are needed to control the second avatar to join the battle.
[0050] Due to the natural imbalance of asymmetric competition, the first virtual character, who is the target of the second virtual character, can only delay the pursuit of the second virtual character as much as possible through interactive points such as windows and boards as well as terrain, thereby buying more time for other first virtual characters to repair the cipher machine and thus win.
[0051] Since there is a nearly 20% difference in movement speed between the second virtual character and the first virtual character (the second virtual character moves faster than the first virtual character), the player will try to go around the same area as much as possible, and play the "Qin King around the Pillar" with the second virtual character. In the process of going around, the existence of scene collisions and interaction points will greatly hinder the use of skills of the second virtual character. Therefore, there is a need for a method that can use skills and respond with high intelligence like the player in the presence of complex scene collisions and interference from interaction points. With this method, not only will the AI be more realistic and difficult to be recognized by players, but it will also allow the first virtual character player to have a more enjoyable battle.
[0052] For a long time, in asymmetric competition, the strong side is easy to fall into the hands of the weak side in complex scenarios. The game planners design a large number of rules, which is not only cumbersome to update, but also the AI response is rigid and easy to be recognized by players.
[0053] Pure reinforcement learning and transfer learning can indeed produce very strong AI, but on the one hand, due to the long R&D cycle, the generalization is weak. On the other hand, it consumes a lot of computing resources after implementation. Today, with the increasingly frequent updates of game content, the methods of reinforcement learning and transfer learning are basically still in the theoretical and experimental stages.
[0054] In summary, whether in symmetrical 5v5 competition or asymmetrical 1v4 competition, AI's skill use and response in complex scenarios have the following problems:
[0055] The existence of scene collisions and interaction points can easily affect the use and response of the skills of the dominant party, and the weaker party players can easily "circle the pillar" or become the players' "followers", making it impossible to counter the players' behaviors in a targeted manner. Secondly, it can only be updated according to the large number of rules given by the planner, which is cumbersome, and the AI response is rigid and easy to be recognized by players. The R&D cycle of pure reinforcement learning and transfer learning is long, and the generalization is weak, which cannot meet the needs of rapid implementation.
[0056] In order to solve the above problems, the present disclosure provides a control scheme for virtual characters, which specifically includes: determining an interactive area corresponding to a first virtual character in a virtual scene, performing collision detection in the virtual scene based on the interactive area to obtain a candidate area, and adding the candidate area to a candidate area set; determining, based on historical game data, a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character when a second virtual character in the virtual scene hits the first virtual character, and adding the position data pair to a position data pair set, wherein the first virtual character and the second virtual character are in an enemy camp; matching the candidate areas in the candidate area set with the position data pairs in the position data pair set to obtain a candidate area. the number of matches corresponding to the alternative area, the number of matches being used to indicate the number of data pairs when the first position and the second position in the position data pair are both located in the alternative area; in response to determining that the distance between the current position of the second virtual character and the first alternative area in the set of alternative areas is less than a first distance threshold, and the number of matches corresponding to the first alternative area is not zero, determining that the second position of the position data pair is located in an alternative position data pair in the first alternative area, and determining a second alternative area corresponding to the first position of the alternative position data pair; in response to determining that the distance between the current position of the first virtual character and the second alternative area is less than a second distance threshold, controlling the second virtual character to perform a specified action towards the first virtual character.
[0057] Through the present disclosure, in a more complex virtual scene, the second virtual character is controlled to perform a specified action on the first virtual character based on collision detection and position matching. The research and development cycle is short, the generalization is strong, the consumption of computing resources is small, and the needs of rapid implementation can be met.
[0058] Through the method provided by the present invention, in the above-mentioned application scenario, not only the skill accuracy of the second virtual character controlled by AI can be greatly improved, but also the performance can be more diversified, thereby counteracting the circumventing behavior of the first virtual character controlled by the player, and avoiding the "follower" of the first virtual character controlled by the player to follow behind the first virtual character controlled by the player.
[0059] After introducing the basic principles of the present disclosure, various non-limiting embodiments of the present disclosure are described in detail below.
[0060] refer to Figure 1 , which is a schematic diagram of an application scenario of the virtual character control method provided by the exemplary embodiment of the present disclosure.
[0061] This application scenario includes a terminal device 101, a server 102, and a data storage system 103. The terminal device 101, the server 102, and the data storage system 103 may be connected via a wired or wireless communication network to achieve data interaction.
[0062] The terminal device 101 may be an electronic device with data transmission and multimedia input / output functions close to the user side, including but not limited to a desktop computer, a mobile phone, a mobile computer, a tablet computer, a media player, a smart wearable device, a personal digital assistant (PDA) or other electronic devices capable of realizing the above functions. The electronic device may include a processor and a display screen with a touch input function, the display screen is used to present a graphical user interface, the graphical user interface can display an application interface, and the processor is used to process application data, generate a graphical user interface, and control the display of the graphical user interface on the display screen.
[0063] Server 102 and data storage system 103 can both be independent physical servers, or a server cluster or distributed system composed of multiple physical servers. They can also be cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.
[0064] The server 102 is used to construct and provide game scenes.
[0065] In specific implementation, the game scene is a virtual scene displayed (or provided) when the application is running on the terminal device 101 or the server 102. Optionally, the virtual scene is a simulation environment of the real world, or a semi-simulation and semi-fictitious virtual environment, or a purely fictitious virtual environment. The virtual scene is any one of a two-dimensional virtual scene and a three-dimensional virtual scene, and the virtual environment can be the sky, land, ocean, etc., wherein the land includes environmental elements such as deserts and cities. Among them, the virtual scene is a scene with complete game logic of virtual objects such as user control. For example, for sandbox 3D shooting games, the virtual scene is a 3D game world for players to control virtual objects to fight. Example virtual scenes may include: at least one element of mountains, plains, rivers, lakes, oceans, deserts, skies, plants, buildings, and vehicles; for example, for 2D card games, the virtual scene is a scene for displaying released cards or displaying virtual objects corresponding to cards. Example virtual scenes may include: an arena, a decisive battlefield, or other "field" elements or other elements that can display the status of card battles; for 2D or 3D multiplayer online tactical competitive games, the virtual scene is a 2D or 3D terrain scene for virtual objects to fight. Example virtual scenes may include: canyon-style mountains, lines, rivers, classrooms, tables and chairs, podiums and other elements.
[0066] The terminal device 101 is installed with a client that communicates with the server 102 , and a user can control a first virtual character controlled by a player in a virtual scene through the client.
[0067] During specific implementation, the terminal device 101 may provide a graphical user interface, which may include: a game scene with a first virtual character controlled by a player and a second virtual character controlled by AI. The graphical user interface is obtained by executing a software application on a processor of a mobile terminal or other terminal and rendering it on a display, and may be a display screen interface of a terminal device. The graphical user interface may present the entire game scene, or only a part of the game scene. The game scene includes a plurality of static virtual objects, including ground, mountains, rocks, vegetation, buildings, etc. When the game scene is relatively large, only a part of the game scene is displayed on the graphical user interface of the terminal device during the game. Optionally, the game scene includes a controlled virtual object, which may be a first virtual character controlled by a player or a second virtual character (non player character, NPC) controlled by AI.
[0068] In specific implementation, a controlled virtual object refers to a dynamic object that can be controlled in a virtual scene. Optionally, the dynamic object can be a virtual character, a virtual object, etc. The controlled virtual object is an object controlled by a user through an input device, or an artificial intelligence (AI) set in a virtual environment through training. In a possible implementation, the user can control the controlled virtual object to move in the virtual scene, for example, control the controlled virtual object to navigate or collect virtual resources, etc., and can also control the controlled virtual object to upgrade and develop on the building object created by itself, and can also control the controlled virtual object to fight with virtual objects of other camps. Optionally, the controlled virtual object can have multiple functions, such as not only having the function of collecting virtual resources, but also having the function of fighting. Optionally, when the virtual environment is a three-dimensional virtual environment, the controlled virtual object can be a three-dimensional virtual model, each controlled virtual object has its own shape and volume in the three-dimensional virtual environment, and occupies a part of the space in the three-dimensional virtual environment. Optionally, the three-dimensional virtual object is a three-dimensional character built based on three-dimensional skeleton technology, and the controlled virtual object realizes different external images through wearable technology. In some implementations, the controlled virtual object may also be implemented using a 2.5-dimensional or 2-dimensional model.
[0069] The server 102 is used to control the second virtual character controlled by AI in the virtual scene, specifically: determining an interactive area corresponding to the first virtual character in the virtual scene, performing collision detection in the virtual scene based on the interactive area to obtain a candidate area, and adding the candidate area to a candidate area set; determining, based on historical game data, a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character when the second virtual character in the virtual scene hits the first virtual character, and adding the position data pair to a position data pair set, wherein the first virtual character and the second virtual character are in an enemy camp; matching the candidate areas in the candidate area set with the position data pairs in the position data pair set to obtain a candidate area. the number of matches corresponding to the alternative area, the number of matches being used to indicate the number of data pairs when the first position and the second position in the position data pair are both located in the alternative area; in response to determining that the distance between the current position of the second virtual character and the first alternative area in the set of alternative areas is less than a first distance threshold, and the number of matches corresponding to the first alternative area is not zero, determining that the second position of the position data pair is located in an alternative position data pair in the first alternative area, and determining a second alternative area corresponding to the first position of the alternative position data pair; in response to determining that the distance between the current position of the first virtual character and the second alternative area is less than a second distance threshold, controlling the second virtual character to perform a specified action towards the first virtual character.
[0070] The data storage system 103 is used to assist the server 102 in storing a set of candidate regions and a set of position data pairs.
[0071] Combine the following Figure 1 The control method of the virtual character according to the exemplary embodiment of the present disclosure is described by using the application scenario. It should be noted that the above application scenario is only shown to facilitate understanding of the spirit and principle of the present disclosure, and the embodiments of the present disclosure are not limited in this respect. On the contrary, the embodiments of the present disclosure can be applied to any applicable scenario.
[0072] refer to Figure 2 , which is a flow chart of a method for controlling a virtual character provided by an exemplary embodiment of the present disclosure.
[0073] The control method of the virtual character comprises the following steps:
[0074] Step S210: determining an interactive area corresponding to a first virtual character in a virtual scene, performing collision detection in the virtual scene based on the interactive area to obtain a candidate area, and adding the candidate area to a candidate area set.
[0075] Below, we will first introduce the virtual scene, specifically:
[0076] In this exemplary embodiment, the virtual scene includes a first virtual character and a second virtual character. The second virtual character chases the first virtual character, and the first virtual character escapes and evades and completes a designated task.
[0077] Among them, the first virtual character is controlled by the player, and the second virtual character can be controlled by the player or by AI. The present disclosure is aimed at the situation where the second virtual character is controlled by AI. Specifically, based on the battle data between the second virtual character controlled by the player and the first virtual character, the second virtual character controlled by AI is controlled to fight against the first virtual character controlled by the player.
[0078] The following is an introduction to how to determine the interactive area.
[0079] In this exemplary embodiment, determining the interactive area corresponding to the first virtual character in the virtual scene includes:
[0080] Determining an interactive virtual object corresponding to the first virtual character in the virtual scene;
[0081] Determining a projection area of the interactive virtual object onto a designated reference plane of the virtual scene;
[0082] The interactable area includes the projection area.
[0083] During specific implementation, if there are several interactive virtual objects in the virtual scene, the area where the interactive virtual objects are located is the interactive area.
[0084] In a specific implementation, the area where the interactive virtual object is located includes the projection area of the interactive virtual object onto a designated reference surface of the virtual scene, such as a virtual ground, or may be the projection area and an area within a preset range around the projection area.
[0085] As a specific example, the interactive area in the virtual scene includes at least one of the following:
[0086] The area where the door panel controlled by the first virtual character controlled by the player is located for blocking the second virtual character controlled by the AI, the area where the window controlled by the first virtual character controlled by the player is located for climbing over the wall, and the area where the telegraph machine controlled by the first virtual character controlled by the player is located for decryption gameplay, etc.
[0087] In the above exemplary embodiments, the existence of interactive virtual objects in the interactive area is used as an example for explanation; however, the present disclosure is not limited to this. In some exemplary embodiments, there may be no interactive virtual objects in the interactive area. In this case, the designated area in the virtual scene is directly divided into the interactive area, and when the first virtual character controlled by the player is within the interactive area, interaction can be performed.
[0088] In a specific implementation, the designated area in the virtual scene is a task area corresponding to the first virtual character controlled by the player, and is divided into an interactive area.
[0089] In specific implementation, the situation where there may not be any interactive virtual objects in the interactive area also includes: the first virtual character controlled by the player can interact with special terrain (such as a hillside, a mountain wall, etc.) in the interactive area.
[0090] In specific implementation, the interaction performed in the interactive area can be active or passive. As a specific example: assuming that the first virtual character controlled by the player stays in the interactive area for a target time, it is regarded as a passive interaction.
[0091] In the above exemplary embodiment, a method for determining an interactive area is introduced. Next, a method for obtaining a set of candidate areas by performing collision detection based on the interactive area will be introduced. Specifically:
[0092] In this exemplary embodiment, performing collision detection in the virtual scene based on the interactive area to obtain a candidate area, and adding the candidate area to a candidate area set includes:
[0093] Generate a cube with a preset side length for collision detection in the interactive area, wherein the cube is centered at the center of the interactive area and the shortest distance between the center and the edge of the interactive area is half of the side length;
[0094] Moving the cube along a specified direction with a preset step length, and detecting whether the moved cube collides with the virtual scene;
[0095] In response to determining that the moved cube collides with the virtual scene, continue to move the cube in a specified direction with a preset step length, and detect whether the moved cube collides with the virtual scene, until the moved cube does not collide with the virtual scene;
[0096] The area where the cube is located when no collision occurs for the first time in each of the specified directions is added as the candidate area to the candidate area set.
[0097] During specific implementation, the value of the preset step length is the same as the value of the preset side length of the cube.
[0098] As a specific example, see Figure 3a and Figure 3b , where perpendicular walls are used as an example:
[0099] In specific implementation, a cube with a radius of r is made with each interactive area as the center, and the cube uses the engine interface to detect whether it collides with the scene.
[0100] If a collision occurs, move forward, backward, left, and right along the square, with a moving step length of r, that is, to ensure that the squares are connected. Continue to perform collision detection. If a collision occurs, continue to perform collision detection along the square where the collision occurred.
[0101] If no collision is detected, it means that the square has not collided with the scene, and there is no need to continue detecting in four directions with this square as the center.
[0102] Record the position of the squares where no collision occurs for the first time in each direction. The following figure shows all the squares where no collision occurs for the first time corresponding to a certain interactive area. It can be seen that the squares surround the wall corresponding to the interactive area very well.
[0103] In the above exemplary embodiments, perpendicular walls are used as an example. For the case where the walls are not perpendicular to each other, multiple angles can be added. However, for particularly complex terrains, a different approach can be used. Now, similar to detecting from the inside out, it is possible to detect without distinguishing between inside and outside. We only care about whether the cube has a collision and record the cubes that have encountered a collision. The combination of these cubes is the body, and then the cube at the outer edge of the wall is obtained.
[0104] As a specific example, see Figure 4 , showing all the squares corresponding to a certain interactive area that did not collide for the first time. It can be seen that the squares surround the wall corresponding to the interactive area very well.
[0105] Step S220: Based on historical game data, determine that when the second virtual character in the virtual scene hits the first virtual character, a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character is added to a position data pair set, wherein the first virtual character and the second virtual character are in hostile camps.
[0106] In this exemplary embodiment, the virtual scene includes a first virtual character and a second virtual character. The second virtual character chases the first virtual character, and the first virtual character escapes and evades and completes a designated task.
[0107] Among them, the first virtual character is controlled by the player, and the second virtual character can be controlled by the player or by AI. The present disclosure is aimed at the situation where the second virtual character is controlled by AI. Specifically, based on the battle data between the second virtual character controlled by the player and the first virtual character, the second virtual character controlled by AI is controlled to fight against the first virtual character controlled by the player.
[0108] In this exemplary embodiment, when the second virtual character in the virtual scene hits the first virtual character based on the historical game data, a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character is determined, and the position data pair is added to a position data pair set, wherein the first virtual character and the second virtual character are in a hostile camp, including:
[0109] Determining game match data corresponding to the virtual scene from the historical game data;
[0110] The position data pair is determined from the game play data.
[0111] In a specific implementation, the game match data includes data of historical game matches conducted in the virtual scene, or data of past moments in the current game match.
[0112] In specific implementation, the game match data includes game match recordings.
[0113] Refer to the table below. In specific implementation, the player video data is parsed to obtain the two corresponding positions when the second virtual character uses a skill to hit the first virtual character, and the points appear in pairs.
[0114] Second avatar position First avatar position <![CDATA[x0,y0,z0]]> ”’ <![CDATA[x1,y1,z1]]> ”’ <![CDATA[x2,y2,z2]]> ”’ … …
[0115] refer to Figure 5 , showing a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character when the second virtual character hits the first virtual character in the virtual scene.
[0116] Step S230: match the candidate areas in the candidate area set and the position data pairs in the position data pair set to obtain a matching number corresponding to the candidate areas, wherein the matching number is used to indicate the number of data pairs when the first position and the second position in the position data pair are both located in the candidate area.
[0117] In this exemplary embodiment, the matching of the candidate area in the candidate area set and the position data pair in the position data pair set to obtain the number of matches corresponding to the candidate area, the number of matches being used to indicate the number of data pairs when both the first position and the second position in the position data pair are located in the candidate area, includes:
[0118] The first position and the second position are spatial positions;
[0119] The candidate area includes the space area occupied by the cube corresponding to the candidate area;
[0120] Generate an inscribed sphere corresponding to the cube;
[0121] In response to determining that the first position or the second position is within the inscribed sphere, determining that the first position or the second position is located in the candidate area;
[0122] Determine the number of matches of the second position corresponding to the candidate area.
[0123] As a specific example, see Figure 6 ,Since the cube is not AABB (axis aligned), it is more expensive to directly determine whether a point is inside a cube than to determine whether a point is inside a sphere.
[0124] Taking into account the computational consumption and possible fluctuations in the data, that is, there may be some deviations between the collected video data and the actual data, a sphere is used to replace each cube, and the radius of the sphere is r / 2.
[0125] In this exemplary embodiment, after matching the candidate area in the candidate area set with the position data pair in the position data pair set to obtain the number of matches corresponding to the candidate area, where the number of matches is used to indicate the number of data pairs when both the first position and the second position in the position data pair are located in the candidate area, the method further includes:
[0126] Determine a mean and a variance of the number of matches of the second position corresponding to the candidate area in the set of candidate areas corresponding to the interactable area;
[0127] An outlier in the number of matches at the second position is determined based on the mean and the variance, and the outlier is cleared.
[0128] In this exemplary embodiment, determining an outlier in the number of matches of the second position based on the mean and the variance includes:
[0129] Based on the variance, a standard deviation is obtained;
[0130] In response to determining that the absolute value of the difference between the number of matches at the second position and the mean is greater than a specified multiple of the standard deviation, the number of matches at the second position is determined to be the outlier.
[0131] As a specific example, see Figure 7 , taking each square as a category, when a video data comes in, calculate the nearest sphere to the location, and it is necessary to ensure that the location is within the sphere. According to this method, the number of data pieces corresponding to each second position in the wall of the interaction point can be obtained.
[0132] Assuming that the data is normally distributed, it is necessary to calculate the mean and variance corresponding to each interaction point, and use the range of 3 standard deviations beyond the mean (i.e., μ±3*δ) to consider it as an outlier. The calculation of the mean and variance is as follows:
[0133] μ=(n0+n1+n2+…+n l );
[0134] δ 2 =((n0-u) 2 +(n1-u) 2 +(n2-u) 2 +…+(n l -u) 2 ) / j;
[0135] Among them, n i is the data in the i-th cube, and l is the total number of cubes corresponding to the interaction points.
[0136] If the value in the grid is an outlier, it is cleared to zero.
[0137] Step S240, in response to determining that the distance between the current position of the second virtual character and the first alternative area in the alternative area set is less than a first distance threshold, and the number of matches corresponding to the first alternative area is not zero, determine an alternative position data pair in which the second position of the position data pair is located in the first alternative area, and determine a second alternative area corresponding to the first position of the alternative position data pair.
[0138] In this exemplary embodiment, determining the distance between the current position of the second virtual character and the first candidate area includes:
[0139] Determining the distance between the current position of the second virtual character and the center position of the first candidate area;
[0140] The determining the distance between the current position of the first virtual character and the second candidate area includes:
[0141] The distance between the current position of the first virtual character and the center position of the second candidate area is determined.
[0142] Step S250: In response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold, controlling the second virtual character to perform a designated action toward the first virtual character.
[0143] In this exemplary embodiment, in response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold, controlling the second virtual character to perform a specified action on the first virtual character includes:
[0144] In response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold, performing ray detection from the current position of the second virtual character to the current position of the first virtual character;
[0145] In response to determining that the ray detection passes, controlling the second virtual character to perform the designated action on the first virtual character.
[0146] As a specific example, see Figure 8 , after removing the above abnormal values, the real-time position of the second virtual character AI is calculated. If the distance between the current position of the second virtual character and the square is less than the threshold θ, and the value in the square is not zero, the square corresponding to the first virtual character is calculated, in order to ensure that the skill can hit a larger range of the first virtual character as much as possible.
[0147] When the distance between the center of the hit square of the corresponding first virtual character and the current position of the first virtual character is less than the threshold α, and the ray detection passes, the skill can be used on the position of the first virtual character. As shown in the figure, the position of the second virtual character is the closest square to the first virtual character, and the distance between the first virtual character and the center of the square is less than the threshold α, and the ray detection between the position of the first virtual character and the center of the square shows no obstacles in between, so the second virtual character can use skills on the current position of the first virtual character at this position.
[0148] As can be seen from the above, the control method of a virtual character provided by an embodiment of the present disclosure includes: determining an interactive area corresponding to a first virtual character in a virtual scene, performing collision detection in the virtual scene based on the interactive area to obtain a candidate area set; determining a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character when a second virtual character in the virtual scene hits the first virtual character; determining the number of matches of the second position corresponding to each candidate area when the first position and the second position in the position data pair are both located in a candidate area in the candidate area set; in response to determining that the distance between the current position of the second virtual character and the first candidate area is less than a first distance threshold, and the number of matches corresponding to the first candidate area is not zero, determining that the second position of the position data pair is located in a candidate position data pair in the first candidate area, and determining a second candidate area corresponding to the first position of the candidate position data pair; in response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold, controlling the second virtual character to perform a specified action on the first virtual character.
[0149] Through the present disclosure, in a more complex virtual scene, a second virtual character controlled by AI is controlled based on collision detection and position matching to perform a specified action on a first virtual character controlled by a player. The research and development cycle is short, the generalization is strong, the consumption of computing resources is low, and the needs of rapid implementation can be met.
[0150] It should be noted that the method of the embodiment of the present disclosure can be performed by a single device, such as a computer or a server. The method of the present embodiment can also be applied in a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present disclosure, and the multiple devices will interact with each other to complete the described method.
[0151] It should be noted that the above describes some embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0152] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present disclosure further provides a control device for a virtual character.
[0153] refer to Fig. 9 , which is a structural diagram of a control device for a virtual character provided by an exemplary embodiment of the present disclosure.
[0154] The control device of the virtual character includes the following modules:
[0155] A candidate region determination module 910 is configured to determine an interactive region corresponding to a first virtual character in a virtual scene, perform collision detection in the virtual scene based on the interactive region, obtain a candidate region, and add the candidate region to a candidate region set;
[0156] The position data pair determination module 920 is configured to determine, based on historical game data, a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character when the second virtual character in the virtual scene hits the first virtual character, and add the position data pair to a position data pair set, wherein the first virtual character and the second virtual character are in an enemy camp;
[0157] The region and position matching module 930 is configured to match the candidate region in the candidate region set with the position data pair in the position data pair set to obtain a matching number corresponding to the candidate region, where the matching number indicates the number of data pairs when both the first position and the second position in the position data pair are located in the candidate region;
[0158] The distance determination module 940 is configured to, in response to determining that the distance between the current position of the second virtual character and the first candidate area in the candidate area set is less than a first distance threshold, and the number of matches corresponding to the first candidate area is not zero, determine that the second position of the position data pair is located in the candidate position data pair in the first candidate area, and determine the second candidate area corresponding to the first position of the candidate position data pair;
[0159] The action execution module 950 is configured to control the second virtual character to execute a specified action toward the first virtual character in response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold.
[0160] In some exemplary embodiments, the candidate region determination module 910 is specifically configured to:
[0161] Determining an interactive virtual object corresponding to the first virtual character in the virtual scene;
[0162] Determining a projection area of the interactive virtual object onto a designated reference plane of the virtual scene;
[0163] The interactable area includes the projection area.
[0164] In some exemplary embodiments, the candidate region determination module 910 is specifically configured to:
[0165] Generate a cube with a preset side length for collision detection in the interactive area, wherein the cube is centered at the center of the interactive area and the shortest distance between the center and the edge of the interactive area is half of the side length;
[0166] Moving the cube along a specified direction with a preset step length, and detecting whether the moved cube collides with the virtual scene;
[0167] In response to determining that the moved cube collides with the virtual scene, continue to move the cube in a specified direction with a preset step length, and detect whether the moved cube collides with the virtual scene, until the moved cube does not collide with the virtual scene;
[0168] The area where the cube is located when no collision occurs for the first time in each of the specified directions is added as the candidate area to the candidate area set.
[0169] In some exemplary embodiments, the location data pair determination module 920 is specifically configured to:
[0170] Determining game match data corresponding to the virtual scene from the historical game data;
[0171] The position data pair is determined from the game play data.
[0172] In some exemplary embodiments, the region and location matching module 930 is specifically configured to:
[0173] The first position and the second position are spatial positions;
[0174] The candidate area includes the space area occupied by the cube corresponding to the candidate area;
[0175] Generate an inscribed sphere corresponding to the cube;
[0176] In response to determining that the first position or the second position is within the inscribed sphere, determining that the first position or the second position is located in the candidate area;
[0177] Determine the number of matches of the second position corresponding to the candidate area.
[0178] In some exemplary embodiments, the region and location matching module 930 is further configured to:
[0179] Determine a mean and a variance of the number of matches of the second position corresponding to the candidate area in the set of candidate areas corresponding to the interactable area;
[0180] An outlier in the number of matches at the second position is determined based on the mean and the variance, and the outlier is cleared.
[0181] In some exemplary embodiments, the region and location matching module 930 is further configured to:
[0182] Based on the variance, a standard deviation is obtained;
[0183] In response to determining that the absolute value of the difference between the number of matches at the second position and the mean is greater than a specified multiple of the standard deviation, the number of matches at the second position is determined to be the outlier.
[0184] In some exemplary embodiments, the action execution module 950 is specifically configured to:
[0185] In response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold, performing ray detection from the current position of the second virtual character to the current position of the first virtual character;
[0186] In response to determining that the ray detection passes, controlling the second virtual character to perform the designated action on the first virtual character.
[0187] In some exemplary embodiments, the distance determination module 940 is specifically configured to:
[0188] Determining the distance between the current position of the second virtual character and the center position of the first candidate area;
[0189] The distance between the current position of the first virtual character and the center position of the second candidate area is determined.
[0190] For the convenience of description, the above device is described by dividing it into various modules according to its functions. Of course, when implementing the present disclosure, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0191] The device of the above embodiment is used to implement the control method of the corresponding virtual character in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0192] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present disclosure also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the control method of the virtual character described in any of the above embodiments is implemented.
[0193] Fig.10 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.
[0194] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0195] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.
[0196] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0197] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0198] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).
[0199] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0200] The electronic device of the above embodiment is used to implement the control method of the corresponding virtual character in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0201] The memory 1020 stores machine-readable instructions executable by the processor 1010. When the electronic device is running, the processor 1010 communicates with the memory 1020 via the bus 1030, so that the processor 1010 executes the following instructions when running:
[0202] Determine an interactive area corresponding to a first virtual character in a virtual scene, perform collision detection in the virtual scene based on the interactive area to obtain a candidate area, and add the candidate area to a candidate area set;
[0203] Based on the historical game data, determining a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character when the second virtual character in the virtual scene hits the first virtual character, and adding the position data pair to a position data pair set, wherein the first virtual character and the second virtual character are in hostile camps;
[0204] Matching the candidate area in the candidate area set with the position data pair in the position data pair set to obtain a matching number corresponding to the candidate area, where the matching number is used to indicate the number of data pairs when both the first position and the second position in the position data pair are located in the candidate area;
[0205] In response to determining that the distance between the current position of the second virtual character and a first candidate area in the candidate area set is less than a first distance threshold, and the number of matches corresponding to the first candidate area is not zero, determining that the second position of the position data pair is located in an alternative position data pair in the first candidate area, and determining a second candidate area corresponding to the first position of the alternative position data pair;
[0206] In response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold, controlling the second virtual character to perform a designated action toward the first virtual character.
[0207] In a possible implementation, in the instructions executed by the processor 1010, determining the interactive area corresponding to the first virtual character in the virtual scene includes:
[0208] Determining an interactive virtual object corresponding to the first virtual character in the virtual scene;
[0209] Determining a projection area of the interactive virtual object onto a designated reference plane of the virtual scene;
[0210] The interactable area includes the projection area.
[0211] In a possible implementation manner, in the instructions executed by the processor 1010, performing collision detection in the virtual scene based on the interactive area to obtain a candidate area, and adding the candidate area to a set of candidate areas includes:
[0212] Generate a cube with a preset side length for collision detection in the interactive area, wherein the cube is centered at the center of the interactive area and the shortest distance between the center and the edge of the interactive area is half of the side length;
[0213] Moving the cube along a specified direction with a preset step length, and detecting whether the moved cube collides with the virtual scene;
[0214] In response to determining that the moved cube collides with the virtual scene, continue to move the cube in a specified direction with a preset step length, and detect whether the moved cube collides with the virtual scene, until the moved cube does not collide with the virtual scene;
[0215] The area where the cube is located when no collision occurs for the first time in each of the specified directions is added as the candidate area to the candidate area set.
[0216] In a possible implementation, in the instructions executed by the processor 1010, determining, based on the historical game data, when the second virtual character in the virtual scene hits the first virtual character, a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character, adding the position data pair to a position data pair set, wherein the first virtual character and the second virtual character are in a hostile camp, includes:
[0217] Determining game match data corresponding to the virtual scene from the historical game data;
[0218] The position data pair is determined from the game play data.
[0219] In a possible implementation manner, in the instruction executed by the processor 1010, matching the candidate area in the candidate area set with the position data pair in the position data pair set to obtain a number of matches corresponding to the candidate area, where the number of matches is used to indicate the number of data pairs when both the first position and the second position in the position data pair are located in the candidate area, includes:
[0220] The first position and the second position are spatial positions;
[0221] The candidate area includes the space area occupied by the cube corresponding to the candidate area;
[0222] Generate an inscribed sphere corresponding to the cube;
[0223] In response to determining that the first position or the second position is within the inscribed sphere, determining that the first position or the second position is located in the candidate area;
[0224] Determine the number of matches of the second position corresponding to the candidate area.
[0225] In a possible implementation manner, in the instruction executed by the processor 1010, after matching the candidate area in the candidate area set with the position data pair in the position data pair set to obtain the number of matches corresponding to the candidate area, where the number of matches is used to indicate the number of data pairs when both the first position and the second position in the position data pair are located in the candidate area, the method further includes:
[0226] Determine a mean and a variance of the number of matches of the second position corresponding to the candidate area in the set of candidate areas corresponding to the interactable area;
[0227] An outlier in the number of matches at the second position is determined based on the mean and the variance, and the outlier is cleared.
[0228] In a possible implementation manner, in the instruction executed by the processor 1010, determining the outlier in the number of matches of the second position based on the mean and the variance includes:
[0229] Based on the variance, a standard deviation is obtained;
[0230] In response to determining that the absolute value of the difference between the number of matches at the second position and the mean is greater than a specified multiple of the standard deviation, the number of matches at the second position is determined to be the outlier.
[0231] In a possible implementation manner, in the instructions executed by the processor 1010, in response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold, controlling the second virtual character to perform a specified action toward the first virtual character includes:
[0232] In response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold, performing ray detection from the current position of the second virtual character to the current position of the first virtual character;
[0233] In response to determining that the ray detection passes, controlling the second virtual character to perform the designated action on the first virtual character.
[0234] In a possible implementation, in the instructions executed by the processor 1010, determining the distance between the current position of the second virtual character and the first candidate area includes:
[0235] Determining the distance between the current position of the second virtual character and the center position of the first candidate area;
[0236] The determining the distance between the current position of the first virtual character and the second candidate area includes:
[0237] The distance between the current position of the first virtual character and the center position of the second candidate area is determined.
[0238] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present disclosure also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the control method of the virtual character as described in any of the above embodiments.
[0239] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0240] The above-mentioned non-transitory computer-readable storage medium can be any available medium or data storage device that can be accessed by a computer, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)), etc.
[0241] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the control method of the virtual character described in any embodiment in the above exemplary method part, and have the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0242] Based on the same inventive concept, corresponding to the control method of the virtual character described in any of the above embodiments, the present disclosure also provides a computer program product, which includes computer program instructions. In some embodiments, the computer program instructions can be executed by one or more processors of a computer so that the computer and / or the processor execute the control method of the virtual character. Corresponding to the execution subject corresponding to each step in each embodiment of the control method of the virtual character, the processor that executes the corresponding step can belong to the corresponding execution subject.
[0243] The computer program product of the above embodiment is used to enable the computer and / or the processor to execute the control method of the virtual character as described in any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0244] Those skilled in the art will appreciate that the embodiments of the present disclosure may be implemented as a system, method, or computer program product. Therefore, the present disclosure may be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." In addition, in some embodiments, the present disclosure may also be implemented in the form of a computer program product in one or more computer-readable media, which contains computer-readable program code.
[0245] Any combination of one or more computer-readable media may be used. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive examples) of computer-readable storage media may include, for example: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device.
[0246] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0247] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0248] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0249] It should be understood that each box in the flowchart and / or block diagram and the combination of boxes 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 or other programmable data processing device to produce a machine, and these computer program instructions are executed by a computer or other programmable data processing device to produce a device that implements the functions / operations specified in the boxes in the flowchart and / or block diagram.
[0250] These computer program instructions may also be stored in a computer-readable medium that enables a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable medium produce a product that includes an instruction device that implements the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0251] Computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby enabling the instructions executed on the computer or other programmable device to provide a process for implementing the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0252] In addition, although the operations of the disclosed method are described in a particular order in the accompanying drawings, this does not require or imply that the operations must be performed in this particular order, or that all the operations shown must be performed to achieve the desired results. On the contrary, the steps depicted in the flow chart can be performed in a different order. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps.
[0253] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0254] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0255] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.
[0256] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power supply / ground connection with the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device can be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform to be implemented in the embodiments of the present application (that is, these details should be fully within the scope of understanding of those skilled in the art). In the case of elaborating specific details (e.g., circuits) to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or when these specific details are changed. Therefore, these descriptions should be considered to be illustrative rather than restrictive.
[0257] Although the present application has been described in conjunction with specific embodiments of the present application, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
[0258] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the present application.
[0259] Although the spirit and principle of the present disclosure have been described with reference to several specific embodiments, it should be understood that the present disclosure is not limited to the disclosed specific embodiments, and the division of various aspects does not mean that the features in these aspects cannot be combined to benefit, and such division is only for the convenience of expression. The present disclosure is intended to cover various modifications and equivalent arrangements included in the spirit and scope of the attached claims. The scope of the attached claims conforms to the broadest interpretation, thereby including all such modifications and equivalent structures and functions.
Claims
1. A method for controlling a virtual character, characterized in that: include: Determine an interactive area corresponding to a first virtual character in a virtual scene, perform collision detection in the virtual scene based on the interactive area to obtain a candidate area, and add the candidate area to a candidate area set; Based on the historical game data, determining a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character when the second virtual character in the virtual scene hits the first virtual character, and adding the position data pair to a position data pair set, wherein the first virtual character and the second virtual character are in hostile camps; Matching the candidate area in the candidate area set with the position data pair in the position data pair set to obtain a matching number corresponding to the candidate area; the matching number is used to indicate the number of data pairs when both the first position and the second position in the position data pair are located in the candidate area; In response to determining that the distance between the current position of the second virtual character and a first candidate area in the candidate area set is less than a first distance threshold, and the number of matches corresponding to the first candidate area is not zero, determining that the second position of the position data pair is located in an alternative position data pair in the first candidate area, and determining a second candidate area corresponding to the first position of the alternative position data pair; In response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold, controlling the second virtual character to perform a designated action toward the first virtual character.
2. The method according to claim 1, characterized in that The step of determining the interactive area corresponding to the first virtual character in the virtual scene includes: Determining an interactive virtual object corresponding to the first virtual character in the virtual scene; Determining a projection area of the interactive virtual object onto a designated reference plane of the virtual scene; The interactable area includes the projection area.
3. The method according to claim 1, characterized in that The performing collision detection in the virtual scene based on the interactive area to obtain a candidate area, and adding the candidate area to a candidate area set includes: Generating a cube with a preset side length for collision detection in the interactive area, wherein the cube is centered at the center of the interactive area; Moving the cube along a specified direction with a preset step length, and detecting whether the moved cube collides with the virtual scene; In response to determining that the moved cube collides with the virtual scene, continue to move the cube in a specified direction with a preset step length, and detect whether the moved cube collides with the virtual scene, until the moved cube does not collide with the virtual scene; The area where the cube is located when no collision occurs for the first time in each of the specified directions is added as the candidate area to the candidate area set.
4. The method according to claim 1, characterized in that: The method of determining, based on the historical game data, when the second virtual character in the virtual scene hits the first virtual character, a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character, and adding the position data pair to a position data pair set, wherein the first virtual character and the second virtual character are in an enemy camp, comprises: Determining game match data corresponding to the virtual scene from the historical game data; The position data pair is determined from the game play data.
5. The method according to claim 3, characterized in that: The matching of the candidate area in the candidate area set and the position data pair in the position data pair set to obtain the number of matches corresponding to the candidate area, wherein the number of matches is used to indicate the number of data pairs when both the first position and the second position in the position data pair are located in the candidate area, includes: The first position and the second position are spatial positions; The candidate area includes the space area occupied by the cube corresponding to the candidate area; Generate an inscribed sphere corresponding to the cube; In response to determining that the first position or the second position is within the inscribed sphere, determining that the first position or the second position is located in the candidate area; Determine the number of data pairs in which both the first position and the second position of the position data pairs are located in the candidate area; The number of matches corresponding to the candidate area is determined based on the number of data pairs.
6. The method according to claim 1, characterized in that After matching the candidate area in the candidate area set with the position data pair in the position data pair set to obtain a matching number corresponding to the candidate area, wherein the matching number is used to indicate the number of data pairs when both the first position and the second position in the position data pair are located in the candidate area, the method further includes: Determine a mean and a variance of the number of matches of the second position corresponding to the candidate area in the set of candidate areas corresponding to the interactable area; An outlier in the number of matches at the second position is determined based on the mean and the variance, and the outlier is cleared.
7. The method according to claim 6, characterized in that The determining, based on the mean and the variance, an outlier in the number of matches of the second position comprises: Based on the variance, a standard deviation is obtained; In response to determining that the absolute value of the difference between the number of matches at the second position and the mean is greater than a specified multiple of the standard deviation, the number of matches at the second position is determined to be the outlier.
8. The method according to claim 1, characterized in that In response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold, controlling the second virtual character to perform a specified action toward the first virtual character includes: In response to determining that the distance between the current position of the first virtual character and the second candidate area is less than the second distance threshold, performing ray detection from the current position of the second virtual character to the current position of the first virtual character; In response to determining that the ray detection passes, controlling the second virtual character to perform the designated action on the first virtual character.
9. The method according to claim 1, characterized in that: The determining the distance between the current position of the second virtual character and the first candidate area includes: Determining the distance between the current position of the second virtual character and the center position of the first candidate area; The determining the distance between the current position of the first virtual character and the second candidate area includes: The distance between the current position of the first virtual character and the center position of the second candidate area is determined.
10. A control device for a virtual character, characterized in that: include: A candidate area determination module is configured to determine an interactive area corresponding to a first virtual character in a virtual scene, perform collision detection in the virtual scene based on the interactive area, obtain a candidate area, and add the candidate area to a candidate area set; a position data pair determination module configured to determine, based on historical game data, a position data pair consisting of a first position of the first virtual character and a second position of the second virtual character when the second virtual character in the virtual scene hits the first virtual character, and add the position data pair to a position data pair set, wherein the first virtual character and the second virtual character are in an enemy camp; an area and position matching module, configured to match the candidate area in the candidate area set with the position data pair in the position data pair set, and obtain a matching number corresponding to the candidate area, wherein the matching number is used to indicate the number of data pairs when both the first position and the second position in the position data pair are located in the candidate area; a distance determination module, configured to, in response to determining that the distance between the current position of the second virtual character and a first candidate area in the candidate area set is less than a first distance threshold, and the number of matches corresponding to the first candidate area is not zero, determine that the second position of the position data pair is located in the candidate position data pair in the first candidate area, and determine a second candidate area corresponding to the first position of the candidate position data pair; The action execution module is configured to control the second virtual character to execute a specified action toward the first virtual character in response to determining that the distance between the current position of the first virtual character and the second candidate area is less than a second distance threshold.
11. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method according to any one of claims 1 to 9 is implemented.
12. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a computer to execute the method according to any one of claims 1 to 9.
13. A computer program product, characterized in that The method comprises computer program instructions, which, when executed on a computer, cause the computer to execute the method according to any one of claims 1 to 9.