Game non-player character generation method and device

By combining the torso and limbs of modular NPC human models, the problems of long creation cycles and homogenization of NPC models are solved, enabling the rapid generation of diverse NPC characters and improving the gaming experience.

CN121982170APending Publication Date: 2026-05-05WUHU DOUZHAOWAN NETWORK TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
WUHU DOUZHAOWAN NETWORK TECHNOLOGY CO LTD
Filing Date
2025-12-31
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

In existing technologies, the creation cycle for non-player character (NPC) models is long, and the appearance becomes highly homogenized when generated in batches, making it impossible to reuse art styles and resulting in a poor game experience.

Method used

The NPC human body model is modularized into a torso model and a limb model. These are randomly combined through an association rule database and then fused with interface parameters and skinning weights to generate diverse NPC characters, supporting changes in art style.

Benefits of technology

It enables the rapid generation of diverse NPC characters, avoids homogenization, reduces the cost of reusing NPC models, and improves the gaming experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121982170A_ABST
    Figure CN121982170A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of game modeling, and discloses a game non-player character generation method and device, and the method comprises the steps: randomly extracting a trunk model set, and obtaining a target trunk model and a corresponding body shape proportion label; querying each limb model set according to the association rule database and the body shape proportion label of the target trunk model to obtain a compatible limb model list corresponding to each limb model set; randomly extracting each compatible limb model list to obtain a plurality of target limb models; judging whether the interface parameters of the target trunk model and the target limb models are matched or not, and if yes, combining the target trunk model and the target limb models to obtain candidate role models; and in response to the selection instruction, taking the candidate role model corresponding to the selection instruction as a non-player role. According to the method, a developer only needs to construct a certain number of limb models and trunk models, and large-batch NPC roles of different types can be generated through random combination.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of game modeling technology, and in particular to a method and apparatus for generating non-player characters in games. Background Technology

[0002] The creation of models for non-player characters (NPCs) in game scenes requires modeling first and then binding skeletons, which results in a cycle of about 1-2 days from modeling to application for non-player characters. Therefore, in games that require a large number of NPCs, after modeling a certain number of NPC models, a large number of NPCs are often generated in batches by copying and placed into the game scene.

[0003] However, NPCs generated in batches through duplication have a highly homogenized appearance, which can easily lead to a sense of repetition among players and a poor gaming experience. Furthermore, the modeled NPCs cannot be reused in games with different art styles. Summary of the Invention

[0004] This application provides a method and apparatus for generating non-player characters in games. Developers only need to build a certain number of limb models and torso models, and a large number of NPC characters of different types can be generated through random combination.

[0005] In a first aspect, embodiments of this application provide a method for generating non-player characters in a game, including: Obtain the association rule database, the torso model set, and multiple limb model sets; Randomly select a set of torso models to obtain the target torso model and its corresponding body proportion label; Based on the association rule database and the body proportion labels of the target torso model, query each limb model set to obtain a list of compatible limb models corresponding to each limb model set. Multiple target limb models are obtained by randomly selecting from each list of compatible limb models. Determine whether the interface parameters of the target torso model and each target limb model match. If they do, combine the target torso model and each target limb model to obtain the candidate character model. In response to a selection command, the candidate character model corresponding to the selection command is treated as a non-player character.

[0006] Furthermore, the torso model set includes multiple torso models and body proportion labels corresponding to each torso model; the limb model set includes multiple limb models corresponding to the same limb part and body proportion labels corresponding to each limb model; the association rule database includes a queue of compatible labels corresponding to various body proportion labels. The above query, based on the association rule database and the body proportion labels of the target torso model, retrieves a list of compatible limb models for each limb model set, including: Based on the body proportion labels of the target torso model, query the association rule database to obtain the compatible label queue corresponding to the body proportion labels of the target torso model, and use it as the target compatible label queue. Limb models whose body proportion labels fall into the target compatible label queue are added to the corresponding compatible limb model list in the limb model set.

[0007] Furthermore, the interface parameters of the torso model include torso height and coordinates of multiple limb connection points, while the interface parameters of the limb model include torso connection point coordinates and bone length. The above-mentioned determination of whether the interface parameters of the target torso model and each target limb model match includes: Determine the coordinates of the target limb connection points on the target torso model corresponding to the target limb model; Determine whether the coordinates of the torso connection points of the target limb model and the coordinates of the target limb connection points are aligned; If not, the interface parameters do not match; if yes, calculate whether the ratio of the torso height to the bone length of each target limb model meets the preset ergonomic range. If yes, the interface parameters match; otherwise, the interface parameters do not match.

[0008] Furthermore, by combining the target torso model and each target limb model, candidate character models are obtained, including: Connect the target limb model and the target torso model based on the coordinates of the torso connection points of the target limb model and the corresponding coordinates of the target limb connection points on the target torso model. Obtain the skinning weight distribution map of each vertex on the target limb model and the target torso model. The skinning weight distribution map includes the weight of each vertex to each bone in the target limb model and the target torso model. The transition area is determined based on the seam between the target limb model and the target torso model; Based on the skin weight distribution map, the weights of each vertex in the transition region are fused to obtain the latest weights of each vertex to each bone, and the latest weights of each vertex are normalized to obtain the candidate character model.

[0009] Furthermore, the limb model set also includes compatible equipment tags for each limb model; the generation method also includes: Obtain the equipment model set. After connecting the target limb model and the target torso model, determine at least one target equipment model in the equipment model set based on the compatible equipment tags of the target limb model. Combine the target equipment model and the target limb model.

[0010] Furthermore, the generation method also includes: After obtaining the candidate character model, calculate the centroid of the candidate character model; Determine if there is a shift in the center of gravity. If so, adjust the spacing between the two leg limb models of the candidate character model according to the direction of the shift in the center of gravity until the center of gravity of the candidate character model is no longer shifted.

[0011] Furthermore, the generation method also includes: After selecting the candidate character model corresponding to the command as a non-player character, obtain the preset core action and the trigger command corresponding to the preset core action, and bind them to the non-player character.

[0012] Furthermore, the generation method also includes: After selecting the candidate character model corresponding to the command as the non-player character, the joint motion constraints of the non-player character are determined according to the body proportion label of the candidate character model. The non-player character is instructed to perform preset core actions based on joint motion constraints, and collision data between the target torso model and each target limb model of the non-player character is detected. Update the joint motion constraints of non-player characters based on the collision data until there is no collision data when the non-player characters perform preset core actions based on the updated joint motion constraints.

[0013] Furthermore, the generation method also includes: After the joint motion constraints are updated, determine whether the updated joint motion constraints cover the range of motion of the preset core movements. If not, delete the non-player character.

[0014] Furthermore, the generation method also includes: Obtain the game map, and the starting and ending coordinates of non-player characters' movements; The route information from the starting point coordinates to the ending point coordinates is generated based on the path planning algorithm; Obtain the level duration of the game map and multiple different movement speeds for non-player characters; Movement data for non-player characters is generated based on level duration, movement speed, and route information. The movement data includes the movement speed of non-player characters on different sections of the route information.

[0015] Furthermore, the above-mentioned generation of non-player character movement data based on level duration, various movement speeds, and route information includes: randomly dividing route information according to a preset number of segments to obtain multiple road segments; Randomly assign the movement speed of a non-player character to each road segment as the initial speed; The movement time is calculated based on the length of each road segment and the initial speed. If the movement time is longer than the level time, the maximum initial speed in each road segment is reduced according to the preset adjustment step. If the movement time is shorter than the level time, the minimum initial speed in each road segment is increased according to the preset adjustment step, until the movement time equals the level time.

[0016] Secondly, embodiments of this application provide a device for generating non-player characters in a game, comprising: The acquisition module is used to acquire the association rule database, the torso model set, and multiple limb model sets. The torso module is used to randomly extract a set of torso models to obtain the target torso model and its corresponding body proportion label. The tag query module is used to query each limb model set based on the association rule database and the body proportion tags of the target torso model, and obtain a list of compatible limb models corresponding to each limb model set. The limb module is used to randomly select from each of the compatible limb model lists to obtain multiple target limb models; The combination module is used to determine whether the interface parameters of the target torso model and each target limb model match. If they do, the target torso model and each target limb model are combined to obtain the candidate character model. The selection module is used to respond to a selection command and select the candidate character model corresponding to the selection command as a non-player character.

[0017] Furthermore, the torso model set includes multiple torso models and corresponding body proportion labels for each torso model; the limb model set includes multiple limb models corresponding to the same limb part and corresponding body proportion labels for each limb model; the association rule database includes a queue of compatible labels corresponding to various body proportion labels; the label query module is specifically used to query the association rule database based on the body proportion labels of the target torso model to obtain the queue of compatible labels corresponding to the body proportion labels of the target torso model, and use it as the target compatible label queue; and to put the limb models in the limb model set whose body proportion labels fall into the target compatible label queue into the list of compatible limb models corresponding to the limb model set.

[0018] Furthermore, the interface parameters for the torso model include torso height and coordinates of multiple limb connection points, while the interface parameters for the limb model include torso connection point coordinates and bone length. The combination module is specifically used to determine the coordinates of the target limb connection points on the target torso model corresponding to the target limb model; it determines whether the torso connection point coordinates of the target limb model and the target limb connection point coordinates are aligned; if not, the interface parameters do not match; if so, it calculates whether the ratio of torso height to the bone length of each target limb model meets the preset ergonomic range; if so, the interface parameters match, otherwise the interface parameters do not match.

[0019] Furthermore, the combination module is specifically used to connect the target limb model and the target torso model based on the coordinates of the torso connection points of the target limb model and the corresponding coordinates of the target limb connection points on the target torso model; obtain the skinning weight distribution map of each vertex on the target limb model and the target torso model, the skinning weight distribution map including the weights of the vertices to each bone in the target limb model and the target torso model; determine the transition region based on the seam between the target limb model and the target torso model; perform weight fusion on each vertex in the transition region based on the skinning weight distribution map to obtain the latest weights of each vertex to each bone, and normalize the latest weights of each vertex to obtain the candidate character model.

[0020] Furthermore, the limb model set also includes compatible equipment tags for each limb model; the generation device also includes: The equipment combination module is used to obtain a set of equipment models. After connecting the target limb model and the target torso model, it determines at least one target equipment model in the set of equipment models based on the compatible equipment tags of the target limb model; and combines the target equipment model and the target limb model.

[0021] Furthermore, the generating apparatus also includes: The center of gravity adjustment module is used to calculate the center of gravity of the candidate character model after obtaining the candidate character model; determine whether there is a shift in the center of gravity; if so, adjust the distance between the two leg limb models of the candidate character model according to the direction of the shift in the center of gravity until the center of gravity of the candidate character model is no longer shifted.

[0022] Furthermore, the generating apparatus also includes: The action combination module is used to obtain the preset core action and the trigger command corresponding to the preset core action after selecting the candidate character model corresponding to the command as a non-player character, and bind it to the non-player character.

[0023] Thirdly, embodiments of this application provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the steps of a method for generating a non-player character in a game as described in any of the above embodiments.

[0024] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of a method for generating a non-player character in a game as described in any of the above embodiments.

[0025] In summary, compared with the prior art, the beneficial effects of the technical solution provided in this application include at least the following: This application provides a method for generating non-player characters in games. The method modularizes the NPC human body model into a torso model and limb models of different body parts. Then, based on an association rule database, the torso model and limb models are randomly combined. Interface parameter matching ensures reasonable model splicing, avoiding significant differences in body proportions between different body parts and gaps in the connection points of candidate character models. Finally, various candidate character models obtained by combining different limb models with each torso module are displayed to game developers for selection. This method only requires developers to build a certain number of limb and torso models, enabling the generation of a large number of NPC characters of different types through random combination. This avoids the homogenization of mass-generated NPC characters. Furthermore, by maintaining the topological structure of the limb and torso models, the art style of the limb and torso models can be changed by applying a stylizer, allowing the limb and torso model sets to be applied to game projects with other art styles, greatly reducing the cost of NPC model reuse. Attached Figure Description

[0026] Figure 1 A flowchart illustrating a method for generating non-player characters in a game, provided as an exemplary embodiment of this application.

[0027] Figure 2 A flowchart of an interface parameter matching detection step provided for an exemplary embodiment of this application.

[0028] Figure 3 A flowchart of the skin weight intelligent fusion step provided for an exemplary embodiment of this application.

[0029] Figure 4 A flowchart illustrating the steps for generating the movement state of a non-player character, as provided in an exemplary embodiment of this application.

[0030] Figure 5 This is a structural diagram of a device for generating non-player characters in a game, provided as an exemplary embodiment of this application. Detailed Implementation

[0031] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.

[0032] Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0033] Please see Figure 1This application provides a method for generating non-player characters in a game, including: Step S11: Obtain the association rule database, the torso model set, and multiple limb model sets.

[0034] The torso model set includes multiple torso models and corresponding body proportion labels for each torso model. The body proportion labels include two dimensions of label content: "body size dimension + proportion dimension". For example, the body proportion label of a certain torso model is "standard body size + three-seven proportion". In the specific implementation process, the label content can be further refined, such as BMI range, etc.

[0035] Furthermore, each torso model and individual limb models can come with fixed clothing, so that after being combined into candidate character models, they can be directly applied to the game scene without having to manually add various clothing items.

[0036] The limb model set includes multiple limb models corresponding to the same limb part and body proportion labels corresponding to each limb model. The body proportion labels of the limb models and the body proportion labels of the torso models have the same dimension. The limb model set can be classified according to the left arm, right arm, left leg and right leg, that is, four types of limb model sets are designed.

[0037] The association rule database includes a queue of compatible labels corresponding to various body proportion labels, which is used to clarify the compatibility dependencies of each trunk / limb model in the two dimensions of body shape and proportion. For example, a trunk model with "standard body shape + 3:7 ratio" can only be compatible with a limb model with "standard / lean body shape + 3:7 / 4:6 ratio".

[0038] Step S12: Randomly select a set of torso models to obtain the target torso model and the corresponding body proportion label.

[0039] Step S13: Query each limb model set according to the association rule database and the body proportion label of the target torso model to obtain a list of compatible limb models corresponding to each limb model set.

[0040] Randomly select a torso model from the torso model set as the target torso model. Then, query the association rule database based on the body proportion label of the target torso model to obtain the compatible label queue corresponding to the body proportion label of the target torso model, and use it as the target compatible label queue. Place the limb models in the limb model set whose body proportion labels fall into the target compatible label queue into the compatible limb model list corresponding to the limb model set.

[0041] It can be assumed that by querying the association rule database, a limb model that can be combined and matched with the current target torso model can be found, and after connection, there will be no situation that does not conform to ergonomics, such as disharmony between the limbs and torso in terms of size or large proportion.

[0042] Step S14: Randomly select from each compatible limb model list to obtain multiple target limb models.

[0043] Specifically, there is a one-to-one correspondence between the list of compatible limb models and the set of limb models. A limb model is extracted from a list of compatible limb models as the target limb model. The list of compatible limb models is polled to obtain the target limb model corresponding to each list of compatible limb models. At this time, the target limb models and the torso model are combined to form a complete human body model.

[0044] To further enhance the rationality of the automatically generated candidate character models, when randomly selecting from the list of compatible limb models, the body proportion labels of symmetrical parts (such as left and right arms and left and right legs) can be constrained to be the same.

[0045] Step S15: Determine whether the interface parameters of the target torso model and each target limb model match. If so, combine the target torso model and each target limb model to obtain the candidate character model.

[0046] The interface parameters of the torso model include torso height and coordinates of multiple limb connection points.

[0047] The interface parameters for the limb model include the coordinates of the torso connection points and the length of the bones.

[0048] Please see Figure 2 The above-mentioned determination of whether the interface parameters of the target torso model and each target limb model match includes: Step S151: Determine the coordinates of the target limb connection point on the target torso model.

[0049] Step S152: Determine whether the coordinates of the torso connection point of the target limb model and the coordinates of the target limb connection point are aligned.

[0050] Specifically, the Euclidean distance between the coordinates of the body connection point and the target limb connection point is calculated. If the obtained Euclidean distance exceeds a certain threshold, or if the docking direction is checked, and the deviation of the docking direction exceeds a certain angle, then the two cannot be aligned.

[0051] In the specific implementation process, you can directly refer to the algorithms in the human body modeling verification tools in game engines, such as the common Anchor / Transform alignment verification tools in the Unity engine.

[0052] Step S153: If not, the interface parameters do not match; if yes, calculate whether the ratio of the torso height to the bone length of each target limb model meets the preset ergonomic range. If yes, the interface parameters match; otherwise, the interface parameters do not match.

[0053] The proportion calculation includes comparing the trunk height with the bone length of each target limb model, as well as comparing the bone lengths of each target limb model with each other. For example, the bone length ratio of the left arm to the right arm should be maintained between 0.95 and 1.05, while the arm length should be 80%-90% of the length of the lower limb (left leg / right leg).

[0054] Step S16: In response to the selection command, the candidate character model corresponding to the selection command is selected as a non-player character.

[0055] Specifically, repeat steps S12-S15 to obtain multiple candidate character models and display them on the computer screen for developers to choose from. Based on the developers' selection instructions, determine the candidate character models that can be used as non-player characters.

[0056] This application adds manual review in the final step to avoid errors or bugs in individual steps during the above-mentioned automatic model combination algorithm, which could lead to unreasonable appearances in the generated candidate character models.

[0057] The above embodiment provides a method for generating non-player characters in games. It modularizes the NPC human body model into a torso model and limb models for different body parts. Then, based on an association rule database, the torso model and limb models are randomly combined. Interface parameter matching ensures reasonable model splicing, avoiding significant differences in body proportions between different body parts and gaps in the connection points of candidate character models. Finally, various candidate character models obtained by combining different limb models with each torso module are displayed to game developers for selection. This method only requires developers to build a certain number of limb and torso models, enabling the generation of a large number of NPC characters of different types through random combination. This avoids homogenization of mass-generated NPC characters. Furthermore, by keeping the topological structure of the limb and torso models unchanged, the art style of the limb and torso models can be changed by applying a stylizer. This allows the limb and torso model sets to be applied to game projects with other art styles, greatly reducing the cost of NPC model reuse.

[0058] Please see Figure 3 In some embodiments, the above-mentioned combination of the target torso model and each target limb model to obtain a candidate character model may specifically include the following steps: Step S154: Connect the target limb model and the target torso model according to the coordinates of the torso connection point of the target limb model and the coordinates of the corresponding target limb connection point of the target limb model on the target torso model.

[0059] Step S155: Obtain the skinning weight distribution map of each vertex on the target limb model and the target torso model. The skinning weight distribution map includes the weight of each vertex to each bone in the target limb model and the target torso model.

[0060] In this model, a vertex is a point on the surface of the target limb model or the target torso model. A vertex can be pulled by multiple bones in the model, and the weight of a vertex to a certain bone determines the magnitude of the pulling force exerted by that bone on the vertex.

[0061] Step S156: Determine the transition area based on the seam between the target limb model and the target torso model.

[0062] Generally, a 2-5cm width on both sides of the seam can be used as a transition area. If the body proportion labels of the two models are exactly the same, a 2cm width on each side, or 4cm, can be used as a transition area. If the body proportion labels of the two models are completely different, a 5cm width on each side, or 10cm, can be used as a transition area.

[0063] Step S157: Based on the skin weight distribution map, perform weight fusion on each vertex in the transition region to obtain the latest weight of each vertex to each bone, and normalize the latest weight of each vertex to obtain the candidate character model.

[0064] Specifically, the weights of a vertex to each bone in the two spliced ​​models are determined based on the model in which the vertex is located and the distance of the vertex from the seam. First, the vertical distance d from the vertex in the transition region to the seam is obtained. If the vertex is on the target limb model, then the latest weight of the vertex to each bone in the two models = (2d / width of the transition region) * weight of the vertex to the bones in the target limb model + (1-2d / width of the transition region) * weight of the vertex to the bones in the target torso model. If the vertex is on the target torso model, then the latest weight of the vertex to each bone in the two models = (2d / width of the transition region) * weight of the vertex to the bones in the target torso model + (1-2d / width of the transition region) * weight of the vertex to the bones in the target limb model.

[0065] Taking a vertex on the target limb model as an example, if d is smaller, it means that the vertex is closer to the target torso model. Therefore, the weight of the vertex on each bone in the target torso model should be larger. If d is larger, it means that the vertex is far from the target torso model. In this case, the weight of the vertex on each bone in the target torso model should be smaller, and the weight on each bone in the target limb model should be larger. When d is located at the edge of the transition region, 2d / width of the transition region = 1. At this time, the vertex only retains the weight on each vertex in the target limb model. Finally, after determining the latest weight of the vertex on each bone, the latest weights are normalized to ensure that the sum of the latest weights of the vertex on each bone in the skinning weight distribution map is equal to 1.

[0066] After splicing the target torso model and the target limb model, the above embodiment uses an intelligent fusion algorithm with skin weights to ensure that the candidate character model deforms naturally in the animation with no visible breaks at the seams, greatly reducing the workload of manual adjustments.

[0067] In some embodiments, the limb model set may also include compatible equipment tags for each limb model.

[0068] The generation method also includes: acquiring a set of equipment models; after connecting the target limb model and the target torso model, determining at least one target equipment model in the set of equipment models based on the compatible equipment tags of the target limb model; and combining the target equipment model and the target limb model. Specifically, taking a simulation management game as an example, NPC models can hold equipment models such as farm tools, while the compatible equipment tags corresponding to each limb model are pre-set by the developers who created the limb model based on the posture of the limb model. In the subsequent modular automatic combination process, the target equipment model that can be reasonably combined and spliced ​​onto the target limb model can be selected from the set of equipment models based on the compatible equipment tags. For example, if the target limb model is a right arm in a raised hand posture, its compatible equipment models can be flags, spatulas, etc., thereby further increasing the diversity of NPC models.

[0069] In some embodiments, the generation method further includes: Step S21: After obtaining the candidate character model, calculate the centroid of the candidate character model.

[0070] Step S22: Determine if there is a shift in the center of gravity. If so, adjust the distance between the two leg limb models of the candidate character model according to the direction of the shift in the center of gravity until the center of gravity of the candidate character model is no longer shifted.

[0071] Specifically, the angle between the corresponding limb models of the left and right legs is adjusted according to the direction of the center of gravity shift. If the center of gravity is shifted to the left, the left leg is moved to the outside (opposite to the right leg) or the right leg is moved to the inside (closer to the left leg) by a preset angle / preset distance, and then the process returns to step S21 until the center of gravity no longer shifts.

[0072] The above embodiments perform center of gravity verification and adjustment on the candidate character model after obtaining it, so as to avoid abnormal posture of the candidate character model due to the asymmetry of the angle between the two limb models of the lower limbs and the torso after combination and splicing.

[0073] In some embodiments, the generation method further includes: after selecting the candidate character model corresponding to the selection instruction as a non-player character, obtaining the preset core action and the trigger instruction corresponding to the preset core action, and binding them to the non-player character.

[0074] To further enhance the diversity and realism of NPCs, this application adds preset core actions and corresponding trigger commands to the defined non-player characters. When the player's operation satisfies the corresponding trigger command, the non-player character will execute the preset core action corresponding to the trigger command. Taking a shooting game as an example, the preset core actions can include a variety of basic actions such as standing, combat attack, defense, fear and trembling. The trigger commands and switching logic can be set through the behavior tree panel of the editor. For example, if an explosion occurs within the preset distance range of the non-player character, it will trigger the head-covering action or the fear and trembling action.

[0075] In some embodiments, the generation method further includes: Step S31: After selecting the candidate character model corresponding to the selection command as the non-player character, determine the joint motion constraints of the non-player character based on the body proportion label of the candidate character model.

[0076] Considering that if the movement scale of non-player characters is forcibly uniform when performing the same preset core action, it is easy to cause clipping phenomenon in large-sized and large-dimensional non-player characters, different joint motion constraints are preset based on different body proportion tags (the key is the body dimension). The joint motion constraint is the joint movement range data of the non-player character when performing the preset core action. The joint motion constraint of large body types is smaller than that of small body types.

[0077] Step S32: The non-player character performs a preset core action based on joint motion constraints, and the collision data between the target torso model and each target limb model of the non-player character is detected.

[0078] Step S33: Update the joint motion constraints of the non-player character based on the collision data until there is no collision data when the non-player character performs the preset core action based on the updated joint motion constraints.

[0079] Specifically, the joint motion constraints of the two limb models that collide (or only the limb models if the limb model and the torso model collide) are obtained, the joint motion constraints are reduced by a preset value, and collision detection is performed again.

[0080] Furthermore, the generation method also includes: after the joint motion constraints are updated, determining whether the updated joint motion constraints cover the motion range of the preset core action; if not, deleting the non-player character.

[0081] It is worth noting that if, in order to ensure that non-player characters do not experience clipping issues when performing preset core actions, the joint movement constraints are reduced to the point where the required range of motion for the preset core actions cannot be completed, then it means that the non-player character cannot balance the contradiction between avoiding clipping and perfectly performing the action, and therefore it will be directly removed.

[0082] For example, when a non-player character performs a head-holding gesture, the arm and torso models collide and clip through each other because the arm model is relatively large. To remove the collision, the joint angle of the raised arm model needs to be reduced. If the angle is reduced to less than the joint angle required for the head-holding gesture, the non-player character is deleted.

[0083] The above embodiments perform collision detection on candidate character models when they perform preset core actions to determine whether the preset core actions can be completed without model collision, thereby deleting unreasonable candidate character models.

[0084] After determining the character model for non-player characters, their movement on the game map often relies on manually setting the start and end points, then using path planning algorithms or manual adjustments to obtain the movement route, and moving at a constant speed along the route. However, constant speed movement makes it easy for players to predict the character's location at different times within a level, which can negatively impact the gaming experience, especially in shooting games. Manually setting different movement methods within a level would be significantly less efficient when developing levels with a large number of NPCs. To solve the above problems, please refer to [link to relevant documentation]. Figure 4 In some embodiments, the generation method further includes: Step S41: Obtain the game map, the starting point coordinates of the non-player character's movement, and the ending point coordinates of the movement.

[0085] Step S42: Generate route information from the starting point coordinates to the ending point coordinates based on the path planning algorithm.

[0086] Step S43: Obtain the level duration of the game map and multiple different movement speeds of the non-player character.

[0087] Step S44: Generate movement data for non-player characters based on level duration, movement speed, and route information. The movement data includes the movement speed of non-player characters on different sections of the route information.

[0088] Specifically, the movement data of the non-player character generated based on the level duration, various movement speeds, and route information includes: Step S441: Randomly divide the route information according to the preset number of segments to obtain multiple road segments.

[0089] Step S442: Randomly assign the movement speed of a non-player character to each road segment as the initial speed.

[0090] Step S443: Calculate the movement time based on the length of each road segment and the initial speed. If the movement time is greater than the level time, reduce the maximum initial speed in each road segment according to the preset adjustment step. If the movement time is less than the level time, increase the minimum initial speed in each road segment according to the preset adjustment step until the movement time equals the level time.

[0091] The preset step size can be 0.1 m / s. Different movement speeds for non-player characters can include: slow walking (1.5 m / s), fast walking (3 m / s), and running (5 m / s). These different movement speeds are first assigned to randomly divided road segments. Then, the movement time required for the non-player character to complete the entire route is calculated based on the movement speed of each road segment. The movement speed on each road segment is adjusted based on the relationship between the movement time and the level duration. For example, the speed of the running segment is reduced by 0.1 m / s or the movement speed of the slow walking segment is increased by 0.1 m / s.

[0092] The method for generating movement states of non-player characters in the game map given in the above embodiments can improve the diversity and randomness of non-player characters and further reduce the homogeneity of non-player characters in the game scene.

[0093] Please see Figure 5 Another embodiment of this application provides a device for generating non-player characters in a game, comprising: The acquisition module 101 is used to acquire the association rule database, the torso model set, and multiple limb model sets.

[0094] The torso module 102 is used to randomly extract a set of torso models to obtain the target torso model and the corresponding body proportion label.

[0095] The tag query module 103 is used to query each limb model set based on the association rule database and the body proportion tags of the target torso model, and obtain a list of compatible limb models corresponding to each limb model set.

[0096] The limb module 104 is used to randomly select from each of the compatible limb model lists to obtain multiple target limb models.

[0097] The combination module 105 is used to determine whether the interface parameters of the target torso model and each target limb model match. If they do, the target torso model and each target limb model are combined to obtain the candidate character model.

[0098] The selection module 106 is used to respond to a selection command and select the candidate character model corresponding to the selection command as a non-player character.

[0099] Furthermore, the torso model set includes multiple torso models and corresponding body proportion labels for each torso model; the limb model set includes multiple limb models corresponding to the same limb part and corresponding body proportion labels for each limb model; the association rule database includes a queue of compatible labels corresponding to various body proportion labels; the label query module 103 is specifically used to query the association rule database based on the body proportion labels of the target torso model to obtain the queue of compatible labels corresponding to the body proportion labels of the target torso model, and use it as the target compatible label queue; and to put the limb models in the limb model set whose body proportion labels fall into the target compatible label queue into the list of compatible limb models corresponding to the limb model set.

[0100] Furthermore, the interface parameters of the torso model include torso height and coordinates of multiple limb connection points, while the interface parameters of the limb model include torso connection point coordinates and bone length. The combination module 105 is specifically used to determine the target limb connection point coordinates corresponding to the target limb model on the target torso model; to determine whether the torso connection point coordinates of the target limb model and the target limb connection point coordinates are aligned; if not, the interface parameters do not match; if so, it calculates whether the ratio of torso height to the bone length of each target limb model meets the preset ergonomic range; if so, the interface parameters match, otherwise the interface parameters do not match.

[0101] Furthermore, the combination module 105 is specifically used to connect the target limb model and the target torso model based on the coordinates of the torso connection points of the target limb model and the corresponding coordinates of the target limb connection points on the target torso model; obtain the skinning weight distribution map of each vertex on the target limb model and the target torso model, the skinning weight distribution map including the weights of the vertices to each bone in the target limb model and the target torso model; determine the transition region based on the seam between the target limb model and the target torso model; perform weight fusion on each vertex in the transition region based on the skinning weight distribution map to obtain the latest weights of each vertex to each bone, and normalize the latest weights of each vertex to obtain the candidate character model.

[0102] Furthermore, the limb model set also includes compatible equipment tags for each limb model; the generation device also includes: The equipment combination module is used to obtain a set of equipment models. After connecting the target limb model and the target torso model, it determines at least one target equipment model in the set of equipment models based on the compatible equipment tags of the target limb model; and combines the target equipment model and the target limb model.

[0103] Furthermore, the generating apparatus also includes: The center of gravity adjustment module is used to calculate the center of gravity of the candidate character model after obtaining the candidate character model; determine whether there is a shift in the center of gravity; if so, adjust the distance between the two leg limb models of the candidate character model according to the direction of the shift in the center of gravity until the center of gravity of the candidate character model is no longer shifted.

[0104] Furthermore, the generating apparatus also includes: The action combination module is used to obtain the preset core action and the trigger command corresponding to the preset core action after selecting the candidate character model corresponding to the command as a non-player character, and bind it to the non-player character.

[0105] Furthermore, the generating apparatus also includes: The joint constraint update module is used to determine the joint motion constraints of the non-player character based on the body proportion label of the candidate character model after selecting the candidate character model corresponding to the command. The module then enables the non-player character to perform a preset core action based on the joint motion constraints and detects the collision data between the target torso model and each target limb model of the non-player character. The module updates the joint motion constraints of the non-player character based on the collision data until there is no collision data when the non-player character performs the preset core action based on the updated joint motion constraints.

[0106] Furthermore, the generating apparatus also includes: The joint constraint removal module is used to determine whether the updated joint motion constraints cover the range of motion of the preset core actions after the update of the joint motion constraints is completed. If not, non-player characters are deleted.

[0107] Furthermore, the generating apparatus also includes: The movement status generation module is used to obtain the game map, the starting coordinates and ending coordinates of the non-player character's movement; generate route information from the starting coordinates to the ending coordinates based on the path planning algorithm; obtain the level duration of the game map and multiple different movement speeds of the non-player character; and generate movement data of the non-player character based on the level duration, various movement speeds and route information. The movement data includes the movement speed of the non-player character in different segments of the route information.

[0108] The specific limitations of the device for generating a non-player character in a game provided in this embodiment can be found in the embodiment of the method for generating a non-player character in a game described above, and will not be repeated here. Each module in the above-described device for generating a non-player character in a game can be implemented entirely or partially through software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0109] This application provides a computer device that may include a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it causes the processor to perform the steps of a method for generating a non-player character in a game, as described in any of the above embodiments.

[0110] The working process, working details, and technical effects of the computer device provided in this embodiment can be found in the embodiment of a method for generating non-player characters in a game described above, and will not be repeated here.

[0111] This application provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the steps of a method for generating a non-player character in a game as described in any of the above embodiments. The computer-readable storage medium refers to a data storage medium, which may include, but is not limited to, floppy disks, optical disks, hard disks, flash memory, USB flash drives, and / or memory sticks. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The working process, details, and technical effects of the computer-readable storage medium provided in this embodiment can be found in the embodiments of a method for generating a non-player character in a game described above, and will not be repeated here.

[0112] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM).

[0113] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0114] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method for generating non-player characters in a game, characterized in that, include: Obtain the association rule database, the torso model set, and multiple limb model sets; Randomly select from the set of torso models to obtain the target torso model and the corresponding body proportion label; Based on the association rule database and the body proportion label of the target torso model, query each of the limb model sets to obtain a list of compatible limb models corresponding to each of the limb model sets; Randomly select from each of the compatible limb model lists to obtain multiple target limb models; Determine whether the interface parameters of the target torso model and each of the target limb models match. If they do, combine the target torso model and each of the target limb models to obtain a candidate character model. In response to a selection command, the candidate character model corresponding to the selection command is selected as a non-player character.

2. The method for generating non-player characters in a game according to claim 1, characterized in that, The torso model set includes multiple torso models and body proportion labels corresponding to each torso model; the limb model set includes multiple limb models corresponding to the same limb part and body proportion labels corresponding to each limb model. The association rule database includes a queue of compatible tags corresponding to various body proportion tags; The step of querying each limb model set based on the association rule database and the body proportion labels of the target torso model to obtain a list of compatible limb models corresponding to each limb model set includes: The association rule database is queried based on the body proportion label of the target torso model to obtain the compatible label queue corresponding to the body proportion label of the target torso model, and this queue is used as the target compatible label queue. The limb models whose body proportion labels fall into the target compatible label queue are placed into the compatible limb model list corresponding to the limb model set.

3. The method for generating non-player characters in a game according to claim 2, characterized in that, The interface parameters of the torso model include torso height and coordinates of multiple limb connection points, and the interface parameters of the limb model include torso connection point coordinates and bone length; the step of determining whether the interface parameters of the target torso model and each of the target limb models match includes: Determine the coordinates of the target limb connection point corresponding to the target limb model on the target torso model; Determine whether the coordinates of the torso connection point of the target limb model and the coordinates of the target limb connection point are aligned; If not, the interface parameters do not match; if yes, calculate whether the ratio of the torso height to the bone length of each target limb model meets the preset ergonomic range. If yes, the interface parameters match; otherwise, the interface parameters do not match.

4. The method for generating non-player characters in a game according to claim 3, characterized in that, The combination of the target torso model and each of the target limb models yields a candidate character model, including: Connect the target limb model and the target torso model according to the coordinates of the torso connection points of the target limb model and the coordinates of the corresponding target limb connection points of the target limb model on the target torso model; Obtain the skinning weight distribution map of each vertex on the target limb model and the target torso model, the skinning weight distribution map including the weight of each vertex to each bone in the target limb model and the target torso model; The transition area is determined based on the seam between the target limb model and the target torso model; Based on the skin weight distribution map, the weights of each vertex in the transition region are fused to obtain the latest weights of each vertex to each bone, and the latest weights of each vertex are normalized to obtain the candidate character model.

5. The method for generating non-player characters in a game according to claim 4, characterized in that, The limb model set also includes compatible equipment tags corresponding to each limb model; the generation method further includes: Obtain a set of equipment models. After connecting the target limb model and the target torso model, determine at least one target equipment model in the set of equipment models based on the compatible equipment tags of the target limb model. The target equipment model and the target limb model are combined.

6. The method for generating non-player characters in a game according to claim 1, characterized in that, Also includes: After obtaining the candidate role model, the centroid of the candidate role model is calculated; Determine whether the center of gravity is shifted. If so, adjust the distance between the two leg limb models of the candidate character model according to the direction of the shift in the center of gravity until the center of gravity of the candidate character model is no longer shifted.

7. The method for generating non-player characters in a game according to claim 1, characterized in that, Also includes: After selecting the candidate character model corresponding to the selection instruction as a non-player character, obtain the preset core action and the trigger instruction corresponding to the preset core action, and bind them to the non-player character.

8. The method for generating non-player characters in a game according to claim 7, characterized in that, Also includes: After selecting the candidate character model corresponding to the selection instruction as a non-player character, the joint motion constraints of the non-player character are determined according to the body proportion label of the candidate character model. The non-player character is instructed to perform a preset core action based on the joint motion constraints, and collision data between the target torso model and each target limb model of the non-player character is detected. The non-player character's joint motion constraints are updated based on the collision data until no collision data exists when the non-player character performs a preset core action based on the updated joint motion constraints.

9. The method for generating non-player characters in a game according to claim 8, characterized in that, Also includes: After the joint motion constraints are updated, it is determined whether the updated joint motion constraints cover the range of motion of the preset core action. If not, the non-player character is deleted.

10. The method for generating non-player characters in a game according to claim 1, characterized in that, Also includes: Obtain the game map, the starting coordinates and ending coordinates of the non-player character's movement; The route information from the starting point coordinates to the ending point coordinates is generated based on the path planning algorithm; Obtain the level duration of the game map and the multiple different movement speeds of the non-player character; The movement data of the non-player character is generated based on the level duration, the movement speeds of each character, and the route information. The movement data includes the movement speed of the non-player character on different segments of the route information.

11. The method for generating non-player characters in a game according to claim 10, characterized in that, The step of generating movement data for the non-player character based on the level duration, the various movement speeds, and the route information includes: The route information is randomly divided into multiple road segments according to a preset number of segments; Randomly assign the movement speed of a non-player character to each of the aforementioned road segments as the initial speed; The travel time is calculated based on the length of each road segment and the initial speed. If the movement time is greater than the checkpoint time, the maximum initial speed in each of the road segments is reduced according to a preset adjustment step. If the movement time is less than the checkpoint time, the minimum initial speed in each road segment is increased according to a preset adjustment step, until the movement time equals the checkpoint time.

12. A device for generating non-player characters in a game, characterized in that, include: The acquisition module is used to acquire the association rule database, the torso model set, and multiple limb model sets. The torso module is used to randomly extract the set of torso models to obtain the target torso model and the corresponding body proportion label. The tag query module is used to query each of the limb model sets based on the association rule database and the body proportion tags of the target torso model, and obtain a list of compatible limb models corresponding to each of the limb model sets. The limb module is used to randomly select from each of the compatible limb model lists to obtain multiple target limb models. The combination module is used to determine whether the interface parameters of the target torso model and each of the target limb models match. If they do, the target torso model and each of the target limb models are combined to obtain a candidate character model. The selection module is used to respond to a selection command and select the candidate character model corresponding to the selection command as a non-player character.

13. The device for generating non-player characters in a game according to claim 12, characterized in that, The torso model set includes multiple torso models and body proportion labels corresponding to each torso model; the limb model set includes multiple limb models corresponding to the same limb part and body proportion labels corresponding to each limb model. The association rule database includes a queue of compatible tags corresponding to various body proportion tags; The tag query module is specifically used to query the association rule database based on the body proportion tag of the target torso model to obtain the compatible tag queue corresponding to the body proportion tag of the target torso model, and use it as the target compatible tag queue; and to put the limb models in the limb model set whose body proportion tags fall into the target compatible tag queue into the compatible limb model list corresponding to the limb model set.

14. The device for generating non-player characters in a game according to claim 13, characterized in that, The interface parameters of the torso model include torso height and coordinates of multiple limb connection points, and the interface parameters of the limb model include torso connection point coordinates and bone length. The combination module is specifically used to determine the target limb connection point coordinates corresponding to the target limb model on the target torso model; determine whether the torso connection point coordinates of the target limb model and the target limb connection point coordinates are aligned; if not, the interface parameters do not match; if so, calculate whether the ratio of the torso height to the bone length of each target limb model meets the preset ergonomic range; if so, the interface parameters match, otherwise the interface parameters do not match.

15. The device for generating non-player characters in a game according to claim 14, characterized in that, The combination module is further configured to connect the target limb model and the target torso model based on the coordinates of the torso connection points of the target limb model and the coordinates of the corresponding target limb connection points of the target limb model on the target torso model; and to obtain the skinning weight distribution map of each vertex on the target limb model and the target torso model, wherein the skinning weight distribution map includes the weight of each vertex to each bone in the target limb model and the target torso model. The transition area is determined based on the seam between the target limb model and the target torso model; Based on the skin weight distribution map, the weights of each vertex in the transition region are fused to obtain the latest weights of each vertex to each bone, and the latest weights of each vertex are normalized to obtain the candidate character model.

16. The device for generating non-player characters in a game according to claim 15, characterized in that, The limb model set also includes compatible equipment tags corresponding to each limb model; the generation device further includes: The equipment combination module is used to acquire a set of equipment models. After connecting the target limb model and the target torso model, it determines at least one target equipment model in the set of equipment models based on the compatible equipment tags of the target limb model; and combines the target equipment model and the target limb model.

17. The device for generating non-player characters in a game according to claim 12, characterized in that, Also includes: The center of gravity adjustment module is used to calculate the center of gravity of the candidate character model after obtaining the candidate character model; Determine whether the center of gravity is shifted. If so, adjust the distance between the two leg limb models of the candidate character model according to the direction of the shift in the center of gravity until the center of gravity of the candidate character model is no longer shifted.

18. The device for generating non-player characters in a game according to claim 12, characterized in that, Also includes: The action combination module is used to obtain a preset core action and the triggering command corresponding to the preset core action after the candidate character model corresponding to the selection command is taken as a non-player character, and bind it to the non-player character.

19. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method for generating non-player characters in a game as described in any one of claims 1 to 11.

20. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method for generating non-player characters in a game as described in any one of claims 1 to 11.