Laser special effects control method, device, storage medium and computer equipment
By performing overlap detection and acquisition of ray intersection points on the capsules of laser virtual objects, the effect of laser virtual objects being blocked by obstacles is achieved, solving the problem that the prior art cannot achieve this effect, and improving detection efficiency.
Patent Information
- Application Number
- CN202111646043.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2041-12-29
AI Technical Summary
The prior art cannot realize the effect of laser virtual objects blocking by obstacles, and can only play virtual special effects at the emission point.
By obtaining the virtual effects of the laser-like virtual object at the emission point, overlaid detection of its capsule body, the first target collision body in the virtual scene is determined, and the intersection point is obtained from the emission point emitted rays along the emission direction of the laser-like virtual object. Based on the distance between the intersection point and the launch point, the virtual effects are scaled and the collision effects are played at the intersection point.
The effect of laser virtual objects being blocked is achieved, reducing the overhead of ray detection and improving the efficiency of ray detection.
Smart Images

Figure CN114272604B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a control method, device, storage medium and computer equipment for laser special effects. Background Art
[0002] In a game scene, when a laser virtual object is launched, a corresponding virtual special effect is usually played at the launch point. However, this method can only achieve the launch effect of the laser virtual object. When the laser virtual object is blocked by an obstacle in the same game scene, this method of the prior art cannot achieve the effect of the laser virtual object being blocked. Summary of the invention
[0003] The present invention provides a control method, device, storage medium and computer equipment for laser special effects, which are mainly capable of effectively controlling virtual special effects of laser virtual objects, thereby achieving the effect of blocking the laser virtual objects.
[0004] According to a first aspect of the present invention, there is provided a method for controlling laser special effects, comprising:
[0005] Obtain the virtual special effects corresponding to the laser virtual object played at the emission point;
[0006] Performing overlapping detection on the capsule corresponding to the laser virtual object to determine a first target collision body in the virtual scene that blocks the virtual special effect;
[0007] Emitting a ray intersecting the first target collision body from the emission point along the emission direction of the laser virtual object, and obtaining an intersection point between the ray and the first target collision body;
[0008] Based on the distance between the intersection point and the emission point, the virtual special effect is scaled, and the collision special effect corresponding to the laser virtual object is played at the intersection point.
[0009] Optionally, performing overlap detection on the capsule corresponding to the laser virtual object to determine a first target collision body in the virtual scene that blocks the virtual special effect includes:
[0010] Determine at least one collision body in the same virtual scene as the laser virtual object;
[0011] Performing overlap detection on the at least one collision body and the capsule body respectively, and determining at least one second target collision body that blocks the virtual special effect at a physical level from the at least one collision body according to the overlap detection result;
[0012] A first target collision body among the at least one second target collision body that blocks the virtual special effect at a logical level is determined according to the distances between the at least one second target collision body and the capsule body.
[0013] Optionally, performing overlap detection on the at least one collision body and the capsule body respectively, and determining, according to the overlap detection result, a second target collision body from the at least one collision body that blocks the virtual special effect at a physical level, comprises:
[0014] Determining, according to level information corresponding to any one of the at least one collision body, whether the any one collision body belongs to a target level;
[0015] If any one of the collision bodies belongs to the target level, performing overlap detection on the any one of the collision bodies and the capsule body;
[0016] If any one of the collision bodies overlaps with the capsule body, the any one of the collision bodies is determined as the second target collision body.
[0017] Optionally, before respectively performing overlap detection on the at least one collision body and the capsule body, and determining, according to the overlap detection result, from the at least one collision body, a second target collision body that blocks the virtual special effect at a physical level, the method further includes:
[0018] Adjusting the radius corresponding to the virtual special effect according to a preset proportional coefficient to obtain an adjusted radius;
[0019] Based on the length corresponding to the virtual special effect and the adjusted radius, a capsule body corresponding to the laser virtual object is generated.
[0020] Optionally, determining, according to the distances between the at least one second target collision body and the capsule body, a first target collision body among the at least one second target collision body that blocks the virtual special effect at a logical level comprises:
[0021] According to the distances between the at least one second target collision body and the capsule body, the at least one second target collision body is sorted from near to far to obtain a sorting result;
[0022] According to the sorting result, determining in sequence whether the at least one second target collision body can block the virtual special effect at a logical level;
[0023] When the first second target collision body that can block the virtual special effect at the logical level is determined, the determination process is stopped, and the first second target collision body that can block the virtual special effect at the logical level is determined as the first target collision body.
[0024] Optionally, the step of sequentially determining whether the at least one second target collision body can block the virtual special effect at a logical level includes:
[0025] According to the attribute information corresponding to any one of the at least one second target collision body and the attribute information corresponding to the laser virtual object, it is determined whether the any one of the second target collision bodies can block the virtual special effect at a logical level.
[0026] Optionally, determining whether any one of the at least one second target collision body can block the virtual special effect at a logical level according to the attribute information corresponding to the any one of the at least one second target collision body and the attribute information corresponding to the laser virtual object includes:
[0027] Determine whether any one of the second target collision bodies can block the virtual special effect at a logical level according to the organizational information of the character to which the any one of the second target collision bodies belongs and the organizational information of the character that emits the laser virtual object;
[0028] If the organizational information of the character to which any one of the second target collision bodies belongs is different from the organizational information of the character that emits the laser-type virtual object, it is determined that the any one of the second target collision bodies can block the virtual special effect at a logical level.
[0029] Optionally, scaling the virtual special effect based on the distance between the intersection point and the emission point includes:
[0030] Calculating a scaling factor corresponding to the virtual special effect according to a distance between the intersection point and the emission point and a length corresponding to the virtual special effect;
[0031] Based on the scaling factor, the virtual special effect is scaled along the emission direction of the laser-like virtual object.
[0032] Optionally, the method further comprises:
[0033] When the position information of the intersection point changes, determining a changed distance between the changed intersection point and the emission point;
[0034] Based on the changed distance and the length corresponding to the virtual special effect, updating a scaling factor corresponding to the virtual special effect;
[0035] Based on the updated scaling factor, the virtual special effect is scaled along the emission direction of the laser virtual object, and the collision special effect corresponding to the virtual object is played at the changed intersection.
[0036] According to a second aspect of the present invention, there is provided a control device for laser special effects, comprising:
[0037] An acquisition unit, used for acquiring a virtual special effect corresponding to a laser virtual object played at a launch point;
[0038] A detection unit, configured to perform overlapping detection on the capsule corresponding to the laser virtual object, and determine a first target collision body in the virtual scene that blocks the virtual special effect;
[0039] A transmitting unit, configured to transmit a ray intersecting with the first target collision body from the transmitting point along the transmitting direction of the laser virtual object, and obtain an intersection point between the ray and the first target collision body;
[0040] A scaling unit is used to scale the virtual special effect based on the distance between the intersection point and the emission point, and to play the collision special effect corresponding to the laser virtual object at the intersection point.
[0041] Optionally, the detection unit includes: a first determination module and a detection module,
[0042] The first determination module is used to determine at least one collision body in the same virtual scene as the laser virtual object;
[0043] The detection module is used to perform overlap detection on the at least one collision body and the capsule body respectively, and determine at least one second target collision body that blocks the virtual special effect at a physical level from the at least one collision body according to the overlap detection result;
[0044] The first determination module is further configured to determine a first target collision body among the at least one second target collision body that blocks the virtual special effect at a logical level according to the distances between the at least one second target collision body and the capsule body.
[0045] Optionally, the detection module includes: a first determination submodule, a detection submodule and a first determination submodule.
[0046] The first determination submodule is configured to determine whether any one of the at least one collision body belongs to a target level according to level information corresponding to the any one collision body.
[0047] The detection submodule is configured to perform overlap detection on the any collision body and the capsule body if the any collision body belongs to the target level;
[0048] The first determination submodule is configured to determine any one of the collision bodies as the second target collision body if the any one of the collision bodies overlaps with the capsule body.
[0049] Optionally, the detection unit further includes: an adjustment module and a generation module.
[0050] The adjustment module is used to adjust the radius corresponding to the virtual special effect according to a preset proportional coefficient to obtain an adjusted radius;
[0051] The generation module is used to generate a capsule body corresponding to the laser virtual object based on the length corresponding to the virtual special effect and the adjusted radius.
[0052] Optionally, the first determination module includes: a sorting submodule, a second judging submodule and a second determining submodule,
[0053] The sorting submodule is used to sort the at least one second target collision body from near to far according to the distance between the at least one second target collision body and the capsule body, so as to obtain a sorting result;
[0054] The second determination submodule is used to determine, in order according to the sorting result, whether the at least one second target collision body can block the virtual special effect at a logical level;
[0055] The second determination submodule is used to stop the determination process when determining the first second target collision body that can logically block the virtual special effect, and determine the first second target collision body that can logically block the virtual special effect as the first target collision body.
[0056] Optionally, the second determination submodule is specifically used to determine whether any one of the at least one second target collision body can block the virtual special effect at a logical level based on attribute information corresponding to the any one of the at least one second target collision body and attribute information corresponding to the laser virtual object.
[0057] Optionally, the second determination submodule is further specifically used to determine whether any one of the second target collision bodies can block the virtual special effect at a logical level based on the organizational information of the character to which the any one of the second target collision bodies belongs and the organizational information of the character that emits the laser-type virtual object; if the organizational information of the character to which the any one of the second target collision bodies belongs is different from the organizational information of the character that emits the laser-type virtual object, it is determined that any one of the second target collision bodies can block the virtual special effect at a logical level.
[0058] Optionally, the scaling unit includes: a calculation module and a scaling module.
[0059] The calculation module is used to calculate the scaling factor corresponding to the virtual special effect according to the distance between the intersection point and the emission point, and the length corresponding to the virtual special effect;
[0060] The scaling module is used to scale the virtual special effect along the emission direction of the laser virtual object based on the scaling factor.
[0061] Optionally, the scaling unit further includes: a second determining module and an updating module,
[0062] The second determining module is used to determine a changed distance between the changed intersection and the transmitting point when the position information of the intersection changes;
[0063] The updating module is used to update the scaling factor corresponding to the virtual special effect based on the changed distance and the length corresponding to the virtual special effect;
[0064] The scaling module is further used to scale the virtual special effects along the emission direction of the laser virtual object based on the updated scaling coefficient, and play the collision special effects corresponding to the virtual object at the changed intersection.
[0065] According to a third aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned control method for laser-type special effects.
[0066] According to a fourth aspect of the present invention, there is provided a computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned control method for laser special effects when executing the program.
[0067] The present invention provides a control method, device, storage medium and computer equipment for laser special effects. Compared with the current method of playing virtual special effects only at the emission point of a laser virtual object, the present invention can obtain the virtual special effects corresponding to the laser virtual object played at the emission point; and perform overlapping detection on the capsule body corresponding to the laser virtual object to determine the first target collision body that blocks the virtual special effects in the virtual scene; at the same time, a ray that intersects with the first target collision body is emitted from the emission point along the emission direction of the laser virtual object, and the intersection point of the ray and the first target collision body is obtained; finally, based on the distance between the intersection point and the emission point, the virtual special effect is scaled, and the collision special effect corresponding to the laser virtual object is played at the intersection point. Therefore, by performing overlapping detection on the capsule body of the laser virtual object and screening out the first target collision body that will block the virtual special effects at the logical level, ray detection is performed to obtain the intersection point. The corresponding collision special effects can be played at the intersection point, and the virtual special effects of the laser virtual object can be scaled, thereby achieving the effect of blocking the laser virtual object. At the same time, since only one ray detection is used in the process of obtaining the intersection point, the detection overhead can be reduced and the ray detection efficiency can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0069] Figure 1 A schematic flow chart of a method for controlling laser special effects provided by an embodiment of the present invention is shown;
[0070] Figure 2 A schematic flow chart of another method for controlling laser special effects provided by an embodiment of the present invention is shown;
[0071] Figure 3 A schematic diagram of the structure of a control device for laser special effects provided by an embodiment of the present invention is shown;
[0072] Figure 4 A schematic diagram showing the structure of another laser special effect control device provided by an embodiment of the present invention;
[0073] Figure 5 A schematic diagram of the physical structure of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0074] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0075] At present, only the emission effect of laser virtual objects can be achieved. When the laser virtual objects are blocked by obstacles in the same game scene, the existing technology cannot achieve the effect of the laser virtual objects being blocked.
[0076] In order to solve the above problems, an embodiment of the present invention provides a control method for laser special effects, such as Figure 1 As shown, the method includes:
[0077] 101. Obtain a virtual special effect corresponding to the laser virtual object played at the emission point.
[0078] Among them, laser virtual objects include not only lasers in game scenes, but also all virtual objects with similar characteristics to lasers. Virtual special effects are pre-made by artists, and the style of the virtual special effects is required not to be affected by scaling.
[0079] The embodiment of the present invention is mainly used to control laser special effects to achieve a scene of laser virtual object blocking effect. The execution subject of the embodiment of the present invention is a device or equipment capable of controlling laser special effects, which can be a server or a client.
[0080] For an embodiment of the present invention, when a command to generate a laser virtual object is received, a virtual special effect corresponding to the laser virtual object is obtained, and the virtual special effect is played at the emission point of the laser virtual object, thereby achieving the emission effect of the laser virtual object.
[0081] 102. Perform overlapping detection on the capsule corresponding to the laser virtual object to determine a first target collision body that blocks the virtual special effect in the virtual scene.
[0082] The first target collision body can be a sphere, a capsule, a cuboid, a convex hull grid, etc., and there is only one first target collision body that is finally determined. For the embodiment of the present invention, when the virtual special effect is played, the collision body in the same virtual scene as the laser virtual object may block the virtual special effect. In order to achieve the effect that the laser virtual object is blocked, it is necessary to first screen out the second target collision body that blocks the virtual special effect from the physical level through overlapping detection, and then screen out the first target collision body that blocks the virtual special effect from the logical level in the second target collision body, so as to perform ray detection on the first target collision body.
[0083] Since directly using a large number of rays to detect obstacles that can block virtual special effects will increase detection overhead and reduce detection efficiency, in order to overcome the above-mentioned defects, in the embodiment of the present invention, an overlapping detection method is used to determine the second target collision body that blocks the virtual special effects at the physical level. Specifically, Unity's physics engine Physx can be used for overlapping detection. Since laser virtual objects are mostly straight lines and cylinders of uniform thickness, they can be approximately regarded as capsules. By calling the Physics.OverlapCapsuleNonAlloc interface, the overlapping detection of the capsule corresponding to the laser virtual object and the collision body in the same virtual scene is realized. The collision body can be regarded as a sphere, capsule, cuboid, convex hull mesh, etc. according to the actual shape characteristics. Through this overlapping detection, the second target collision body that blocks the virtual special effects can be screened out from the physical level. It should be noted that Unity's physics engine Physx can support the cache function. Before the physical world in the virtual scene is updated, the detection between the capsule and the same collision body will only be calculated once, and the subsequent calculations will return the previous calculation results.
[0084] Furthermore, the first target collision body that blocks the virtual special effect is determined from the second target collision body at the logical level, so as to perform ray detection on the first target collision body and obtain the intersection point. The specific determination process of the second target collision body and the first target collision body is detailed in steps 202 and 203.
[0085] 103. Launch a ray from the launch point along the launch direction of the laser virtual object to intersect the first target collision body, and obtain an intersection point between the ray and the first target collision body.
[0086] In order to reduce the overhead of ray detection, the embodiment of the present invention only emits one ray to the first target collision body during the ray detection process. Specifically, from the center position of the virtual special effect, only one ray intersecting the first target collision body is emitted along the emission direction of the laser-type virtual object. When the emitted ray intersects with the surface of the first target collision body, the physical engine Physx returns the position information of the intersection. Through the position information of the intersection, the virtual special effect can be scaled and the corresponding collision effect can be played at the same time.
[0087] 104. Based on the distance between the intersection point and the emission point, scale the virtual special effect, and play the collision special effect corresponding to the laser virtual object at the intersection point.
[0088] The collision special effect is a special effect when a capsule body pre-made by an artist collides with a collision body. For the embodiment of the present invention, in order to control the laser special effect to achieve the effect of the laser virtual object being blocked, step 104 specifically includes: calculating the scaling factor corresponding to the virtual special effect according to the distance between the intersection point and the emission point, and the length corresponding to the virtual special effect; based on the scaling factor, scaling the virtual special effect along the emission direction of the laser virtual object.
[0089] Specifically, when the ray intersects with the surface of the first target collision body, the physics engine Physx will return the position information of the intersection point, and determine the distance between the intersection point and the emission point based on the position information of the intersection point and the position information of the emission point. Then, the distance between the intersection point and the emission point is divided by the original length corresponding to the virtual special effect to obtain the scaling factor corresponding to the virtual special effect. Then, according to the scaling factor, the virtual special effect is scaled along the emission direction of the laser virtual object. For example, the scaling factor is 1:2, the original length corresponding to the virtual special effect is 100 meters, and the length corresponding to the virtual special effect after scaling is 50 meters. At the same time, according to the position information corresponding to the intersection point, the collision effect corresponding to the laser virtual object is played at the intersection point. Thus, by scaling the virtual special effect and playing the corresponding collision effect at the intersection point, the effect of the laser virtual object being blocked by the collision body can be achieved.
[0090] In a specific application scenario, after the virtual special effects of the laser virtual object are played and before they are destroyed, it is necessary to perform blocking detection on the capsule body corresponding to the laser virtual object at a certain frequency. Specifically, it can be detected whether the position information of the intersection of the ray and the collision body in each frame image changes. If the position information of the intersection continues to change, the scaling process of the virtual special effect is also ongoing. Based on this, the method includes: when the position information of the intersection changes, determining the changed distance between the changed intersection and the emission point; based on the changed distance and the length corresponding to the virtual special effect, updating the scaling factor corresponding to the virtual special effect; based on the updated scaling factor, scaling the virtual special effect along the emission direction of the laser virtual object, and playing the collision special effect corresponding to the virtual object at the changed intersection.
[0091] A control method for laser special effects provided by an embodiment of the present invention can obtain the virtual special effects corresponding to the laser virtual object played at the emission point compared with the current method of playing virtual special effects only at the emission point of the laser virtual object; and perform overlapping detection on the capsule corresponding to the laser virtual object to determine the first target collision body that blocks the virtual special effects in the virtual scene; at the same time, a ray that intersects with the first target collision body is emitted from the emission point along the emission direction of the laser virtual object, and the intersection of the ray and the first target collision body is obtained; finally, based on the distance between the intersection and the emission point, the virtual special effect is scaled, and the collision special effect corresponding to the laser virtual object is played at the intersection. Thus, by performing overlapping detection on the capsule of the laser virtual object, and filtering out the first target collision body that will block the virtual special effect at the logical level, performing ray detection to obtain the intersection, the corresponding collision special effect can be played at the intersection, and the virtual special effect of the laser virtual object can be scaled, so that the effect of the laser virtual object being blocked can be achieved. At the same time, since only one ray detection is used in the process of obtaining the intersection, the detection overhead can be reduced and the ray detection efficiency can be improved.
[0092] Further, in order to better illustrate the realization process of the laser virtual object blocking effect, as a refinement and extension of the above embodiment, the embodiment of the present invention provides another control method of laser special effects, such as Figure 2 As shown, the method includes:
[0093] 201. Obtain a virtual special effect corresponding to the laser virtual object played at the emission point.
[0094] For an embodiment of the present invention, when a generation instruction of a laser-type virtual object is received, the virtual special effects corresponding to the laser-type virtual object are obtained, and the original length and radius corresponding to the virtual special effects are recorded, and then the virtual special effects are played at the emission point, thereby realizing the emission effect of the laser-type virtual object.
[0095] 202. Determine at least one collision body in the same virtual scene as the laser virtual object, perform overlap detection on the at least one collision body and the capsule body respectively, and determine at least one second target collision body that blocks the virtual special effect at a physical level from the at least one collision body according to the overlap detection result.
[0096] Among them, the number of second target collision bodies can be one, two or more. In order to avoid using a large number of rays to detect the collision body that blocks the virtual special effect and increase the detection overhead, the embodiment of the present invention adopts an overlapping detection method to screen out the second target collision body that blocks the virtual special effect at the physical level. Specifically, in the overlapping detection process, since the laser virtual objects are mostly straight lines and uniformly thick bodies, the laser virtual objects can be regarded as capsules. The size of the capsule can be determined according to the size of the virtual special effect. Based on this, the method includes: adjusting the radius corresponding to the virtual special effect according to a preset proportional coefficient to obtain an adjusted radius; based on the length corresponding to the virtual special effect and the adjusted radius, generating a capsule corresponding to the laser virtual object. Among them, the length of the capsule can be equal to the original length of the virtual special effect, and the radius of the capsule is adjusted to be slightly smaller than the radius of the virtual special effect by a preset proportional coefficient to avoid being considered as blocking once the edge of the virtual special effect intersects with the collision body. The preset proportional coefficient can be set according to actual business needs.
[0097] In the process of performing overlap detection on the capsule of the laser virtual object, Unity provides Layer at the physical engine level to filter the collision body, that is, when calling the interface to detect overlapping collision bodies, only the collision bodies belonging to the specified layer can be detected, and the collision bodies of different layers have different corresponding categories. For example, the collision bodies can be divided into attack collision bodies, hit collision bodies, shield collision bodies, volume collision bodies, etc. according to the categories. The collision bodies of the above categories are all at different levels. In the process of performing overlap detection, the embodiment of the present invention can only perform overlap detection on the collision bodies of the specified layer. Based on this, the overlapping detection is performed on the at least one collision body and the capsule body respectively, and the second target collision body that blocks the virtual special effect at the physical level is determined from the at least one collision body according to the overlapping detection result, including: judging whether any one of the at least one collision body belongs to the target level according to the level information corresponding to the any one collision body; if the any one collision body belongs to the target level, performing overlap detection on the any one collision body and the capsule body; if the any one collision body overlaps with the capsule body, determining the any one collision body as the second target collision body. Among them, the target level can be set according to actual business needs, and the number of target levels is at least one.
[0098] For example, the physics engine is set to detect only two layers of collision bodies, and the collision bodies at the target level are the struck collision body and the shield collision body. At least one collision body in the same virtual scene as the laser virtual object includes: collision body A, collision body B and collision body C. Collision body A is an attack collision body, collision body B is a struck collision body, and collision body C is a shield collision body. In the process of detecting collision body A, collision body B and collision body C, it is first determined whether collision body A, collision body B and collision body C belong to the target level. Since collision body A is an attack collision body and does not belong to the target level, it is not overlapped. It is assumed that it will not block the virtual special effects of the laser virtual object. In addition, since collision body B and collision body C are the hit collision body and the shield collision body respectively, both of which belong to the collision bodies at the target level, overlap detection is performed on collision body B and collision body C respectively. Furthermore, in the process of overlap detection, if the capsule body of the laser virtual object overlaps with collision body B, it is determined that collision body B is the second target collision body that can block the virtual special effects at the physical level. Similarly, it can be determined whether collision body C is the second target collision body.
[0099] 203. Determine a first target collision body among the at least one second target collision body that blocks the virtual special effect at a logical level according to the distances between the at least one second target collision body and the capsule body.
[0100] For the embodiment of the present invention, not all collision bodies in the target layer can block the virtual special effect, and it is necessary to further determine the first target collision body that can block the virtual special effect at the logical level. Specifically, when determining the first target collision body, at least one second target collision body can be sorted according to the distance between at least one second target collision body and the capsule body, and then according to the sorting result, it is determined in turn at the layer logical level whether the second target collision body can block the virtual special effect. Based on this, step 203 specifically includes: sorting the at least one second target collision body from near to far according to the distance between the at least one second target collision body and the capsule body respectively, to obtain a sorting result; according to the sorting result, determining in turn whether the at least one second target collision body can block the virtual special effect at the logical level; when it is determined that the first second target collision body that can block the virtual special effect at the logical level is the first target collision body, the determination process is stopped, and the first second target collision body that can block the virtual special effect at the logical level is determined as the first target collision body.
[0101] For example, the second target collision bodies screened out from the physical level include collision body D, collision body E and collision body F. According to the distance between the above collision bodies and the capsule body, collision body D, collision body E and collision body F are sorted from near to far, and the sorting results are collision body E, collision body D and collision body F. Then, according to the above sorting results, it is determined from the logical level whether collision body E, collision body D and collision body F can block the virtual special effect. If collision body E cannot block the virtual special effect at the logical level, it is continued to be determined whether collision body D can block the virtual special effect at the logical level according to the sorting order. If it is determined that collision body D can block the virtual special effect at the logical level, collision body D is determined to be the first target collision body, and collision body F is no longer determined subsequently.
[0102] In a specific application scenario, the determination logic may be set according to actual business needs, such as determining whether the second target collision body can block the virtual special effect at a logical level through the attribute information corresponding to the capsule body and the attribute information corresponding to the second target collision body, where the attribute information may specifically be organizational information (for example, camp attribute). When the capsule body and the second target collision body belong to different organizational information, it is determined that the second target collision body can block the virtual special effect at a logical level. Based on this, determining the first target collision body that blocks the virtual special effect at a logical level in the at least one second target collision body according to the distance between the at least one second target collision body and the capsule body respectively includes: determining whether the any one of the at least one second target collision bodies can block the virtual special effect at a logical level according to the attribute information corresponding to the second target collision body and the attribute information corresponding to the laser virtual object. Further, the determining whether any one of the at least one second target collision body can block the virtual special effect at a logical level according to the attribute information corresponding to the second target collision body and the attribute information corresponding to the laser-type virtual object includes: determining whether any one of the second target collision body can block the virtual special effect at a logical level according to the organization information of the character to which the any one of the second target collision body belongs and the organization information of the character that emits the laser-type virtual object; if the organization information of the character to which the any one of the second target collision body belongs is the same as the organization information of the character that emits the laser-type virtual object, determining that the any one of the second target collision body cannot block the virtual special effect at a logical level; if the organization information of the character to which the any one of the second target collision body belongs is different from the organization information of the character that emits the laser-type virtual object, determining that the any one of the second target collision body can block the virtual special effect at a logical level.
[0103] For example, when the camp of the character to which any second target collision body belongs is the same as the camp of the character that emits the laser-type virtual object, it is determined that any second target object will not block the virtual special effects of the laser-type virtual object; when the camp of the character to which any second target collision body belongs is different from the camp of the character that emits the laser-type virtual object, it is determined that any second target object will block the virtual special effects of the laser-type virtual object.
[0104] It should be noted that the embodiment of the present invention does not limit the specific logic of the determination. In addition to the above-mentioned determination of the tissue information of the capsule body and the second target collision body, it is also possible to detect whether the second target collision body itself is configured to allow blocking of the laser, or to detect whether the laser-type virtual object itself is configured to be blocked, etc.
[0105] 204. Launch a ray from the launch point along the launch direction of the laser virtual object to intersect the first target collision body, and obtain an intersection point between the ray and the first target collision body.
[0106] For the embodiment of the present invention, only one ray intersecting with the first target collision body is emitted from the center position of the virtual special effect along the emission direction of the laser-type virtual object. When the emitted ray intersects with the surface of the first target collision body, the physical engine Physx returns the position information of the intersection so that the virtual special effect can be scaled based on the position information of the intersection and the corresponding collision special effect can be played at the same time.
[0107] 205. Based on the distance between the intersection point and the emission point, scale the virtual special effect, and play the collision special effect corresponding to the laser virtual object at the intersection point.
[0108] The process of scaling the virtual special effects and the process of playing the collision special effects at the intersection in the embodiment of the present invention are substantially the same as step 104 and will not be described in detail herein.
[0109] Another control method for laser special effects provided by an embodiment of the present invention can obtain the virtual special effects corresponding to the laser virtual object played at the emission point compared with the current method of playing virtual special effects only at the emission point of the laser virtual object; and perform overlapping detection on the capsule corresponding to the laser virtual object to determine the first target collision body that blocks the virtual special effects in the virtual scene; at the same time, a ray that intersects with the first target collision body is emitted from the emission point along the emission direction of the laser virtual object, and the intersection of the ray and the first target collision body is obtained; finally, based on the distance between the intersection and the emission point, the virtual special effect is scaled, and the collision special effect corresponding to the laser virtual object is played at the intersection. Thus, by performing overlapping detection on the capsule of the laser virtual object, and filtering out the first target collision body that will block the virtual special effect at the logical level, performing ray detection to obtain the intersection, the corresponding collision special effect can be played at the intersection, and the virtual special effect of the laser virtual object can be scaled, so that the effect of the laser virtual object being blocked can be achieved. At the same time, since only one ray detection is used in the process of obtaining the intersection, the detection overhead can be reduced and the ray detection efficiency can be improved.
[0110] Further, as Figure 1 The specific implementation of the present invention provides a control device for laser special effects, such as Figure 3 As shown, the device includes: an acquisition unit 31, a detection unit 32, a transmission unit 33 and a scaling unit 34.
[0111] The acquisition unit 31 may be used to acquire virtual special effects corresponding to the laser virtual object played at the emission point.
[0112] The detection unit 32 may be used to perform overlapping detection on the capsule corresponding to the laser virtual object, and determine the first target collision body that blocks the virtual special effect in the virtual scene.
[0113] The emission unit 33 may be configured to emit a ray intersecting the first target collision body from the emission point along the emission direction of the laser virtual object, and obtain an intersection point between the ray and the first target collision body.
[0114] The scaling unit 34 may be configured to scale the virtual special effect based on the distance between the intersection point and the emission point, and to play the collision special effect corresponding to the laser virtual object at the intersection point.
[0115] In a specific application scenario, the detection unit 32, such as Figure 4 As shown, it includes: a first determination module 321 and a detection module 322.
[0116] The first determining module 321 may be used to determine at least one collision body in the same virtual scene as the laser virtual object.
[0117] The detection module 322 can be used in the detection module to perform overlap detection on the at least one collision body and the capsule body respectively, and determine at least one second target collision body that blocks the virtual special effect at the physical level from the at least one collision body according to the overlap detection result.
[0118] The first determination module 321 may also be used to determine a first target collision body among the at least one second target collision body that blocks the virtual special effect at a logical level according to the distances between the at least one second target collision body and the capsule body.
[0119] Furthermore, the detection module 322 includes: a first determination submodule, a detection submodule and a first determination submodule.
[0120] The first determination submodule may be configured to determine whether any one of the at least one collision body belongs to a target level according to level information corresponding to the any one collision body.
[0121] The detection submodule may be configured to perform overlap detection on the any collision body and the capsule body if the any collision body belongs to the target level.
[0122] The first determination submodule may be configured to determine any one of the collision bodies as the second target collision body if the any one of the collision bodies overlaps with the capsule body.
[0123] Furthermore, the detection unit 32 further includes: an adjustment module 323 and a generation module 324 .
[0124] The adjustment module 323 may be used to adjust the radius corresponding to the virtual special effect according to a preset proportional coefficient to obtain an adjusted radius.
[0125] The generating module 324 may be configured to generate a capsule body corresponding to the laser-type virtual object based on the length corresponding to the virtual special effect and the adjusted radius.
[0126] Furthermore, the first determination module 321 includes: a sorting submodule, a second judging submodule and a second determining submodule.
[0127] The sorting submodule may be used to sort the at least one second target collision body from near to far according to the distances between the at least one second target collision body and the capsule body, to obtain a sorting result.
[0128] The second determination submodule may be configured to determine, in order according to the sorting result, whether the at least one second target collision body can block the virtual special effect at a logical level.
[0129] The second determination submodule may be configured to stop the determination process when determining the first second target collision body that can logically block the virtual special effect, and determine the first second target collision body that can logically block the virtual special effect as the first target collision body.
[0130] Furthermore, the second determination submodule can be specifically used to determine whether any one of the at least one second target collision body can block the virtual special effect at a logical level based on the attribute information corresponding to the any one of the at least one second target collision body and the attribute information corresponding to the laser virtual object.
[0131] Furthermore, the second determination submodule can also be specifically used to determine whether any one of the second target collision bodies can block the virtual special effect at a logical level based on the organizational information of the character to which the any one of the second target collision bodies belongs and the organizational information of the character that emits the laser-type virtual object; if the organizational information of the character to which the any one of the second target collision bodies belongs is different from the organizational information of the character that emits the laser-type virtual object, it is determined that any one of the second target collision bodies can block the virtual special effect at a logical level.
[0132] In a specific application scenario, the scaling unit 34 includes: a calculation module 341 and a scaling module 342 .
[0133] The calculation module 341 may be configured to calculate a scaling factor corresponding to the virtual special effect according to a distance between the intersection point and the emission point and a length corresponding to the virtual special effect.
[0134] The scaling module 342 may be configured to scale the virtual special effect along the emission direction of the laser-like virtual object based on the scaling factor.
[0135] Furthermore, the scaling unit 34 further includes: a second determining module 343 and an updating module 344 .
[0136] The second determining module 343 may be configured to determine a changed distance between the changed intersection and the transmitting point when the position information of the intersection changes.
[0137] The updating module 344 may be configured to update a scaling factor corresponding to the virtual special effect based on the changed distance and the length corresponding to the virtual special effect.
[0138] The scaling module 342 may also be used to scale the virtual special effects along the emission direction of the laser-type virtual object based on the updated scaling factor, and play the collision special effects corresponding to the virtual object at the changed intersection.
[0139] It should be noted that for other corresponding descriptions of the functional modules involved in the control device for laser special effects provided in the embodiment of the present invention, reference can be made to Figure 1 The corresponding description of the method shown will not be repeated here.
[0140] Based on the above Figure 1 The method shown, accordingly, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the following steps are implemented: obtaining a virtual special effect corresponding to a laser virtual object played at a launch point; performing overlap detection on a capsule corresponding to the laser virtual object, and determining a first target collision body in a virtual scene that blocks the virtual special effect; emitting a ray that intersects with the first target collision body from the launch point along the launch direction of the laser virtual object, and obtaining an intersection point of the ray and the first target collision body; scaling the virtual special effect based on the distance between the intersection point and the launch point, and playing the collision special effect corresponding to the laser virtual object at the intersection point.
[0141] Based on the above Figure 1 The method shown and Figure 3 The embodiment of the device shown in the figure, the embodiment of the present invention also provides a physical structure diagram of a computer device, such as Figure 5 As shown, the computer device includes: a processor 41, a memory 42, and a computer program stored in the memory 42 and executable on the processor, wherein the memory 42 and the processor 41 are both arranged on a bus 43, and when the processor 41 executes the program, the following steps are implemented: obtaining a virtual special effect corresponding to a laser virtual object played at a launch point; performing overlap detection on a capsule corresponding to the laser virtual object, and determining a first target collision body in a virtual scene that blocks the virtual special effect; emitting a ray that intersects with the first target collision body from the launch point along the launch direction of the laser virtual object, and obtaining an intersection point between the ray and the first target collision body; scaling the virtual special effect based on a distance between the intersection point and the launch point, and playing a collision special effect corresponding to the laser virtual object at the intersection point.
[0142] Through the technical solution of the present invention, it is possible to obtain the virtual special effects corresponding to the laser virtual object played at the emission point; and perform overlapping detection on the capsule body corresponding to the laser virtual object to determine the first target collision body that blocks the virtual special effects in the virtual scene; at the same time, a ray that intersects with the first target collision body is emitted from the emission point along the emission direction of the laser virtual object, and the intersection of the ray and the first target collision body is obtained; finally, based on the distance between the intersection and the emission point, the virtual special effects are scaled, and the collision special effects corresponding to the laser virtual object are played at the intersection. Thus, by performing overlapping detection on the capsule body of the laser virtual object, and filtering out the first target collision body that will block the virtual special effects at the logical level, performing ray detection to obtain the intersection, the corresponding collision special effects can be played at the intersection, and the virtual special effects of the laser virtual object can be scaled, so that the effect of the laser virtual object being blocked can be achieved. At the same time, since only one ray detection is used in the process of obtaining the intersection, the detection overhead can be reduced and the ray detection efficiency can be improved.
[0143] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0144] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for controlling laser special effects, characterized in that: include: Obtain the virtual special effects corresponding to the laser virtual object played at the emission point; Performing overlapping detection on the capsule corresponding to the laser virtual object to determine a first target collision body in the virtual scene that blocks the virtual special effect; Emitting a ray intersecting the first target collision body from the emission point along the emission direction of the laser virtual object, and obtaining an intersection point between the ray and the first target collision body; Based on the distance between the intersection point and the emission point, the virtual special effect is scaled, and a collision special effect corresponding to the laser virtual object is played at the intersection point; The step of performing overlapping detection on the capsule corresponding to the laser virtual object to determine the first target collision body in the virtual scene that blocks the virtual special effect includes: Determine at least one collision body in the same virtual scene as the laser virtual object; Performing overlap detection on the at least one collision body and the capsule body respectively, and determining at least one second target collision body that blocks the virtual special effect at a physical level from the at least one collision body according to the overlap detection result; A first target collision body among the at least one second target collision body that blocks the virtual special effect at a logical level is determined according to the distances between the at least one second target collision body and the capsule body.
2. The method according to claim 1, characterized in that The performing overlap detection on the at least one collision body and the capsule body respectively, and determining, according to the overlap detection result, from the at least one collision body, a second target collision body that blocks the virtual special effect at a physical level, comprises: Determining, according to level information corresponding to any one of the at least one collision body, whether the any one collision body belongs to a target level; If any one of the collision bodies belongs to the target level, performing overlap detection on the any one of the collision bodies and the capsule body; If any one of the collision bodies overlaps with the capsule body, the any one of the collision bodies is determined as the second target collision body.
3. The method according to claim 1, characterized in that Before respectively performing overlap detection on the at least one collision body and the capsule body and determining, according to the overlap detection result, from the at least one collision body, a second target collision body that blocks the virtual special effect at a physical level, the method further includes: Adjusting the radius corresponding to the virtual special effect according to a preset proportional coefficient to obtain an adjusted radius; Based on the length corresponding to the virtual special effect and the adjusted radius, a capsule body corresponding to the laser virtual object is generated.
4. The method according to claim 1, characterized in that: The determining, according to the distances between the at least one second target collision body and the capsule body, a first target collision body among the at least one second target collision body that blocks the virtual special effect at a logical level comprises: According to the distances between the at least one second target collision body and the capsule body, the at least one second target collision body is sorted from near to far to obtain a sorting result; According to the sorting result, determining in sequence whether the at least one second target collision body can block the virtual special effect at a logical level; When the first second target collision body that can block the virtual special effect at the logical level is determined, the determination process is stopped, and the first second target collision body that can block the virtual special effect at the logical level is determined as the first target collision body.
5. The method according to claim 4, characterized in that The step of sequentially determining whether the at least one second target collision body can block the virtual special effect at a logical level includes: According to the attribute information corresponding to any one of the at least one second target collision body and the attribute information corresponding to the laser virtual object, it is determined whether the any one of the second target collision bodies can block the virtual special effect at a logical level.
6. The method according to claim 5, characterized in that The determining, based on the attribute information corresponding to any one of the at least one second target collision body and the attribute information corresponding to the laser virtual object, whether any one of the at least one second target collision body can block the virtual special effect at a logical level comprises: Determine whether any one of the second target collision bodies can block the virtual special effect at a logical level according to the organizational information of the character to which the any one of the second target collision bodies belongs and the organizational information of the character that emits the laser virtual object; If the organizational information of the character to which any one of the second target collision bodies belongs is different from the organizational information of the character that emits the laser-type virtual object, it is determined that the any one of the second target collision bodies can block the virtual special effect at a logical level.
7. The method according to claim 1, characterized in that The step of scaling the virtual special effect based on the distance between the intersection point and the emission point includes: Calculating a scaling factor corresponding to the virtual special effect according to a distance between the intersection point and the emission point and a length corresponding to the virtual special effect; Based on the scaling factor, the virtual special effect is scaled along the emission direction of the laser-like virtual object.
8. The method according to claim 7, characterized in that The method further comprises: When the position information of the intersection point changes, determining a changed distance between the changed intersection point and the emission point; Based on the changed distance and the length corresponding to the virtual special effect, updating a scaling factor corresponding to the virtual special effect; Based on the updated scaling factor, the virtual special effect is scaled along the emission direction of the laser virtual object, and the collision special effect corresponding to the virtual object is played at the changed intersection.
9. A control device for laser special effects, characterized in that: include: An acquisition unit, used for acquiring a virtual special effect corresponding to a laser virtual object played at a launch point; A detection unit, configured to perform overlapping detection on the capsule corresponding to the laser virtual object, and determine a first target collision body in the virtual scene that blocks the virtual special effect; A transmitting unit, configured to transmit a ray intersecting with the first target collision body from the transmitting point along the transmitting direction of the laser virtual object, and obtain an intersection point between the ray and the first target collision body; A scaling unit, configured to scale the virtual special effect based on the distance between the intersection point and the emission point, and play a collision special effect corresponding to the laser virtual object at the intersection point; The detection unit is specifically used to determine at least one collision body in the same virtual scene as the laser virtual object; perform overlap detection on the at least one collision body and the capsule body respectively, and determine at least one second target collision body that blocks the virtual special effect at the physical level from the at least one collision body according to the overlap detection result; and determine a first target collision body that blocks the virtual special effect at the logical level from the at least one second target collision body according to the distance between the at least one second target collision body and the capsule body.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Method for simulating illumination in game scene, device, terminal equipment and storage medium
CN108236783A
Collision detection method and device, computer equipment and computer readable storage medium
CN113633988A