Virtual character cluster processing method and device, computer device, and storage medium
By adjusting the motion attribute parameters of the virtual character cluster, and based on the target object's location information and response behavior type, the interaction methods between the virtual characters and player objects are enriched, solving the problem of monotonous interaction methods in virtual animal cluster simulation, and improving the game's interactivity and player engagement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2023-11-21
- Publication Date
- 2026-07-21
AI Technical Summary
In existing virtual animal group simulations, the individual movement patterns are fixed, resulting in a single way of interacting with the virtual objects controlled by the player, poor game interactivity, and reduced player engagement.
By adjusting the motion attribute parameters of each virtual character in the virtual character cluster, and determining the distance difference and response behavior type based on the location information of the target virtual object and the location information of the virtual character cluster, the virtual characters are controlled to perform corresponding behaviors, thus enriching the interaction methods.
It improves the interactivity between the virtual character cluster and the player-controlled object, thereby enhancing the game's replay value and player engagement.
Smart Images

Figure CN117643724B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a method, apparatus, computer device, and storage medium for processing virtual character clusters. Background Technology
[0002] When developing games or producing film and animation, the implementation of virtual scenes and elements aims to closely resemble real-world environments. For example, in game development, artists and designers often propose the creation of game assets. These assets can be designed to simulate various animal groups that resemble real-life environments, such as schools of fish, flocks of birds, herds of horses, or prides of lions, thus constructing a vivid and realistic virtual world.
[0003] Currently, the creation of virtual animal groups is an important area in game technology, primarily used for rendering and simulating animal groups in nature within game scenes. Existing virtual animal group simulations typically employ the Boids algorithm to simulate real-world animal groups. However, in virtual animal groups simulated by current technology, the movement of individual animals follows fixed trajectories, resulting in relatively fixed movement patterns. This leads to a monotonous interaction between the individual animals and the virtual objects controlled by the player, often causing players to feel bored and tedious. Poor game interactivity reduces the game's replay value, making it difficult to attract players to participate repeatedly over a long period, thus lowering player engagement. Summary of the Invention
[0004] This application provides a method, apparatus, computer device, and storage medium for processing a virtual character cluster. By adjusting the game behavior of each virtual character in the virtual character cluster according to the actual interaction scenario, the interaction methods between each virtual character in the virtual character cluster and the virtual objects controlled by the game player are enriched, the interactivity of the game is improved, the replay value of the game is enhanced, and the player's stickiness to the game is increased.
[0005] This application provides a method for processing virtual character clusters, the method including:
[0006] When an interaction event is detected between a target virtual object and a preset virtual character cluster, the response behavior type corresponding to the interaction event is determined, and the position information of the target virtual object and the position information of each virtual character in the virtual character cluster are obtained. Each virtual character in the virtual character cluster is set with corresponding motion attribute parameters.
[0007] The distance difference is determined based on the location information of the target virtual object and the location information of each virtual character in the virtual character cluster;
[0008] Based on the distance difference between each virtual character and the preset adjustment parameters corresponding to the response behavior type, the target adjustment parameters for each virtual character are determined.
[0009] Based on the response behavior type and the target adjustment parameters of each virtual character, the motion attribute parameters of each virtual character in the virtual character cluster are adjusted to control each virtual character in the virtual character cluster to perform the role behavior corresponding to the response behavior type.
[0010] Accordingly, embodiments of this application also provide a processing apparatus for a virtual character cluster, the processing apparatus for the virtual character cluster comprising:
[0011] The first determining unit is used to determine the response behavior type corresponding to the interaction event when an interaction event is detected between the target virtual object and the preset virtual character cluster, and to obtain the position information of the target virtual object and the position information of each virtual character in the virtual character cluster, wherein each virtual character in the virtual character cluster is set with corresponding motion attribute parameters.
[0012] The second determining unit is used to determine the distance difference based on the location information of the target virtual object and the location information of each virtual character in the virtual character cluster;
[0013] The third determining unit is used to determine the target adjustment parameters of each virtual character based on the distance difference between each virtual character and the preset adjustment parameters corresponding to the response behavior type.
[0014] The adjustment unit is used to adjust the motion attribute parameters of each virtual character in the virtual character cluster according to the response behavior type and the target adjustment parameters of each virtual character, so as to control each virtual character in the virtual character cluster to perform the role behavior corresponding to the response behavior type.
[0015] Accordingly, this application also provides a computer device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the processing method for virtual character clusters as described above.
[0016] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the processing method for a virtual character cluster as described above.
[0017] This application provides a method, apparatus, computer device, and storage medium for processing a virtual character cluster. When an interaction event is detected between a target virtual object and a preset virtual character cluster, the method determines the response behavior type corresponding to the interaction event and obtains the location information of the target virtual object and the location information of each virtual character in the virtual character cluster. Each virtual character in the virtual character cluster has corresponding motion attribute parameters. Then, a distance difference is determined based on the location information of the target virtual object and the location information of each virtual character in the virtual character cluster. Next, a target adjustment parameter is determined for each virtual character based on the distance difference and the preset adjustment parameter corresponding to the response behavior type. Finally, the motion attribute parameters of each virtual character in the virtual character cluster are adjusted according to the response behavior type and the target adjustment parameters of each virtual character to control each virtual character in the virtual character cluster to perform the character behavior corresponding to the response behavior type. This application embodiment adjusts the game behavior of each virtual character in the virtual character cluster according to the actual interaction scenario, enriches the interaction methods between each virtual character in the virtual character cluster and the virtual objects controlled by the game player, improves the interactivity of the game, enhances the replay value of the game, and increases the player's stickiness to the game. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a system schematic diagram of the processing device for virtual character clusters provided in the embodiments of this application.
[0020] Figure 2 This is a flowchart illustrating a method for processing virtual character clusters provided in an embodiment of this application.
[0021] Figure 3 This is a schematic diagram of a scenario for processing a virtual character cluster provided in an embodiment of this application.
[0022] Figure 4 This is another scenario diagram illustrating the processing method for virtual character clusters provided in the embodiments of this application.
[0023] Figure 5 This is another scenario diagram illustrating the processing method for virtual character clusters provided in the embodiments of this application.
[0024] Figure 6This is another scenario diagram illustrating the processing method for virtual character clusters provided in the embodiments of this application.
[0025] Figure 7 This is another scenario diagram illustrating the processing method for virtual character clusters provided in the embodiments of this application.
[0026] Figure 8 This is another scenario diagram illustrating the processing method for virtual character clusters provided in the embodiments of this application.
[0027] Figure 9 This is another scenario diagram illustrating the processing method for virtual character clusters provided in the embodiments of this application.
[0028] Figure 10 This is another scenario diagram illustrating the processing method for virtual character clusters provided in the embodiments of this application.
[0029] Figure 11 This is a schematic diagram of the structure of the processing device for the virtual character cluster provided in the embodiments of this application.
[0030] Figure 12 This is a schematic diagram of the structure of the computer device provided in the embodiments of this application. Detailed Implementation
[0031] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0032] Currently, the creation of virtual animal swarms is an important area in game technology, primarily used to render and simulate animal groups in nature within game scenes. Existing virtual animal swarm simulations typically employ the Boids algorithm to simulate real-world animal groups. However, current technology results in virtual animal swarms where individuals show little difference in size and appearance, leading to poor visual appeal. Furthermore, virtual animal swarms lack interaction, and each individual moves along fixed trajectories with predictable patterns. This monotonous interaction between the virtual animals and the player-controlled virtual objects often leads to boredom and reduced replay value, hindering long-term player engagement and reducing player stickiness.
[0033] This application provides a method, apparatus, computer device, and storage medium for processing virtual character clusters. Specifically, the virtual character cluster processing method of this application can be executed by a computer device, which can be a terminal or a server. The terminal can be a smartphone, tablet, laptop, touch screen, game console, personal computer (PC), personal digital assistant (PDA), or other terminal device. The terminal can also include a client, which can be a game application client, a browser client carrying a game program, or an instant messaging client. The server can be an independent physical server, a server cluster composed of multiple physical servers, or a distributed system. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0034] For example, when the processing method for the virtual character cluster runs on a terminal, the terminal device stores a game application and uses it to render virtual scenes in the game. The terminal device is used to interact with the user through a graphical user interface (GUI), such as by downloading, installing, and running the game application. The way the terminal device provides the GUI to the user can be varied; for example, it can be rendered and displayed on the terminal device's screen, or it can present the GUI through holographic projection. For instance, the terminal device can include a touchscreen display and a processor. The touchscreen display is used to present the GUI and receive user input commands generated by the GUI, which includes game visuals. The processor is used to run the game, generate the GUI, respond to input commands, and control the display of the GUI on the touchscreen display.
[0035] For example, when the processing method for the virtual character cluster runs on a server, it can be considered cloud gaming. Cloud gaming refers to a gaming method based on cloud computing. In the cloud gaming operating mode, the game application and the game screen presentation are separate. The storage and execution of the virtual character cluster processing method are completed on the cloud gaming server. The game screen presentation is completed on the cloud gaming client, which is mainly used for receiving and sending game data and presenting the game screen. For example, the cloud gaming client can be a display device with data transmission capabilities located close to the user, such as a mobile terminal, television, computer, PDA, or personal digital assistant. However, the terminal device for processing game data is the cloud gaming server in the cloud. When playing the game, the user operates the cloud gaming client to send operation commands to the cloud gaming server. The cloud gaming server runs the game according to the operation commands, encodes and compresses the game screen and other data, returns it to the cloud gaming client via the network, and finally, the cloud gaming client decodes and outputs the game screen.
[0036] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating a virtual character cluster processing system provided in an embodiment of this application. The system may include at least one terminal, at least one server, at least one database, and a network. A user's terminal can connect to different game servers via the network. The terminal is any device with computing hardware capable of supporting and executing software products corresponding to the game. Furthermore, when the system includes multiple terminals, multiple servers, and multiple networks, different terminals can connect to each other through different networks and servers. The network can be a wireless network or a wired network, such as a wireless local area network (WLAN), local area network (LAN), cellular network, 2G network, 3G network, 4G network, 5G network, etc. Additionally, different terminals can also connect to other terminals or servers using their own Bluetooth networks or hotspot networks. For example, multiple users can connect online through different terminals via appropriate networks and synchronize with each other to support multiplayer games. Furthermore, the system may include multiple databases coupled to different servers, and can continuously store game environment-related information in the databases while different users are playing multiplayer games online.
[0037] This application provides a method for processing virtual character clusters, which can be executed by a terminal or a server. This application example illustrates the method using a terminal. The terminal may include a touchscreen display and a processor (of course, the terminal can also use peripherals such as a mouse or keyboard as input devices; this example only uses a touchscreen display). The touchscreen display is used to present a graphical user interface (GUI) and receive operation commands generated by the user interacting with the GUI. When the user operates the GUI through the touchscreen display, the GUI can control local content on the terminal in response to the received operation commands, or it can control content on a peer server in response to the received operation commands. For example, the operation commands generated by the user interacting with the GUI may include commands to launch a game application. The processor is configured to launch the game application after receiving the user's command to launch the game application. Furthermore, the processor is configured to render and draw the GUI associated with the game on the touchscreen display. The touchscreen display is a multi-touch sensitive screen capable of sensing touch or swipe operations performed simultaneously on multiple points on the screen. Users perform touch operations on the graphical user interface (GUI) using their fingers. Upon detecting the touch operation, the GUI controls different virtual objects within the game's GUI to perform actions corresponding to the touch operation. For example, the game can be any of the following: casual game, action game, role-playing game, strategy game, sports game, puzzle game, etc. The game may include a virtual scene drawn on the GUI. Furthermore, the virtual scene may include one or more virtual objects controlled by the user (or player), such as virtual characters. Additionally, the virtual scene may include one or more obstacles, such as railings, ditches, walls, etc., to restrict the movement of virtual objects, for example, limiting the movement of one or more objects to a specific area within the virtual scene. Optionally, the virtual scene may also include one or more elements, such as skills, scores, character health status, energy, etc., to provide assistance to the player, offer virtual services, increase scores related to player performance, etc. Furthermore, the GUI may present one or more indicators to provide guidance information to the player. For example, the game may include virtual objects controlled by the player and one or more other virtual objects (such as enemy characters). In one embodiment, one or more other virtual objects are controlled by other players in the game. For example, one or more other virtual objects can be controlled by a computer, such as robots using artificial intelligence (AI) algorithms, to enable a human-computer battle mode. For example, virtual objects possess various skills or abilities that game players use to achieve objectives. For example, virtual objects may possess one or more weapons, items, tools, etc., that can be used to eliminate other objects in the game. Such skills or abilities can be activated by the game player using one of several preset touch operations on the terminal's touchscreen display.The processor can be configured to respond to operation commands generated by the user's touch operation to display the corresponding game screen.
[0038] It should be noted that, Figure 1 The schematic diagram of the virtual character cluster processing system shown is merely an example. The processing system and scenario of the virtual character cluster described in this application embodiment are for the purpose of more clearly illustrating the technical solutions of this application embodiment and do not constitute a limitation on the technical solutions provided in this application embodiment. As those skilled in the art will know, with the emergence of new business scenarios, the technical solutions provided in this application embodiment are also applicable to similar technical problems.
[0039] This application provides a method for processing a virtual character cluster. This method can be executed by a terminal or a server. This application example illustrates the method using a terminal. A graphical user interface (GUI) can be provided by the terminal device. The GUI includes at least a partial virtual scene, a target virtual object controlled by the terminal device within the virtual scene, non-player virtual characters, and a virtual character cluster. The virtual character cluster includes multiple virtual characters, which can be non-player characters (NPCs). The partial virtual scene is determined based on the viewing angle of the target virtual character controlled by the terminal device or the non-player virtual character.
[0040] In this embodiment, a virtual scene is a virtual environment displayed (or provided) by an application running on a terminal. This virtual environment can be a simulation of the real world, a semi-simulated / semi-fictional three-dimensional environment, or a purely fictional three-dimensional environment. This virtual environment can be used for virtual environment battles between at least two virtual objects, and it contains virtual resources available for use by at least two virtual objects. One or more virtual objects or virtual characters can be displayed in the virtual scene. Virtual objects and virtual characters can coexist in a virtual scene simultaneously; this is illustrative and not intended to be limiting.
[0041] Virtual characters or virtual objects refer to interactive objects in a virtual environment. Virtual objects refer to game objects controlled by users or players through a terminal. In this embodiment, the virtual object is a game object currently controlled by the player through a terminal, that is, a game character controlled by the player on this terminal.
[0042] This application provides a method, apparatus, computer device, and storage medium for processing virtual character clusters. The method for processing virtual character clusters can be used with terminals such as smartphones, tablets, laptops, or personal computers. The following description uses game development as an example to illustrate the method, apparatus, computer device, and storage medium for processing virtual character clusters. It should be noted that the order of description in the following embodiments is not intended to limit the preferred order of the embodiments.
[0043] Please see Figure 2 , Figure 2 A flowchart illustrating a method for processing virtual character clusters provided in this application embodiment is shown. The specific process can be summarized in steps 101 to 104 as follows:
[0044] 101. When an interaction event is detected between a target virtual object and a preset virtual character cluster, the response behavior type corresponding to the interaction event is determined, and the position information of the target virtual object and the position information of each virtual character in the virtual character cluster are obtained, wherein each virtual character in the virtual character cluster is set with corresponding motion attribute parameters.
[0045] In this embodiment, an interaction event occurs when the target virtual object interacts with a preset cluster of virtual characters. This interaction event can occur when the distance between the target virtual object and the preset cluster of virtual characters meets a preset distance; or, it can occur when the target virtual object collides with the preset cluster of virtual characters. Specifically, the response behavior types include attraction behavior types and escape behavior types, and the motion attribute parameters can include the forward speed, turning speed, and centripetal force of the virtual characters.
[0046] In this embodiment, the Boids algorithm is used to set up a virtual character cluster. Each virtual character (individual) in the virtual character cluster is only affected by other individuals within a certain distance. The influence is divided into three aspects: first, separation force, that is, the neighboring individuals will exert a force that pushes it away; second, alignment force, that is, the current individual's velocity direction will align with the average velocity direction of the neighboring fish; and finally, cohesion force, that is, the current individual will move closer to the average position of the neighboring individuals.
[0047] Specifically, this application implements the basic Boids algorithm. When performing Boids algorithm calculations on each individual (virtual character) in the virtual character cluster, it is necessary to traverse the entire virtual character cluster and examine other individuals within the current individual's neighborhood. These neighboring individuals generate separation, alignment, and cohesion forces. The specific implementation code is shown below:
[0048] / / Normal booid cluster
[0049] uint nearbyCount = 1;
[0050] float neighborRadius=boi dParam.nei ghborRadius*scaleNoise;
[0051] / / Nearest distance of the current fish
[0052] for(int otherIdx=0; otherIdx <boi dParam.boidNum;++otherIdx)
[0053] / / Begin iterating through the entire school of fish
[0054] CVector3f otherBoid,pos=boidData.m_yvMapData[otherIdx].position;
[0055] / / Check the distance between this fish and the current fish.
[0056] float diffLen=boid_pos.Dist(otherBoid pos);
[0057] if(diffLen <neighborRadius)
[0058] / / If within the vicinity of the current fish
[0059] CVector3f diff=boid__pos-otherBoid pos;
[0060] / / Calculate the positional deviation between the current fish and this fish
[0061] float scaler=clamp(1.0f-diffLen / neighborRadius,0.0f, 1.0f);
[0062] / / Map the distance between the two to a range of 0-1, where the closer to 1, the closer they are.
[0063] separation+=diff*(scaler / diffLen);
[0064] / / separatioate Keep your distance from this fish
[0065] alignment+=boi dData.m__vMapData[otherIdx].direction;
[0066] laliammente. Keep in the same direction as this fish.
[0067] cohesion+=otherBoid poS;
[0068] The cohesion force is used to calculate the average position of these fish, and they move closer to that position.
[0069] nearbyCount += 1;
[0070] / / Number of nearby fish +1
[0071] To make the virtual character cluster more realistic and vivid, in this embodiment, each virtual character in the cluster is differentiated. Specifically, different character display information can be randomly assigned to each virtual character in the cluster. By inputting random values for movement speed, size, texture ID, and color saturation (i.e., adjusting the vibrancy of the virtual character's colors), these values are randomly assigned to different virtual characters in the cluster, giving each virtual character a differentiated movement and appearance. Furthermore, different movement effects can be set for different animal types. For example, a crab's movement effect is limited to horizontal movement, while a jellyfish's movement effect is limited to changing direction only within a certain upward range. For example, please refer to... Figure 3 The computer device can provide a graphical user interface, which displays content including a virtual scene and a cluster of virtual characters located in the virtual scene. The cluster of virtual characters includes multiple virtual characters, and each virtual character in the cluster displays different character information, including display size information, display color information, and display mentality information.
[0072] Specifically, in this embodiment, the speed, size, texture ID, and saturation value of a virtual character can be randomly selected from a set range. These random values are then concatenated bitwise into two uints to save memory space. The speed random value is used in the Boids algorithm to update the virtual character's position information; while the size, texture ID, and saturation random values of the virtual character are passed to the GPU shader to modify the rendering effect of each virtual character. The specific implementation code is shown below:
[0073] / / One uint32-bit, bits 1-3 for random values of texture ID, bits 4-11 for random values of red saturation, bits 12-19 for random values of blue saturation;
[0074] / / Place random values for green saturation in bits 20-27, and random values for the final color brightness in bits 28-32.
[0075] uint cId = ((uint)colorId & 0x0007); / / Random value for texture ID
[0076] uint hx = ((uint)(hsv.x*255.0f)&0x00ff); / / Random value for red saturation
[0077] uint hy = ((uint)(hsv.y*255.0f)&0x00ff); / / Random value for blue saturation
[0078] uint hz = ((uint)(hsv.z*255.0f)&0x00ff); / / Random value for green saturation
[0079] uint hf = ((uint)(hsvFinalHueRandom*31.0f)&0x001f); / / Random value for final color brightness
[0080] / / Concatenate all random values into a single uint bit
[0081] data[i].noise=cId|(hx«3)|(hy«11)|(hz«19)|(hf«27);
[0082] Then, these random values, such as velocity, are extracted from the Boids algorithm and added to the final position update calculation. Additionally, the texture IDs or random sizes required for rendering can be obtained by calling the corresponding API in the project's rendering interface.
[0083] To enrich the interaction methods of virtual character clusters, embodiments of this application can enable the transfer of a target virtual character between two virtual character clusters, and the method may include:
[0084] In response to a role transfer event for the virtual character cluster, a target virtual character cluster is identified, and a target virtual character is determined from the virtual character cluster based on a preset selection rule;
[0085] The character information of the target virtual character is removed from the cluster information of the virtual character cluster, and the character information of the target virtual character is added to the cluster information of the target virtual character cluster, so as to control the target virtual character to move to the target virtual character cluster.
[0086] Specifically, the embodiments of this application can realize interaction between virtual character clusters. By realizing the exchange of individuals between Boids clusters, the interaction effect between clusters can be achieved. For example, the virtual character cluster can include a flock of seagulls on the beach and a flock of seagulls in the sky. When the target virtual object approaches the flock of seagulls on the beach, the seagulls in the flock on the beach will be startled and fly away. At this time, the transfer function is called to add the startled seagull to the flock of seagulls in the sky. Then, due to the limitation of the bounding box, the startled seagull will automatically and slowly fly to the flock of seagulls in the sky and follow along to simulate the movement of the flock of seagulls in the sky.
[0087] Furthermore, this application provides two interfaces. The first interface can delete an individual (virtual character) from the virtual character cluster and return the individual's position and direction information before deletion. The second interface can add an individual to the virtual character cluster at a specified position and direction. Then, based on the Boids algorithm, logic can be added to determine which individual needs to be transferred. Currently, there are two transfer mechanisms: the first is timed transfer, where one individual is transferred at set intervals; the second is collision transfer, where an individual is transferred when a player collides with it. For timed transfer, an individual can be randomly selected for transfer, or the outermost individual can be selected for the most natural transfer effect. For collision transfer, if an individual is already in the process of being transferred, the transfer command should not be triggered repeatedly. Here, `eNeedTransferType` is used to distinguish the current transfer status of the individual. Finally, after the Boids algorithm returns the individual to be transferred, DelOneInBoid and AddOneInBoid can be called sequentially to remove the individual from the original virtual character cluster and add it to the new virtual character cluster. During this step, corresponding animations can be played; for example, a takeoff animation can be played when a seagull is joining a sky seagull flock from the ground. The entire animation mechanism can be controlled by a state machine. It's important to note that after a virtual character transfer is initiated within a cluster, it's necessary to monitor when the transfer is complete. In the normal process, the transfer is considered complete once the individual enters the bounding box of the target virtual character cluster. For special cases, such as a seagull landing in the sky to join a ground seagull flock, the current individual's altitude above the ground needs to be determined. If the altitude difference is less than a threshold, a landing animation should be played, and the transfer state should be cleared.
[0088] For example, please refer to the following: Figure 4 , Figure 5 and Figure 6The computer device can provide a graphical user interface (GUI) that displays a virtual scene and a first virtual character cluster and a second virtual character cluster located in the virtual scene. In response to a character transfer event for the first virtual character cluster, the computer device can determine that the target virtual character cluster is the second virtual character cluster, determine the target virtual character from the virtual character cluster based on a preset selection rule, and then remove the character information of the target virtual character from the cluster information of the first virtual character cluster and add the character information of the target virtual character to the cluster information of the second virtual character cluster, thereby controlling the target virtual character to move to the second virtual character cluster.
[0089] In one embodiment, the method may further include:
[0090] Obtain the virtual bounding box of the virtual character cluster, wherein the bounding box information corresponding to the virtual bounding box includes position information, bounding box size information and bounding box shape information;
[0091] The virtual cluster range is determined based on the bounding box information;
[0092] When it is detected that the display position of a target virtual character in the virtual character cluster exceeds the range of the virtual cluster, motion adjustment information is determined based on the display position of the target virtual character and the bounding box information;
[0093] Based on the motion adjustment information, the motion attribute parameters of the target virtual character are adjusted to control the target virtual character to move towards the virtual bounding box.
[0094] In another embodiment, the method may further include:
[0095] In response to the size adjustment command for the virtual character cluster, the bounding box size information of the virtual bounding box is adjusted based on the size adjustment parameters of the size adjustment command to obtain the adjusted virtual bounding box.
[0096] In yet another embodiment, the method may further include:
[0097] In response to the shape adjustment command for the virtual character cluster, the bounding box shape information of the virtual bounding box is adjusted based on the shape adjustment parameters of the shape adjustment command to obtain the adjusted virtual bounding box.
[0098] Specifically, in this embodiment, the aspect ratio coefficient can be set to adjust the y-direction component of the cohesion force, thereby controlling the overall aspect ratio of the entire virtual character cluster. For example, the cohesion force of the Boid algorithm causes the entire virtual character cluster to tend towards the center. Normally, this force is evenly distributed around the perimeter, so a typical fish school resembles a sphere. If the vertical component of the cohesion force is attenuated, for example, by multiplying it by 0.5, the constraint force on the virtual character cluster in the vertical direction will weaken, and the entire virtual character cluster will lengthen. Then, the virtual character in the cluster can be determined based on the virtual bounding box of the cluster. If it exceeds the boundary, it will move into the virtual bounding box. The specific implementation code is shown below:
[0099] / / OBB bounding box limitations
[0100] bool bAvoid0BB = false;
[0101] if(boi dParam.need0BB){
[0102] for(int i = 0; i < 6; ++i){ / / Each bounding box consists of six planes (six faces of a cuboid)
[0103] CVector3f plane__normal = boidData.m_CB_0BBData.m__OBBPlane[i]; / / Normal vector of the current calculation plane.
[0104] plane__normal.Normalize();
[0105] CVector3f obb_center=boidData.m_CB_0BBData.m_OBBCenter;
[0106] / / Coordinates of the center point of the entire bounding box
[0107] CVector3f plane_center=boidData.m_CB._0BBData.m__OBBPlane[i];
[0108] / / Coordinates of the center point of the current calculation plane
[0109] float distance = plane_normal.Dot(boid_pos) - plane__normal.Dot(obb_center + plane_center); / / Calculate the distance of the fish from this calculation plane. A positive number indicates that it is outside the plane. if (distance > 0) { / / If it is outside the plane, it means that it has already left the bounding box. It should swim back into the bounding box and increase its speed.
[0110] bAvoidOBB = true;
[0111] avoi dOBBDirection=-plane_normal;
[0112] speedAccelerate = 1.2f;
[0113] rotateAccelerate = 1.2f;
[0114] To optimize the rendering of virtual character clusters, in this embodiment, each virtual character cluster undergoes a first clipping based on its bounding box. If the bounding box is not within the virtual camera's view, the entire cluster represented by that box is not rendered. If the bounding box is valid, a second clipping is performed on each individual (virtual character) within it. If an individual is not within the view or is too far away, it is still not rendered. During final rendering, GPU instantiation is used, rendering all individuals in the cluster with a single draw instruction. Furthermore, since all individuals in a virtual character cluster represent a single model, instantiation can be used to render all cluster individuals at once with a single draw instruction. The specific implementation code is shown below:
[0115] / / First, check if the bounding box of this school of fish is within the player's field of view. If not, don't draw it. if(itFrustum->m_pFrustum->0BBInFrustum(0BBCenter,OBBSide,NULD) / / Next, check if this school of fish is too far from the player. If it is too far, don't draw it either.
[0116] if(!CullSmal10bject(OBBCenter,cullCoeff*0BBScale,BOID_CULL_SMALL_BEGIN_DIST,viewPos,BOID_CULL_SMALL_DENSITY)) / / Remove small objects bVisible=true;
[0117] break;
[0118] 102. Determine the distance difference based on the location information of the target virtual object and the location information of each virtual character in the virtual character cluster.
[0119] In this embodiment of the application, the computer device can determine the distance difference based on the location information of the target virtual object and the location information of each virtual character in the virtual character cluster.
[0120] 103. Based on the distance difference between each virtual character and the preset adjustment parameters corresponding to the response behavior type, determine the target adjustment parameters for each virtual character.
[0121] In this embodiment of the application, the step of "determining the target adjustment parameters for each virtual character based on the distance difference between each virtual character and the preset adjustment parameters corresponding to the response behavior type" may include:
[0122] The target weight is determined based on the distance difference between the virtual characters and the preset rules corresponding to the response behavior types;
[0123] The target adjustment parameters of the virtual character are determined based on the preset adjustment parameters corresponding to the target weight and the response behavior type.
[0124] Specifically, this application incorporates a proximity effect into the Boids algorithm. When the distance between each virtual character (individual) in the virtual character cluster and the target virtual object controlled by the player is less than a set threshold, the individual, in addition to the basic force of the Boids algorithm, will also experience a force that pulls them closer to the center of the target virtual object. If they get too close, they will also experience a reverse obstacle avoidance force to prevent clipping. Furthermore, if the fear effect is activated, each individual will update its fear coefficient based on its distance from the predator. This fear coefficient will be weighted with the fear coefficients of surrounding individuals, and the movement speed and centripetal force of the virtual character will be updated based on this weighted coefficient.
[0125] In one specific embodiment, the response behavior type is an attraction behavior type, and the step "determining the target weight based on the distance difference of the virtual character and the preset rule corresponding to the response behavior type" may include:
[0126] The first target weight is determined based on the distance difference between the virtual characters, the preset weight value, and the first preset rule;
[0127] The target adjustment parameters of the virtual character are determined based on the preset adjustment parameters corresponding to the first target weight and the attraction behavior type.
[0128] Among them, the first preset rule is that the closer the virtual character is to the virtual object, the smaller the weight of the preset weight value (so that the closer force is smaller). That is, the preset weight value of the virtual character closer to the virtual object is adjusted to a smaller value.
[0129] For example, please refer to Figure 7 and Figure 8 , the computer device can provide a graphical user interface, and the content displayed on the graphical user interface includes a virtual scene and a virtual character cluster located in the virtual scene. When it is detected that the first target virtual character collides with the preset virtual character cluster, that is, when the first target virtual character has an interaction event with the preset virtual character cluster, the computer device can determine that the response behavior type corresponding to the interaction event is an attraction behavior type, and obtain the position information of the first target virtual character and the position information of each virtual character in the virtual character cluster; then, the computer device determines a distance difference based on the position information of the first target virtual character and the position information of each virtual character in the virtual character cluster, and determines the target adjustment parameter of each virtual character according to the distance difference of each virtual character and the preset adjustment parameter corresponding to the attraction behavior type; finally, according to the attraction behavior type and the target adjustment parameter of each virtual character, the movement attribute parameters of each virtual character in the virtual character cluster are adjusted to control each virtual character in the virtual character cluster to execute the role behavior corresponding to the attraction behavior type, that is, to control each virtual character in the virtual character cluster to approach the first target virtual character.
[0130] Among them, in the embodiment of the present application, the proximity effect is added. Each virtual character that requires the proximity effect can be set as the target in the algorithm. Each individual in the cluster will traverse all targets and find the nearest one. If the distance from this nearest target is less than the set m_TargetFollowDistance, then this individual will receive a followTargetDirection pointing to the target, and the weight of this closer force will be smaller the closer it is to the target. In this way, after getting close to the virtual object, the individual is more affected by the Boids algorithm and will not collide with the virtual object. The specific implementation code is as follows:
[0131] for(uint targetIdx = 0; targetIdx < targetCnt; targetIdx++) / / Traverse all targets
[0132] CVector3f targetPos = boidData.m CBTarget.margetPositionsAndSpeed[targetIdx]; / / Target coordinate
[0133] float targetRadius = (float)((int)boidData.mCBTarget.
[0134] m_TargetPositionsAndSpeed[targetIdx][3] % 1000); / / Target object's own radius size
[0135] float targetSpeed = boidData.mCBTarget.m_TargetPositionsAndSpeed[targetIdx][3] / 1000; / / Target object's speed
[0136] float dis = boid_pos.Dist(targetPos); / / Distance between the current fish and the target object
[0137] if (dis < boidData.m._CBTarget.m_TargetFollowDistance && dis < nearestTargetDistance) / / If the distance between the current fish and the target object is less than the approach distance, bFollowTarget = true
[0138] nearestTargetDistance = dis;
[0139] / / Weight of the approach force. The closer to the target object and the larger the target object's own radius, the smaller this approach force weight, to avoid getting too close to the target object
[0140] targetWeight = min(1.0f, 0.3f * nearestTargetDistance / targetRadiusD;
[0141] / / Direction of the approach force.
[0142] followTargetDirection = CVector3f(targetPos - boid_pos).Normalize();
[0143] / / There should be some acceleration effect when approaching
[0144] speedAccelerate = 1.2f;
[0145] nearestTargetPos = targetPos;
[0146] In another specific embodiment, the response behavior type is an escape behavior type, and the step "determining the target weight based on the distance difference of the virtual character and the preset rule corresponding to the response behavior type" may include:
[0147] Obtain a first preset judgment range of the target virtual object, and determine the range radius of the preset judgment range;
[0148] The second target weight is determined based on the distance difference between the virtual characters, the radius of the range, and the second preset rule;
[0149] The target adjustment parameters of the virtual character are determined based on the second target weight and the preset adjustment parameters corresponding to the escape behavior type.
[0150] The second preset rule is as follows: if the virtual character is within the first preset judgment range, the distance difference is obtained by subtracting the distance difference (that is, the distance difference between the target virtual object and the virtual character) from the range radius. Then, the arctangent function is applied to the distance difference to map it to the interval of 0-1. The final calculated value is the second target weight (i.e., fear weight). The closer it is to 1, the closer the virtual character is to the target virtual object.
[0151] For example, please refer to the following: Figure 9 and Figure 10 The computer device can provide a graphical user interface (GUI) displaying a virtual scene and a cluster of virtual characters within that scene. When a collision event is detected between a second target virtual character and a preset cluster of virtual characters (i.e., an interaction event occurs between the second target virtual character and the preset cluster of virtual characters), the computer device can determine that the response behavior type corresponding to the interaction event is an escape behavior type, and acquire the location information of the second target virtual character and the location information of each virtual character in the cluster. Then, based on the location information of the second target virtual character and the location information of each virtual character in the cluster, the computer device determines a distance difference. Based on the distance difference of each virtual character and the preset adjustment parameters corresponding to the escape behavior type, the computer device determines the target adjustment parameters of each virtual character. Finally, based on the attraction behavior type and the target adjustment parameters of each virtual character, the computer device adjusts the motion attribute parameters of each virtual character in the cluster to control each virtual character in the cluster to perform the character behavior corresponding to the escape behavior type, i.e., to control each virtual character in the cluster to move away from the second target virtual character.
[0152] To make the escape effect more realistic, it is also necessary to consider the influence of the fear factors of neighboring virtual characters on the target adjustment parameters. After the step of "determining the second target weight according to the distance difference of the virtual character, the range radius, and the second preset rule", the method may include:
[0153] Obtain the second preset judgment range of the virtual character;
[0154] Obtain the second target weight of other virtual characters located within the second preset judgment range;
[0155] Based on the second target weight of the virtual character, the second target weights of all other virtual characters, and the third preset rule, determine the third target weight;
[0156] Determine the target adjustment parameter of the virtual character according to the preset adjustment parameter corresponding to the third target weight and the escape behavior type.
[0157] Among them, in the embodiment of the present application, a fear effect is set. First, the fear propagation radius of each predator is set and passed into the algorithm. Each individual in the cluster traverses these predators. If it is within the fear radius of the predator, the distance difference is obtained by subtracting the distance between the two from the fear radius, and then this distance difference is used for the arctangent function operation and mapped to the interval of 0-1. The finally calculated value is its fear factor. The closer it is to 1, the closer it is to the predator. The specific implementation code is as follows:
[0158] / / Fear model
[0159] float fearRadius = boidData.mCB0bstacle.mPredatorFearRadius[obstacleIdx];
[0160] / / The fear radius of this fear source
[0161] if (fearRadius > 0.0) {
[0162] float dis = boid.pos.Dist(obstacleCenter); / / The distance of the current fish from the fear source if (dis < fearRadius) { / / If the distance is less than the fear radius, the fear effect is added float tmp = atan((fearRadius - dis) / boidParam.emotionSlope) / (PI)+0.5f;
[0163] / / Calculate the fear emotion, which is a value between 0 and 1. The closer it is to 1, the more fearful
[0164] escape=(boid.pOS2obstacleCenter)7dis;
[0165] / / Calculate the direction to escape the source of fear|
[0166] Next, when traversing the cluster and calculating the basic Boids algorithm, we need to add an extra step: obtaining the fear factors of neighboring individuals and averaging them. This average represents the fear level of other individuals in the vicinity, as fear is contagious. Finally, when calculating the fear factor of the current individual, we use the value calculated in the previous step and the fear factors of surrounding individuals for a weighted sum to obtain the current individual's fear factor. This fear factor affects the current individual's forward speed, turning speed, and centripetal force weight. The specific implementation code is shown below:
[0167] / / Normal booid cluster
[0168] uint nearbyCount = 1;
[0169] f1oat neighborRadius=boidParam.neighborRadius*scaleNoise;
[0170] / / Iterate through the entire school of fish and find the neighboring fish of the currently being calculated fish.
[0171] for(int otherIdx=0; otherIdx <boidParam.boidNum;++otherIdx)
[0172] CVector3f otherBoid_pos=boidData.m__vMapData[otherIdx].position;
[0173] float diffLen=boid__pos.Dist(otherBoid_pos);
[0174] if(diffLen<neighborRadius&&diffLen> 0.01)
[0175] Fear of contagion
[0176] float otherBoid_ES__Contagion;
[0177] / / Gain the fear of neighboring fish
[0178] GetBoi dEmotionState(boi dData.m__vMapData[other Idx].noise2, otherBoid_ES_Contagion);
[0179] / / Add up the fear levels of all neighboring fish
[0180] ES_Contagion+=otherBoid_ES_Contagion;
[0181] / / Fear Model
[0182] ES_Contagion* = avg;
[0183] / / Average fear level of neighboring fish
[0184] / / The final fear level is a weighted average of the average fear level of neighboring fish and the currently calculated fear level.
[0185] ES=boidParam.emotionContagionWeight*ES_Contagion+(1-boidParam.emotionContagionWeight)*ES_Predator;
[0186] / / Increase movement speed and turning speed based on calculated fear levels.
[0187] speedAccelerate=max(speedAccelerate, 1+boidParam.emotionSpeedAccelerate*ES);
[0188] rotateAccelerate=max(rotateAccelerate, 1+boidParam.emotionRotateAccelerate*ES);
[0189] / / Save this fear so that other fish can use it when calculating.
[0190] SetBoi dEmotionState(ES, boidData.m__vMapData[idx].noise2);
[0191] 104. Based on the response behavior type and the target adjustment parameters of each virtual character, the motion attribute parameters of each virtual character in the virtual character cluster are adjusted to control each virtual character in the virtual character cluster to perform the role behavior corresponding to the response behavior type.
[0192] In this embodiment of the application, the step "adjusting the motion attribute parameters of each virtual character in the virtual character cluster according to the response behavior type and the target adjustment parameters of each virtual character, so as to control each virtual character in the virtual character cluster to execute the character behavior corresponding to the response behavior type" may include:
[0193] Based on the response behavior type and the display position of the target virtual object, the target movement direction of the virtual character is determined;
[0194] The motion attribute parameters of the virtual character are adjusted based on the target motion direction and the target adjustment parameters to control the virtual character to move towards the target motion direction according to the adjusted motion attribute parameters.
[0195] In summary, the virtual character cluster processing method provided in this application embodiment can determine the response behavior type corresponding to the interaction event when an interaction event is detected between a target virtual object and a preset virtual character cluster, and obtain the position information of the target virtual object and the position information of each virtual character in the virtual character cluster, wherein each virtual character in the virtual character cluster is set with corresponding motion attribute parameters; then, a distance difference is determined based on the position information of the target virtual object and the position information of each virtual character in the virtual character cluster; next, a target adjustment parameter for each virtual character is determined according to the distance difference of each virtual character and the preset adjustment parameter corresponding to the response behavior type; finally, the motion attribute parameters of each virtual character in the virtual character cluster are adjusted according to the response behavior type and the target adjustment parameters of each virtual character, so as to control each virtual character in the virtual character cluster to perform the character behavior corresponding to the response behavior type. This application embodiment adjusts the game behavior of each virtual character in the virtual character cluster according to the actual interaction scenario, enriches the interaction methods between each virtual character in the virtual character cluster and the virtual objects controlled by the game player, improves the interactivity of the game, enhances the replay value of the game, and increases the player's stickiness to the game.
[0196] To better implement the above methods, embodiments of this application may also provide a processing device for a virtual character cluster, which may be integrated into a computer device, such as a terminal or other computer device.
[0197] Please see Figure 11 , Figure 11 This is a schematic diagram of a processing device for a virtual character cluster provided in an embodiment of this application. The device includes:
[0198] The first determining unit 201 is used to determine the response behavior type corresponding to the interaction event when an interaction event is detected between the target virtual object and the preset virtual character cluster, and to obtain the position information of the target virtual object and the position information of each virtual character in the virtual character cluster, wherein each virtual character in the virtual character cluster is set with corresponding motion attribute parameters.
[0199] The second determining unit 202 is used to determine the distance difference based on the location information of the target virtual object and the location information of each virtual character in the virtual character cluster;
[0200] The third determining unit 203 is used to determine the target adjustment parameters of each virtual character based on the distance difference of each virtual character and the preset adjustment parameters corresponding to the response behavior type.
[0201] The adjustment unit 204 is used to adjust the motion attribute parameters of each virtual character in the virtual character cluster according to the response behavior type and the target adjustment parameters of each virtual character, so as to control each virtual character in the virtual character cluster to perform the role behavior corresponding to the response behavior type.
[0202] In some embodiments, the processing apparatus for the virtual character cluster includes:
[0203] The first determining subunit is used to determine the target weight based on the distance difference of the virtual character and the preset rules corresponding to the response behavior type;
[0204] The first determining subunit is further configured to determine the target adjustment parameters of the virtual character based on the preset adjustment parameters corresponding to the target weight and the response behavior type.
[0205] In some embodiments, the processing apparatus for the virtual character cluster includes:
[0206] The second determining subunit is used to determine the target movement direction of the virtual character based on the response behavior type and the display position of the target virtual object;
[0207] The first adjustment subunit is used to adjust the motion attribute parameters of the virtual character based on the target motion direction and the target adjustment parameters, so as to control the virtual character to move towards the target motion direction according to the adjusted motion attribute parameters.
[0208] In some embodiments, the processing apparatus for the virtual character cluster includes:
[0209] The third determining subunit is used to determine the first target weight based on the distance difference of the virtual character, the preset weight value, and the first preset rule;
[0210] The third determining subunit is further configured to determine the target adjustment parameters of the virtual character based on the preset adjustment parameters corresponding to the first target weight and the attraction behavior type.
[0211] In some embodiments, the processing apparatus for the virtual character cluster includes:
[0212] The fourth determining subunit is used to obtain the first preset judgment range of the target virtual object and determine the range radius of the preset judgment range;
[0213] The fourth determining subunit is further configured to determine the second target weight based on the distance difference of the virtual character, the range radius, and the second preset rule;
[0214] The fourth determining subunit is further configured to determine the target adjustment parameters of the virtual character based on the preset adjustment parameters corresponding to the second target weight and the escape behavior type.
[0215] In some embodiments, the processing apparatus for the virtual character cluster includes:
[0216] The first acquisition subunit is used to acquire the second preset judgment range of the virtual character;
[0217] The first acquisition subunit is also used to acquire the second target weights of other virtual characters located within the second preset judgment range;
[0218] The fifth determining subunit is used to determine the third target weight based on the second target weight of the virtual character, the second target weights of all other virtual characters, and the third preset rule;
[0219] The fifth determining subunit is further configured to determine the target adjustment parameters of the virtual character based on the preset adjustment parameters corresponding to the third target weight and the escape behavior type.
[0220] In some embodiments, the processing apparatus for the virtual character cluster includes:
[0221] The first response subunit is used to respond to a role transfer event for the virtual role cluster, determine the target virtual role cluster, and determine the target virtual role from the virtual role cluster based on a preset selection rule;
[0222] The processing subunit is used to remove the character information of the target virtual character from the cluster information of the virtual character cluster and add the character information of the target virtual character to the cluster information of the target virtual character cluster, so as to control the target virtual character to move to the target virtual character cluster.
[0223] In some embodiments, the processing apparatus for the virtual character cluster includes:
[0224] The second acquisition subunit is used to acquire the virtual bounding box of the virtual character cluster, wherein the bounding box information corresponding to the virtual bounding box includes position information, bounding box size information and bounding box shape information;
[0225] The sixth determining subunit is used to determine the virtual cluster range based on the bounding box information;
[0226] The sixth determining subunit is further configured to determine motion adjustment information based on the display position of the target virtual character and the bounding box information when it is detected that the display position of the target virtual character in the virtual character cluster exceeds the range of the virtual cluster;
[0227] The second adjustment subunit is used to adjust the motion attribute parameters of the target virtual character based on the motion adjustment information, so as to control the target virtual character to move towards the virtual bounding box.
[0228] In some embodiments, the processing apparatus for the virtual character cluster includes:
[0229] The third adjustment subunit is used to respond to the size adjustment command for the virtual character cluster, and adjust the bounding box size information of the virtual bounding box based on the size adjustment parameters of the size adjustment command to obtain the adjusted virtual bounding box.
[0230] In some embodiments, the processing apparatus for the virtual character cluster includes:
[0231] The fourth adjustment subunit is used to respond to the shape adjustment command for the virtual character cluster, and adjust the bounding box shape information of the virtual bounding box based on the shape adjustment parameters of the shape adjustment command to obtain the adjusted virtual bounding box.
[0232] This application discloses a processing device for a virtual character cluster. A first determining unit 201, upon detecting an interaction event between a target virtual object and a preset virtual character cluster, determines the response behavior type corresponding to the interaction event and acquires the location information of the target virtual object and the location information of each virtual character in the virtual character cluster. Each virtual character in the virtual character cluster has corresponding motion attribute parameters. A second determining unit 202 determines a distance difference based on the location information of the target virtual object and the location information of each virtual character in the virtual character cluster. A third determining unit 203 determines target adjustment parameters for each virtual character based on the distance difference between the virtual characters and the preset adjustment parameters corresponding to the response behavior type. An adjustment unit 204 adjusts the motion attribute parameters of each virtual character in the virtual character cluster according to the response behavior type and the target adjustment parameters of each virtual character, thereby controlling each virtual character in the virtual character cluster to perform the character behavior corresponding to the response behavior type. This application embodiment adjusts the game behavior of each virtual character in the virtual character cluster according to the actual interaction scenario, enriches the interaction methods between each virtual character in the virtual character cluster and the virtual objects controlled by the game player, improves the interactivity of the game, enhances the replay value of the game, and increases the player's stickiness to the game.
[0233] Accordingly, this application also provides a computer device, which can be a terminal or a server. The terminal can be a smartphone, tablet computer, laptop computer, touch screen, game console, personal computer (PC), personal digital assistant (PDA), or other terminal device. Figure 12 As shown, Figure 12 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The computer device 300 includes a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, and a computer program stored in the memory 302 and executable on the processor. The processor 301 and the memory 302 are electrically connected. Those skilled in the art will understand that the computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0234] The processor 301 is the control center of the computer device 300. It connects various parts of the computer device 300 through various interfaces and lines. By running or loading software programs and / or modules stored in the memory 302, and calling data stored in the memory 302, it performs various functions of the computer device 300 and processes data, thereby monitoring the computer device 300 as a whole.
[0235] In this embodiment, the processor 301 in the computer device 300 loads the instructions corresponding to the processes of one or more applications into the memory 302 according to the following steps, and the processor 301 runs the applications stored in the memory 302 to achieve various functions:
[0236] When an interaction event is detected between a target virtual object and a preset virtual character cluster, the response behavior type corresponding to the interaction event is determined, and the position information of the target virtual object and the position information of each virtual character in the virtual character cluster are obtained. Each virtual character in the virtual character cluster is set with corresponding motion attribute parameters.
[0237] The distance difference is determined based on the location information of the target virtual object and the location information of each virtual character in the virtual character cluster;
[0238] Based on the distance difference between each virtual character and the preset adjustment parameters corresponding to the response behavior type, the target adjustment parameters for each virtual character are determined.
[0239] Based on the response behavior type and the target adjustment parameters of each virtual character, the motion attribute parameters of each virtual character in the virtual character cluster are adjusted to control each virtual character in the virtual character cluster to perform the role behavior corresponding to the response behavior type.
[0240] In one embodiment, determining the target adjustment parameters for each virtual character based on the distance difference between each virtual character and the preset adjustment parameters corresponding to the response behavior type includes:
[0241] The target weight is determined based on the distance difference between the virtual characters and the preset rules corresponding to the response behavior types;
[0242] The target adjustment parameters of the virtual character are determined based on the preset adjustment parameters corresponding to the target weight and the response behavior type.
[0243] In one embodiment, adjusting the motion attribute parameters of each virtual character in the virtual character cluster according to the response behavior type and the target adjustment parameters of each virtual character, so as to control each virtual character in the virtual character cluster to perform the role behavior corresponding to the response behavior type, includes:
[0244] Based on the response behavior type and the display position of the target virtual object, the target movement direction of the virtual character is determined;
[0245] The motion attribute parameters of the virtual character are adjusted based on the target motion direction and the target adjustment parameters to control the virtual character to move towards the target motion direction according to the adjusted motion attribute parameters.
[0246] In one embodiment, the response behavior type is an attraction behavior type;
[0247] The step of determining the target weight based on the distance difference of the virtual character and the preset rules corresponding to the response behavior type includes:
[0248] The first target weight is determined based on the distance difference between the virtual characters, the preset weight value, and the first preset rule;
[0249] The target adjustment parameters of the virtual character are determined based on the preset adjustment parameters corresponding to the first target weight and the attraction behavior type.
[0250] In one embodiment, the response behavior type is an escape behavior type;
[0251] The step of determining the target weight based on the distance difference of the virtual character and the preset rules corresponding to the response behavior type includes:
[0252] Obtain a first preset judgment range of the target virtual object, and determine the range radius of the preset judgment range;
[0253] The second target weight is determined based on the distance difference between the virtual characters, the radius of the range, and the second preset rule;
[0254] The target adjustment parameters of the virtual character are determined based on the second target weight and the preset adjustment parameters corresponding to the escape behavior type.
[0255] In one embodiment, after determining the second target weight based on the distance difference of the virtual character, the range radius, and the second preset rule, the method further includes:
[0256] Obtain the second preset judgment range of the virtual character;
[0257] Obtain the second target weights of other virtual characters located within the second preset judgment range;
[0258] The third target weight is determined based on the second target weight of the virtual character, the second target weights of all other virtual characters, and the third preset rule;
[0259] The target adjustment parameters of the virtual character are determined based on the preset adjustment parameters corresponding to the third target weight and the escape behavior type.
[0260] In one embodiment, the method further includes:
[0261] In response to a role transfer event for the virtual character cluster, a target virtual character cluster is identified, and a target virtual character is determined from the virtual character cluster based on a preset selection rule;
[0262] The character information of the target virtual character is removed from the cluster information of the virtual character cluster, and the character information of the target virtual character is added to the cluster information of the target virtual character cluster, so as to control the target virtual character to move to the target virtual character cluster.
[0263] In one embodiment, the method further includes:
[0264] Obtain the virtual bounding box of the virtual character cluster, wherein the bounding box information corresponding to the virtual bounding box includes position information, bounding box size information and bounding box shape information;
[0265] The virtual cluster range is determined based on the bounding box information;
[0266] When it is detected that the display position of a target virtual character in the virtual character cluster exceeds the range of the virtual cluster, motion adjustment information is determined based on the display position of the target virtual character and the bounding box information;
[0267] Based on the motion adjustment information, the motion attribute parameters of the target virtual character are adjusted to control the target virtual character to move towards the virtual bounding box.
[0268] In one embodiment, after obtaining the virtual bounding box of the virtual character cluster, the method further includes:
[0269] In response to the size adjustment command for the virtual character cluster, the bounding box size information of the virtual bounding box is adjusted based on the size adjustment parameters of the size adjustment command to obtain the adjusted virtual bounding box.
[0270] In one embodiment, after obtaining the virtual bounding box of the virtual character cluster, the method further includes:
[0271] In response to the shape adjustment command for the virtual character cluster, the bounding box shape information of the virtual bounding box is adjusted based on the shape adjustment parameters of the shape adjustment command to obtain the adjusted virtual bounding box.
[0272] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0273] Optional, such as Figure 12 As shown, the computer device 300 also includes: a touch screen display 303, a radio frequency circuit 304, an audio circuit 305, an input unit 306, and a power supply 307. The processor 301 is electrically connected to the touch screen display 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306, and the power supply 307. Those skilled in the art will understand that... Figure 12 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0274] The touch display screen 303 can be used to display a graphical user interface (GUI) and receive operation commands generated by the user interacting with the GUI. The touch display screen 303 may include a display panel and a touch panel. The display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the computer device. These graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof. Optionally, the display panel can be configured using a liquid crystal display (LCD), organic light-emitting diode (OLED), or other similar technologies. The touch panel can be used to collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel), generate corresponding operation commands, and execute the corresponding program according to the operation commands. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch location and the signal generated by the touch operation, transmitting the signal to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 301. It can also receive and execute commands from the processor 301. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it transmits the information to the processor 301 to determine the type of touch event. Subsequently, the processor 301 provides corresponding visual output on the display panel based on the type of touch event. In this embodiment, the touch panel and the display panel can be integrated into the touch display screen 303 to achieve input and output functions. However, in some embodiments, the touch panel and the touch display screen 303 can be implemented as two independent components to achieve input and output functions. That is, the touch display screen 303 can also be used as part of the input unit 306 to achieve input functions.
[0275] In this embodiment, a processor 301 executes an application to generate a graphical interface on a touch display screen 303. The touch display screen 303 is used to present the graphical interface and receive user commands generated by the graphical interface.
[0276] The radio frequency circuit 304 can be used to transmit and receive radio frequency signals to establish wireless communication with network devices or other computer devices, and to transmit and receive signals with network devices or other computer devices.
[0277] Audio circuitry 305 can be used to provide an audio interface between a user and a computer device via a speaker and a microphone. Audio circuitry 305 converts received audio data into electrical signals, transmits them to the speaker, and the speaker converts them into sound signals for output. Conversely, the microphone converts collected sound signals into electrical signals, which are then received by audio circuitry 305, converted back into audio data, and output to processor 301 for processing. The audio data is then transmitted via radio frequency circuitry 304 to, for example, another computer device, or output to memory 302 for further processing. Audio circuitry 305 may also include an earphone jack to facilitate communication between peripheral headphones and the computer device.
[0278] The input unit 306 can be used to receive input numbers, characters, or user characteristic information (such as fingerprints, iris, facial information, etc.), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.
[0279] Power supply 307 is used to supply power to various components of computer device 300. Optionally, power supply 307 can be logically connected to processor 301 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. Power supply 307 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0280] although Figure 12 As not shown in the diagram, computer equipment 300 may also include a camera, sensor, wireless fidelity module, Bluetooth module, etc., which will not be described in detail here.
[0281] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0282] As can be seen from the above, the computer device provided in this embodiment, when detecting an interaction event between a target virtual object and a preset virtual character cluster, determines the response behavior type corresponding to the interaction event, and obtains the position information of the target virtual object and the position information of each virtual character in the virtual character cluster, wherein each virtual character in the virtual character cluster is set with corresponding motion attribute parameters; then, based on the position information of the target virtual object and the position information of each virtual character in the virtual character cluster, a distance difference is determined; next, based on the distance difference of each virtual character and the preset adjustment parameters corresponding to the response behavior type, a target adjustment parameter for each virtual character is determined; finally, based on the response behavior type and the target adjustment parameters of each virtual character, the motion attribute parameters of each virtual character in the virtual character cluster are adjusted to control each virtual character in the virtual character cluster to perform the character behavior corresponding to the response behavior type. This application embodiment adjusts the game behavior of each virtual character in the virtual character cluster according to the actual interaction scenario, enriches the interaction methods between each virtual character in the virtual character cluster and the virtual objects controlled by the game player, improves the interactivity of the game, enhances the replay value of the game, and increases the player's stickiness to the game.
[0283] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0284] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of computer programs that can be loaded by a processor to execute steps in any of the virtual character cluster processing methods provided in embodiments of this application. For example, the computer program can execute the following steps:
[0285] When an interaction event is detected between a target virtual object and a preset virtual character cluster, the response behavior type corresponding to the interaction event is determined, and the position information of the target virtual object and the position information of each virtual character in the virtual character cluster are obtained. Each virtual character in the virtual character cluster is set with corresponding motion attribute parameters.
[0286] The distance difference is determined based on the location information of the target virtual object and the location information of each virtual character in the virtual character cluster;
[0287] Based on the distance difference between each virtual character and the preset adjustment parameters corresponding to the response behavior type, the target adjustment parameters for each virtual character are determined.
[0288] Based on the response behavior type and the target adjustment parameters of each virtual character, the motion attribute parameters of each virtual character in the virtual character cluster are adjusted to control each virtual character in the virtual character cluster to perform the role behavior corresponding to the response behavior type.
[0289] In one embodiment, determining the target adjustment parameters for each virtual character based on the distance difference between each virtual character and the preset adjustment parameters corresponding to the response behavior type includes:
[0290] The target weight is determined based on the distance difference between the virtual characters and the preset rules corresponding to the response behavior types;
[0291] The target adjustment parameters of the virtual character are determined based on the preset adjustment parameters corresponding to the target weight and the response behavior type.
[0292] In one embodiment, adjusting the motion attribute parameters of each virtual character in the virtual character cluster according to the response behavior type and the target adjustment parameters of each virtual character, so as to control each virtual character in the virtual character cluster to perform the role behavior corresponding to the response behavior type, includes:
[0293] Based on the response behavior type and the display position of the target virtual object, the target movement direction of the virtual character is determined;
[0294] The motion attribute parameters of the virtual character are adjusted based on the target motion direction and the target adjustment parameters to control the virtual character to move towards the target motion direction according to the adjusted motion attribute parameters.
[0295] In one embodiment, the response behavior type is an attraction behavior type;
[0296] The step of determining the target weight based on the distance difference of the virtual character and the preset rules corresponding to the response behavior type includes:
[0297] The first target weight is determined based on the distance difference between the virtual characters, the preset weight value, and the first preset rule;
[0298] The target adjustment parameters of the virtual character are determined based on the preset adjustment parameters corresponding to the first target weight and the attraction behavior type.
[0299] In one embodiment, the response behavior type is an escape behavior type;
[0300] The step of determining the target weight based on the distance difference of the virtual character and the preset rules corresponding to the response behavior type includes:
[0301] Obtain a first preset judgment range of the target virtual object, and determine the range radius of the preset judgment range;
[0302] The second target weight is determined based on the distance difference between the virtual characters, the radius of the range, and the second preset rule;
[0303] The target adjustment parameters of the virtual character are determined based on the second target weight and the preset adjustment parameters corresponding to the escape behavior type.
[0304] In one embodiment, after determining the second target weight based on the distance difference of the virtual character, the range radius, and the second preset rule, the method further includes:
[0305] Obtain the second preset judgment range of the virtual character;
[0306] Obtain the second target weights of other virtual characters located within the second preset judgment range;
[0307] The third target weight is determined based on the second target weight of the virtual character, the second target weights of all other virtual characters, and the third preset rule;
[0308] The target adjustment parameters of the virtual character are determined based on the preset adjustment parameters corresponding to the third target weight and the escape behavior type.
[0309] In one embodiment, the method further includes:
[0310] In response to a role transfer event for the virtual character cluster, a target virtual character cluster is identified, and a target virtual character is determined from the virtual character cluster based on a preset selection rule;
[0311] The character information of the target virtual character is removed from the cluster information of the virtual character cluster, and the character information of the target virtual character is added to the cluster information of the target virtual character cluster, so as to control the target virtual character to move to the target virtual character cluster.
[0312] In one embodiment, the method further includes:
[0313] Obtain the virtual bounding box of the virtual character cluster, wherein the bounding box information corresponding to the virtual bounding box includes position information, bounding box size information and bounding box shape information;
[0314] The virtual cluster range is determined based on the bounding box information;
[0315] When it is detected that the display position of a target virtual character in the virtual character cluster exceeds the range of the virtual cluster, motion adjustment information is determined based on the display position of the target virtual character and the bounding box information;
[0316] Based on the motion adjustment information, the motion attribute parameters of the target virtual character are adjusted to control the target virtual character to move towards the virtual bounding box.
[0317] In one embodiment, after obtaining the virtual bounding box of the virtual character cluster, the method further includes:
[0318] In response to the size adjustment command for the virtual character cluster, the bounding box size information of the virtual bounding box is adjusted based on the size adjustment parameters of the size adjustment command to obtain the adjusted virtual bounding box.
[0319] In one embodiment, after obtaining the virtual bounding box of the virtual character cluster, the method further includes:
[0320] In response to the shape adjustment command for the virtual character cluster, the bounding box shape information of the virtual bounding box is adjusted based on the shape adjustment parameters of the shape adjustment command to obtain the adjusted virtual bounding box.
[0321] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0322] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0323] Since the computer program stored in the storage medium can execute the steps of any of the virtual character cluster processing methods provided in the embodiments of this application, when an interaction event is detected between a target virtual object and a preset virtual character cluster, the response behavior type corresponding to the interaction event is determined, and the position information of the target virtual object and the position information of each virtual character in the virtual character cluster are obtained, wherein each virtual character in the virtual character cluster is set with corresponding motion attribute parameters; then, a distance difference is determined based on the position information of the target virtual object and the position information of each virtual character in the virtual character cluster; next, a target adjustment parameter for each virtual character is determined according to the distance difference of each virtual character and the preset adjustment parameter corresponding to the response behavior type; finally, the motion attribute parameters of each virtual character in the virtual character cluster are adjusted according to the response behavior type and the target adjustment parameters of each virtual character, so as to control each virtual character in the virtual character cluster to perform the role behavior corresponding to the response behavior type. This application embodiment adjusts the game behavior of each virtual character in the virtual character cluster according to the actual interaction scenario, enriches the interaction methods between each virtual character in the virtual character cluster and the virtual objects controlled by the game player, improves the interactivity of the game, enhances the replay value of the game, and increases the player's stickiness to the game.
[0324] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0325] The foregoing has provided a detailed description of a method, apparatus, computer device, and storage medium for processing virtual character clusters according to embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the technical solutions and core ideas of this application. Those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method for processing virtual character clusters, characterized in that, include: When an interaction event is detected between a target virtual object and a preset virtual character cluster, the response behavior type corresponding to the interaction event is determined, and the position information of the target virtual object and the position information of each virtual character in the virtual character cluster are obtained. Each virtual character in the virtual character cluster is set with corresponding motion attribute parameters. The distance difference is determined based on the location information of the target virtual object and the location information of each virtual character in the virtual character cluster; Based on the distance difference between each virtual character and the preset adjustment parameters corresponding to the response behavior type, the target adjustment parameters for each virtual character are determined. Based on the response behavior type and the target adjustment parameters of each virtual character, the motion attribute parameters of each virtual character in the virtual character cluster are adjusted to control each virtual character in the virtual character cluster to perform the role behavior corresponding to the response behavior type.
2. The method for processing virtual character clusters according to claim 1, characterized in that, The step of determining the target adjustment parameters for each virtual character based on the distance difference between each virtual character and the preset adjustment parameters corresponding to the response behavior type includes: The target weight is determined based on the distance difference between the virtual characters and the preset rules corresponding to the response behavior types; The target adjustment parameters of the virtual character are determined based on the preset adjustment parameters corresponding to the target weight and the response behavior type.
3. The method for processing virtual character clusters according to claim 2, characterized in that, The step of adjusting the motion attribute parameters of each virtual character in the virtual character cluster according to the response behavior type and the target adjustment parameters of each virtual character, so as to control each virtual character in the virtual character cluster to execute the role behavior corresponding to the response behavior type, includes: Based on the response behavior type and the display position of the target virtual object, the target movement direction of the virtual character is determined; The motion attribute parameters of the virtual character are adjusted based on the target motion direction and the target adjustment parameters to control the virtual character to move towards the target motion direction according to the adjusted motion attribute parameters.
4. The method for processing virtual character clusters according to claim 3, characterized in that, The response behavior type is an attraction behavior type; The step of determining the target weight based on the distance difference of the virtual character and the preset rules corresponding to the response behavior type includes: The first target weight is determined based on the distance difference between the virtual characters, the preset weight value, and the first preset rule; The target adjustment parameters of the virtual character are determined based on the preset adjustment parameters corresponding to the first target weight and the attraction behavior type.
5. The method for processing virtual character clusters according to claim 3, characterized in that, The response behavior type is the escape behavior type; The step of determining the target weight based on the distance difference of the virtual character and the preset rules corresponding to the response behavior type includes: Obtain a first preset judgment range of the target virtual object, and determine the range radius of the preset judgment range; The second target weight is determined based on the distance difference between the virtual characters, the radius of the range, and the second preset rule; The target adjustment parameters of the virtual character are determined based on the second target weight and the preset adjustment parameters corresponding to the escape behavior type.
6. The method for processing virtual character clusters according to claim 5, characterized in that, After determining the second target weight based on the distance difference of the virtual character, the range radius, and the second preset rule, the method further includes: Obtain the second preset judgment range of the virtual character; Obtain the second target weights of other virtual characters located within the second preset judgment range; The third target weight is determined based on the second target weight of the virtual character, the second target weights of all other virtual characters, and the third preset rule; The target adjustment parameters of the virtual character are determined based on the preset adjustment parameters corresponding to the third target weight and the escape behavior type.
7. The method for processing virtual character clusters according to claim 1, characterized in that, The method further includes: In response to a role transfer event for the virtual character cluster, a target virtual character cluster is identified, and a target virtual character is determined from the virtual character cluster based on a preset selection rule; The character information of the target virtual character is removed from the cluster information of the virtual character cluster, and the character information of the target virtual character is added to the cluster information of the target virtual character cluster, so as to control the target virtual character to move to the target virtual character cluster.
8. The method for processing virtual character clusters according to claim 1, characterized in that, The method further includes: Obtain the virtual bounding box of the virtual character cluster, wherein the bounding box information corresponding to the virtual bounding box includes position information, bounding box size information and bounding box shape information; The virtual cluster range is determined based on the bounding box information; When it is detected that the display position of a target virtual character in the virtual character cluster exceeds the range of the virtual cluster, motion adjustment information is determined based on the display position of the target virtual character and the bounding box information; Based on the motion adjustment information, the motion attribute parameters of the target virtual character are adjusted to control the target virtual character to move towards the virtual bounding box.
9. The method for processing virtual character clusters according to claim 8, characterized in that, After obtaining the virtual bounding box of the virtual character cluster, the process also includes: In response to the size adjustment command for the virtual character cluster, the bounding box size information of the virtual bounding box is adjusted based on the size adjustment parameters of the size adjustment command to obtain the adjusted virtual bounding box.
10. The method for processing virtual character clusters according to claim 8, characterized in that, After obtaining the virtual bounding box of the virtual character cluster, the process also includes: In response to the shape adjustment command for the virtual character cluster, the bounding box shape information of the virtual bounding box is adjusted based on the shape adjustment parameters of the shape adjustment command to obtain the adjusted virtual bounding box.
11. A processing device for a cluster of virtual characters, characterized in that, include: The first determining unit is used to determine the response behavior type corresponding to the interaction event when an interaction event is detected between the target virtual object and the preset virtual character cluster, and to obtain the position information of the target virtual object and the position information of each virtual character in the virtual character cluster, wherein each virtual character in the virtual character cluster is set with corresponding motion attribute parameters. The second determining unit is used to determine the distance difference based on the location information of the target virtual object and the location information of each virtual character in the virtual character cluster; The third determining unit is used to determine the target adjustment parameters of each virtual character based on the distance difference between each virtual character and the preset adjustment parameters corresponding to the response behavior type. The adjustment unit is used to adjust the motion attribute parameters of each virtual character in the virtual character cluster according to the response behavior type and the target adjustment parameters of each virtual character, so as to control each virtual character in the virtual character cluster to perform the role behavior corresponding to the response behavior type.
12. A computer device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the processing method for a virtual character cluster as described in any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the processing method for a virtual character cluster as described in any one of claims 1 to 10.