CN-122019115-A - Bullet behavior scheduling method and device, equipment and medium thereof
Abstract
The application relates to a bullet behavior scheduling method, a device, equipment and a medium thereof. The method comprises the steps of obtaining behavior configuration information of bullets, obtaining bullet entity examples from a multiplexing resource pool according to the behavior configuration information, constructing bullet entities, establishing a behavior scheduling queue for the bullet entities, adding each behavior module into the behavior scheduling queue according to a preset sequence, executing each behavior module in the behavior scheduling queue, determining the behavior module needing to be continuously executed every frame so as to move into a continuous behavior list for frame traversal after being executed once, calling an asynchronous parallel collision detection system to execute collision detection, executing the behavior module hitting collision according to a collision result, continuing executing the subsequent behavior modules until the subsequent behavior modules are destroyed, and recovering the bullet entity examples to the multiplexing resource pool when the bullet entity examples are destroyed. The application solves the bottleneck problems of bullet behavior logic coupling and collision detection performance, and realizes modularized scheduling and asynchronous parallel collision detection, thereby improving development efficiency, running performance and expandability.
Inventors
- HUANG XINYAO
- Chen Fengte
Assignees
- 广州库洛数界科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260416
Claims (10)
- 1. The bullet behavior scheduling method is characterized by comprising the following steps: Acquiring behavior configuration information of a bullet, wherein the behavior configuration information comprises at least one behavior module, and each behavior module corresponds to an independent behavior stage in the life cycle of the bullet; obtaining a bullet entity instance from a multiplexing resource pool according to the behavior configuration information, constructing a bullet entity, establishing a behavior scheduling queue for the bullet entity, and adding the behavior modules into the behavior scheduling queue according to a preset sequence; Executing each behavior module in the behavior scheduling queue, determining the behavior module needing to be continuously executed for each frame, moving the behavior module into a continuous behavior list for frame traversal after the behavior module is executed once, and further driving the state update of the bullet entity; When the behavior module of collision detection is executed, an asynchronous parallel collision detection system is called to execute the collision detection, a collision snapshot is collected from a game thread, so that wide-stage screening and narrow-stage accurate detection are sequentially carried out in an asynchronous thread pool, and a collision result is written back to the game thread; And executing a behavior module hitting the collision according to the collision result, continuously executing a subsequent behavior module until the collision is destroyed, and recovering the bullet entity instance to the multiplexing resource pool when the collision is destroyed.
- 2. The method of claim 1, wherein the step of obtaining behavior configuration information for the bullet comprises: Setting a derivative bullet generation rule in the behavior configuration information, wherein the derivative bullet generation rule comprises generation conditions, derivative bullet configuration identifiers, generation quantity, delay time and generation interval, and the generation conditions are at least one of generation immediately when a bullet is created, generation when the bullet life cycle is ended or generation when the bullet hits; when executing the behavior module of the derivative bullet generation, creating a bullet entity of the derivative bullet when the generation condition is met according to the derivative bullet generation rule.
- 3. The method of claim 1, wherein executing each behavior module in the behavior scheduling queue, determining a behavior module to be continuously executed per frame, to move into a continuous behavior list for frame traversal after one execution, and further driving the state update of the bullet entity, comprises: for a behavior module needing to be continuously executed every frame, moving the behavior module into a continuous behavior list after being executed once; Traversing the continuous behavior list in a frame updating stage of each frame period, and executing frame updating logic of each behavior module; and traversing the continuous behavior list in a frame post-processing stage of each frame period, and executing frame post-processing logic of each behavior module.
- 4. The method of claim 1, wherein the step of invoking the asynchronous parallel collision detection system to perform collision detection comprises: In the game thread of the current frame, distributing a collision snapshot for each object participating in collision, wherein the collision snapshot comprises a static attribute and a dynamic attribute, the static attribute comprises a shape type, a collision channel and a collision willingness mask and is cached, and the dynamic attribute comprises a current position and a last frame position and is updated frame by frame so as to generate the collision snapshot; In the asynchronous thread pool, performing wide-stage screening based on the collision snapshot to generate candidate collision pairs; in the asynchronous thread pool, performing narrow-stage accurate detection on the candidate collision pair, and determining a collision result; and writing the collision result back to the game thread and notifying the corresponding bullet entity.
- 5. The method of claim 4, wherein prior to the step of generating candidate collision pairs in the asynchronous thread pool by performing a wide-phase screening based on the collision snapshot, further comprising: Acquiring respective collision willingness masks and collision channels of a first object to be detected and a second object to be detected for collision filtering detection; When the result of the bit pressing and operation of the collision willingness mask of the first object to be detected and the bit identifier corresponding to the collision channel of the second object to be detected is not zero, and the result of the bit pressing and operation of the collision willingness mask of the second object to be detected and the bit identifier corresponding to the collision channel of the first object to be detected is also not zero, the object to be detected is judged to pass through collision filtering detection, and the subsequent collision detection is allowed to enter.
- 6. The method of claim 4, wherein the step of performing wide-phase screening by the asynchronous parallel collision detection system comprises: Sampling the external radius of an object involved in collision, and calculating the statistical quantile of the external radius as a typical radius; setting the side length of the grid to be a preset multiple of the typical radius, thereby dividing the space into grids; generating an index relation between the grid and the object in a multi-pass grid building mode; and for the objects in each grid, adaptively selecting a corresponding candidate pair generation algorithm according to the number of the objects in the grid.
- 7. The method of claim 4, wherein the step of performing narrow-phase accurate detection by the asynchronous parallel collision detection system comprises: Invoking corresponding analysis geometric judgment mode to calculate whether to intersect according to the shape combination of the two collision bodies, wherein the shape combination comprises at least one of a sphere and a sphere, a sphere and a box body, a sphere and a capsule body, a box body and a box body, a box body and a capsule body; For the object with continuous collision detection, selecting an analytical solution or discrete sampling detection mode to execute the inter-frame continuous collision detection according to whether the collision shape combination has an analytical motion track solution.
- 8. A bullet behavior scheduling device, comprising: The bullet screen configuration acquisition module is used for acquiring behavior configuration information of the bullet, wherein the behavior configuration information comprises at least one behavior module, and each behavior module corresponds to an independent behavior stage in the bullet life cycle; The bullet entity construction module is used for acquiring bullet entity examples from the multiplexing resource pool according to the behavior configuration information, constructing bullet entities, establishing a behavior scheduling queue for the bullet entities, and adding the behavior modules into the behavior scheduling queue according to a preset sequence; The bullet behavior scheduling module is used for executing each behavior module in the behavior scheduling queue, determining the behavior module which needs to be continuously executed every frame, moving the behavior module into a continuous behavior list for frame traversal after the behavior module is executed once, and further driving the state update of the bullet entity; The asynchronous collision detection module is used for calling the asynchronous parallel collision detection system to execute collision detection when the behavior module of collision detection is executed, collecting collision snapshots from the game threads, sequentially carrying out wide-stage screening and narrow-stage accurate detection in the asynchronous thread pool, and writing collision results back to the game threads; The bullet hit collision module is used for executing the hit collision behavior module according to the collision result, continuously executing the subsequent behavior module until the bullet is destroyed, and recovering the bullet entity instance to the multiplexing resource pool during the destruction.
- 9. A bullet behavior scheduling apparatus comprising a central processor and a memory, characterized in that the central processor is adapted to invoke execution of a computer program stored in the memory to perform the steps of the method according to any of claims 1 to 7.
- 10. A non-transitory readable storage medium, characterized in that it stores in form of computer readable instructions a computer program implemented according to the method of any one of claims 1 to 7, which when invoked by a computer, performs the steps comprised by the corresponding method.
Description
Bullet behavior scheduling method and device, equipment and medium thereof Technical Field The application relates to the technical field of game interaction, in particular to a bullet behavior scheduling method and device, equipment and medium thereof. Background In the field of game development, the run-time behavior (including movement trajectories, collision detection, hit response, etc.) of bullets in a bullet screen system directly affects the fluency and playability of a battle. At present, the main stream scheme adopts a traditional hard coding mode, and logic such as bullet initialization, movement, collision, hit, destruction and the like is directly solidified in a program code. Under the scheme, a programmer is required to write a large number of repeated codes for each newly added bullet behavior (such as tracking, rebound and splitting), and bullet logic is scattered among the modules, so that the code coupling degree is high and the maintainability is poor. Meanwhile, the planner cannot independently adjust bullet behavior parameters or combine new behaviors, each modification depends on programmer intervention to reconstruct, compile and test codes, the iteration period is long, and the trial-and-error cost is high. In addition, the existing scheme relies on a general physical system of a game engine to perform collision detection, and an independent physical component is created for each bullet, so that the memory expense is high, the CPU load is high, and the frame rate is seriously reduced when a large number of bullets are on screen. Collision callbacks of a physical engine are generated in asynchronous threads, the time sequence is uncontrollable, hit judgment is often delayed or the sequence is disordered, and accurate frame synchronization logic is difficult to realize. Meanwhile, bullet entities and special effect resources are frequently created and destroyed, and multiplexing mechanisms such as an object pool and the like are lacked, so that memory fragments and garbage are recovered and blocked, and a large-scale bullet screen scene cannot be supported. The logics such as bullet initialization, movement, collision and destruction are mixed together, collision detection is tightly coupled with other behaviors, independent optimization or replacement cannot be realized, and expansibility is poor. In summary, the existing bullet behavior scheduling schemes have the problems of behavior logic coupling, poor expansibility, disordered resource management, bottleneck in collision detection performance, uncontrollable time sequence and the like, and are difficult to meet the requirements of smoothness, accuracy and expandability in large-scale bullet screen scenes. Disclosure of Invention The present application aims to solve the above problems and provide a bullet behavior scheduling method and corresponding apparatus, device, non-volatile readable storage medium, and computer program product. According to one aspect of the present application, there is provided a bullet behavior scheduling method, including: Acquiring behavior configuration information of a bullet, wherein the behavior configuration information comprises at least one behavior module, and each behavior module corresponds to an independent behavior stage in the life cycle of the bullet; obtaining a bullet entity instance from a multiplexing resource pool according to the behavior configuration information, constructing a bullet entity, establishing a behavior scheduling queue for the bullet entity, and adding the behavior modules into the behavior scheduling queue according to a preset sequence; Executing each behavior module in the behavior scheduling queue, determining the behavior module needing to be continuously executed for each frame, moving the behavior module into a continuous behavior list for frame traversal after the behavior module is executed once, and further driving the state update of the bullet entity; When the behavior module of collision detection is executed, an asynchronous parallel collision detection system is called to execute the collision detection, a collision snapshot is collected from a game thread, so that wide-stage screening and narrow-stage accurate detection are sequentially carried out in an asynchronous thread pool, and a collision result is written back to the game thread; And executing a behavior module hitting the collision according to the collision result, continuously executing a subsequent behavior module until the collision is destroyed, and recovering the bullet entity instance to the multiplexing resource pool when the collision is destroyed. According to another aspect of the present application, there is provided a bullet behavior scheduling apparatus including: The bullet screen configuration acquisition module is used for acquiring behavior configuration information of the bullet, wherein the behavior configuration information comprises at least one behavior module, and e