Threat level sound effect playing method, device, storage medium and electronic device
By detecting attack events in a virtual scene and determining the target sound source location of the threat sound effect, the problem of large computing volume in the prior art is solved, and more efficient threat sound effect playback is achieved, and the operating pressure of computer equipment is reduced.
Patent Information
- Application Number
- CN202210821133.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-12
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2042-07-12
AI Technical Summary
In the prior art, threat system needs to adjust threat sound effects by hanging contactors to virtual characters and adding physical collisions, resulting in large amounts of computing and increasing the operating pressure of computer equipment.
By detecting the target virtual character attacking other virtual characters, the location of the target virtual character, the attack direction vector and other information are obtained, and the target sound source location of the threat sound effect in the virtual scene is determined, and the threat sound effect is played based on that location.
It reduces the amount of computing, reduces the operating pressure of computer equipment, and improves game performance.
Smart Images

Figure CN115193044B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a method and device for playing threatening sound effects, a computer-readable storage medium, and an electronic device. Background Art
[0002] In recent years, with the development and popularization of computer equipment technology, more and more applications with three-dimensional virtual environments have emerged, such as virtual reality applications, three-dimensional map programs, military simulation programs, first-person shooting games (FPS), role-playing games (RPG), etc.
[0003] In the prior art, taking FPS games as an example, when there are multiple people shooting at each other, the threat system will clearly play the sound produced by the virtual character that poses the greatest threat to the enemy, so that the players corresponding to each virtual character of the enemy can recognize the virtual character that poses the greatest threat, and thus target or avoid it.
[0004] In the process of research and practice of the prior art, the inventor of the present application found that the threat level system of the prior art needs to perform a large amount of calculations after attaching triggers to virtual characters and adding physical collisions in order to adjust the threat level sound effects. The amount of calculation is large, which increases the operating pressure of computer equipment. Summary of the invention
[0005] The embodiments of the present application provide a method and device for playing threatening sound effects, which can reduce the amount of calculation and reduce the operating pressure of computer equipment.
[0006] To solve the above technical problems, the present application provides the following technical solutions:
[0007] A method for playing a threat sound effect, comprising:
[0008] When it is detected that a target virtual character attacks other virtual characters, obtaining a first position of the target virtual character, a second position of the other virtual characters, and an attack direction vector corresponding to the attack direction of the target virtual character when attacking;
[0009] Determining a target sound source position of a threat sound effect corresponding to the attack in a virtual scene based on the first position, the second position, and the attack direction vector;
[0010] The threat sound effect is played based on the target sound source position.
[0011] A device for playing threatening sound effects, characterized by comprising:
[0012] An acquisition module, for acquiring, when it is detected that a target virtual character attacks other virtual characters, a first position of the target virtual character, a second position of the other virtual characters, and an attack direction vector corresponding to the attack direction of the target virtual character when attacking;
[0013] A determination module, configured to determine a target sound source position of a threat sound effect corresponding to the attack in a virtual scene based on the first position, the second position, and the attack direction vector;
[0014] A playing module is used to play the threat sound effect based on the target sound source position.
[0015] In some embodiments, the determining module includes:
[0016] A first calculation submodule, configured to calculate a first distance value between the target virtual character and the other virtual characters based on the first position and the second position;
[0017] A second calculation submodule, used to calculate the unit vector corresponding to the attack direction vector;
[0018] A first determining submodule, configured to determine a reference position based on the first distance value and the unit vector;
[0019] A comparison submodule, configured to calculate a second distance value between the reference position and the other virtual character based on the reference position and the second position, and compare the second distance value with a preset distance value to obtain a comparison result;
[0020] The second determination submodule is used to determine the target sound source position of the threat sound effect corresponding to the attack in the virtual scene based on the comparison result.
[0021] In some embodiments, the second determining submodule is used to:
[0022] If the comparison result is that the second distance value is less than the preset distance value, detecting whether there is an obstruction between the first position and the reference position;
[0023] When there is an obstruction between the first position and the reference position, determining a target obstruction away from the reference position;
[0024] The target position of the target obstruction is obtained, and the target position is determined as the target sound source position of the threat sound effect corresponding to the attack in the virtual scene.
[0025] In some embodiments, the second determining submodule is further used to:
[0026] When there is no obstruction between the first position and the reference position, the reference position is determined as the target sound source position of the threat sound effect corresponding to the attack in the virtual scene.
[0027] In some embodiments, the second determining submodule is further used to:
[0028] If the comparison result is that the second distance value is greater than the preset distance value, playing the threat sound effect is prohibited.
[0029] In some embodiments, the device further comprises:
[0030] A calculation module, used for calculating a third distance value between the target sound source position and the second position;
[0031] An execution module is used to execute the step of playing the threat sound effect based on the target sound source position if the third distance value is not within the preset distance value interval.
[0032] In some embodiments, the device further comprises:
[0033] A prohibition module is used to prohibit playing the threat sound effect based on the target sound source position if the third distance value is within a preset distance value interval.
[0034] In some embodiments, the playback module includes:
[0035] a third determination submodule, configured to determine a target sound effect volume corresponding to the third distance value based on a mapping relationship between the distance value and the sound effect volume;
[0036] An acquisition submodule, used to acquire the target attack type when the target virtual character attacks;
[0037] A fourth determination submodule, configured to determine a target sound effect tone corresponding to the target attack type based on a mapping relationship between the attack type and the sound effect tone;
[0038] The playing submodule is used to play the threat sound effect at the target sound source position according to the target sound effect volume and the target sound effect pitch.
[0039] A computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for a processor to load to execute the steps in the above-mentioned method for playing threat sound effects.
[0040] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the method for playing threat sound effects as described above when executing the program.
[0041] In the embodiment of the present application, when it is detected that a target virtual character attacks other virtual characters, the first position of the target virtual character, the second position of the other virtual characters, and the attack direction vector corresponding to the attack direction of the target virtual character are obtained; based on the first position, the second position, and the attack direction vector, the target sound source position of the threat sound effect corresponding to the attack in the virtual scene is determined; and the threat sound effect is played based on the target sound source position. In this way, the target sound source position of the threat sound effect corresponding to the attack in the virtual scene is determined through the first position, the second position, and the attack direction vector, avoiding the attachment of triggers to virtual characters and adding physical collisions, thereby reducing the amount of calculation and the operating pressure of computer equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0043] Figure 1a A system diagram of a method for playing threatening sound effects provided in an embodiment of the present application.
[0044] Figure 1b A flowchart of a method for playing threat sound effects provided in an embodiment of the present application.
[0045] Figure 1c A schematic diagram of the principle of determining a reference position provided in an embodiment of the present application.
[0046] Figure 1d A schematic diagram of determining a target position of a target obstruction as a target sound effect position provided in an embodiment of the present application.
[0047] Figure 2 A schematic diagram of the structure of a device for playing threatening sound effects provided in an embodiment of the present application;
[0048] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0050] See also Figure 1a , Figure 1a A system diagram of a method for playing threat sound effects provided in an embodiment of the present application, the system may include at least one client 1000, at least one electronic device 2000, at least one database 3000, and a network 4000. The client 1000 may be a computer device such as a mobile phone, a computer or a personal digital assistant, and the electronic device 2000 may establish a connection with the client 1000 through the network 4000, and the electronic device 2000 is used to synchronize other virtual players and virtual scene images in the game to the client 1000 in real time. Among them, the network 4000 may be a wireless network or a wired network, such as a wireless network such as a wireless local area network (WLAN), a local area network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, etc. In addition, the system may include a database 3000, which may be used to store the player's account information and the virtual character information under the account, etc.
[0051] The present application embodiment provides a method for playing threatening sound effects, which can be performed by an electronic device. Figure 1a As shown, when the electronic device 2000 detects that a target virtual character attacks other virtual characters, it obtains the first position of the target virtual character, the second position of the other virtual characters, and the attack direction vector corresponding to the attack direction of the target virtual character when attacking; based on the first position, the second position and the attack direction vector, it determines the target sound source position of the threat sound effect corresponding to the attack in the virtual scene; and plays the threat sound effect based on the target sound source position.
[0052] It should be noted that Figure 1a The system diagram for playing the threat level sound effect shown is only an example. The threat level sound effect playing system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the threat level sound effect playing system and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.
[0053] In this embodiment, the description will be made from the perspective of a device for playing threatening sound effects. The device for playing threatening sound effects may be integrated in an electronic device having a storage unit and a microprocessor installed therein and having computing capabilities.
[0054] See also Figure 1b , Figure 1bA flowchart of a method for playing a threat level sound effect provided in an embodiment of the present application. The method for playing a threat level sound effect includes:
[0055] In step 101, when it is detected that a target virtual character attacks other virtual characters, the first position of the target virtual character, the second position of the other virtual characters, and the attack direction vector corresponding to the attack direction of the target virtual character are obtained.
[0056] Among them, the position of each virtual character playing in the virtual scene will be synchronized to the electronic device. When there is a target virtual character attacking other virtual characters, the first position of the target virtual character in the virtual scene, the second position of the other virtual characters in the virtual scene and the attack direction vector corresponding to the attack direction of the target virtual character when attacking are obtained.
[0057] Specifically, other virtual characters are virtual characters in the camp battle and in the free battle, they are virtual characters other than the target virtual character. And the means of attack are different for different game types. For example, in FPS games, attacks are carried out by means of virtual firearms, and in RPG games, attacks are carried out by releasing skills. However, different types of games will attack in a certain direction, that is, the attack direction, and the attack direction can be controlled by the player who controls the virtual character.
[0058] In a three-dimensional virtual scene, the position of a virtual character is generally determined by the x-axis, y-axis, and z-axis. For example, the first position of the target virtual character is (x1, y1, z1), and the second position of other virtual characters is (x2, y2, z2). The attack direction vector can be To express.
[0059] In step 102, based on the first position, the second position and the attack direction vector, a target sound source position of a threat sound effect corresponding to an attack in a virtual scene is determined.
[0060] In order to play the threat sound effect, it is necessary to determine the target sound source position for playing the threat sound effect according to the first position, the second position and the attack direction vector.
[0061] In some embodiments, the step of determining the target sound source position of the threat sound effect corresponding to the attack in the virtual scene based on the first position, the second position, and the attack direction vector includes:
[0062] (1) calculating a first distance value between the target virtual character and the other virtual characters based on the first position and the second position;
[0063] (2) calculating the unit vector corresponding to the attack direction vector;
[0064] (3) determining a reference position based on the first distance value and the unit vector;
[0065] (4) calculating a second distance value between the reference position and the other virtual character based on the reference position and the second position, and comparing the second distance value with a preset distance value to obtain a comparison result;
[0066] (5) Based on the comparison result, determine the target sound source position of the threat sound effect corresponding to the attack in the virtual scene.
[0067] Among them, Figure 1c As shown, Figure 1c A schematic diagram of the principle of determining a reference position provided in an embodiment of the present application. The first distance value l1 between the target virtual character and the other virtual character can be calculated based on the coordinates (x1, y1, z1) of the first position A and the coordinates (x2, y2, z2) of the second position B. And calculate the attack direction vector The corresponding unit vector Calculate l1 and unit vector The product of the reference position is p. near =(x near ,y near , z near )=(x v *l1,y v *l1,z v *l1); calculate the reference position p near The second distance value between the other virtual character (x2, y2, z2)
[0068] Specifically, after l2 is calculated, l2 needs to be compared with a preset distance value. The purpose of setting the preset distance value is: if l2 is greater than the preset distance value, it proves that the other virtual characters are far away from the reference position; if l2 is less than the preset distance value, it proves that the other virtual characters are close to the reference position. The method of determining the target sound source is different for different situations.
[0069] In some embodiments, the step of determining the target sound source position of the threat sound effect corresponding to the attack in the virtual scene based on the comparison result includes:
[0070] (1.1) If the comparison result is that the second distance value is less than the preset distance value, detecting whether there is an obstruction between the first position and the reference position;
[0071] (1.2) when there is an obstruction between the first position and the reference position, determining a target obstruction away from the reference position;
[0072] (1.3) Obtaining a target position of the target obstruction, and determining the target position as a target sound source position of a threat sound effect corresponding to the attack in the virtual scene.
[0073] Among them, Figure 1d As shown, Figure 1d A schematic diagram of determining the target position of a target obstruction as the target sound effect position provided in an embodiment of the present application. Since there are some obstructions such as buildings and mountains in addition to virtual characters in the virtual scene, in order to restore the real scene, if the attack is blocked by the obstruction, the sound effects caused by the bullet or skill will be played at the obstruction. Therefore, if the comparison result is that the second distance value is less than the preset distance value, it is detected whether there is an obstruction between the first position and the reference position. Figure 1d As shown, A and p near There are occluders C and D between the first position and the reference position, and the sound effect caused by the bullet or skill will be played at the position where it is first blocked. Therefore, when there is an occluder between the first position and the reference position, the target occluder far away from the reference position is determined. Figure 1d Far from the reference position p near The target occluder is C, so the target position of the target occluder C is obtained, and the target position is determined as the target sound source position of the threat sound effect corresponding to the attack in the virtual scene.
[0074] In some embodiments, the method further comprises:
[0075] When there is no obstruction between the first position and the reference position, the reference position is determined as the target sound source position of the threat sound effect corresponding to the attack in the virtual scene.
[0076] If there is no obstruction between a position and the reference position, the reference position p is directly near A target sound source position of a threat sound effect corresponding to the attack in the virtual scene is determined.
[0077] In some embodiments, the method further comprises:
[0078] If the comparison result is that the second distance value is greater than the preset distance value, playing the threat sound effect is prohibited.
[0079] Among them, when the second distance value between the reference position and other virtual characters is greater than the preset distance value, it means that the other virtual characters are far away from the reference position, that is, it is difficult or impossible for the target virtual character to pose a threat to other virtual characters, so playing the threat sound effect is prohibited.
[0080] In step 103, a threat sound effect is played based on the target sound source position.
[0081] Among them, after the target sound source position is determined, the threat sound effect can be played based on the target sound source position.
[0082] In some implementations, before the step of playing the threat sound effect based on the target sound source position, the method further includes:
[0083] (1) calculating a third distance value between the target sound source position and the second position;
[0084] (2) If the third distance value is not within the preset distance value range, executing the step of playing the threat sound effect based on the target sound source position.
[0085] Among them, if the target sound source position is too close or too far from other virtual characters, the threat sound effect may not be played. Therefore, after determining the target sound source position, it is necessary to calculate the third distance value between the target sound source position and the second position, and detect whether the third distance value is within a preset distance value range, for example, 5 meters to 10 meters. If so, the step of playing the threat sound effect based on the target sound source position is performed, and the threat sound effect is played normally.
[0086] In some implementations, the step of playing the threat sound effect based on the target sound source position includes:
[0087] (1) determining a target sound effect volume corresponding to the third distance value based on a mapping relationship between the distance value and the sound effect volume;
[0088] (2) obtaining a target attack type when the target virtual character attacks;
[0089] (3) determining a target sound effect tone corresponding to the target attack type based on a mapping relationship between the attack type and the sound effect tone;
[0090] (4) Playing the threat sound effect at the target sound source location according to the target sound effect volume and the target sound effect pitch.
[0091] Among them, in order to restore the real scene, the distance between the target sound source position and other virtual characters, the volume, tone and other parameters of the threat sound effect shown to other virtual characters at different distances are also different. You can agree with the game program in advance on the name of the third distance value, such as threat_distance, and create an RTPC with the same name in Game Parameters. Since the program has already set the specific function of RTPC, select None in the Bind to Built-In Parameter tab, otherwise Wwise will overwrite the function set by the program, and then set the default value and maximum / minimum value of RTPC. The value here is best set according to the effective distance of the gunshot sound effect in our game. Create a Switch Container to bind the GUN_TYPE switch. Through this switch, you can distinguish different guns, and even use different threat sound effects on different guns. Bind the threat_distance RTPC to the Switch Container in the third step, and start modulating the performance effect in the game as needed. Make-up Gain can be used to adjust the volume of threat sound effects at different distances. At close range, the amount of information provided by gunshots is sufficient, and adding threat sound effects will make it seem a bit chaotic, so we adjust Make-up Gain to 0 at close range. Voice Pitch can also be used to adjust the sound performance at different distances, and filters can be used as needed. Through the above steps, a mapping relationship between the third distance value and various parameters such as the volume and filter of the threat sound effect is established, as well as a mapping relationship between different attack types and parameters such as tone. For FPS games, the attack type can be the gun type of virtual guns, and for RPG games, the attack type can be the skill type of skills, which is not limited here.
[0092] Specifically, after the mapping relationship is established, the target sound effect volume corresponding to the third distance value can be determined based on the mapping relationship between the distance value and the sound effect volume; the target sound effect tone corresponding to the target attack type can be determined based on the mapping relationship between the attack type and the sound effect tone; and the threat degree sound effect can be played at the target sound source position according to the target sound effect volume and the target sound effect tone.
[0093] As can be seen from the above, the embodiment of the present application obtains the first position of the target virtual character, the second position of the other virtual characters, and the attack direction vector corresponding to the attack direction of the target virtual character when it is detected that there is a target virtual character attacking other virtual characters; based on the first position, the second position and the attack direction vector, the target sound source position of the threat sound effect corresponding to the attack in the virtual scene is determined; and the threat sound effect is played based on the target sound source position. In this way, the target sound source position of the threat sound effect corresponding to the attack in the virtual scene is determined through the first position, the second position and the attack direction vector, avoiding the attachment of triggers to virtual characters and adding physical collisions, thereby reducing the amount of calculation and the operating pressure of computer equipment.
[0094] In order to facilitate better implementation of the method for playing the threat degree sound effect provided in the embodiment of the present application, the embodiment of the present application also provides a device based on the above-mentioned method for playing the threat degree sound effect. The meanings of the terms are the same as those in the above-mentioned method for playing the threat degree sound effect, and the specific implementation details can refer to the description in the method embodiment.
[0095] See also Figure 2 , Figure 2 This is a schematic diagram of the structure of a device for playing a threat level sound effect provided in an embodiment of the present application, wherein the device for playing a threat level sound effect may include an acquisition module 301, a determination module 302, and a playing module 303, etc.
[0096] The acquisition module 301 is used to acquire the first position of the target virtual character, the second position of the other virtual character, and the attack direction vector corresponding to the attack direction of the target virtual character when it is detected that the target virtual character attacks other virtual characters;
[0097] A determination module 302 is used to determine a target sound source position of a threat sound effect corresponding to the attack in a virtual scene based on the first position, the second position and the attack direction vector;
[0098] The playing module 303 is used to play the threat sound effect based on the target sound source position.
[0099] In some implementations, the determining module 302 includes:
[0100] A first calculation submodule, configured to calculate a first distance value between the target virtual character and the other virtual characters based on the first position and the second position;
[0101] A second calculation submodule, used to calculate the unit vector corresponding to the attack direction vector;
[0102] A first determining submodule, configured to determine a reference position based on the first distance value and the unit vector;
[0103] A comparison submodule, configured to calculate a second distance value between the reference position and the other virtual character based on the reference position and the second position, and compare the second distance value with a preset distance value to obtain a comparison result;
[0104] The second determination submodule is used to determine the target sound source position of the threat sound effect corresponding to the attack in the virtual scene based on the comparison result.
[0105] In some implementations, the second determining submodule is configured to:
[0106] If the comparison result is that the second distance value is less than the preset distance value, detecting whether there is an obstruction between the first position and the reference position;
[0107] When there is an obstruction between the first position and the reference position, determining a target obstruction away from the reference position;
[0108] The target position of the target obstruction is obtained, and the target position is determined as the target sound source position of the threat sound effect corresponding to the attack in the virtual scene.
[0109] In some implementations, the second determining submodule is further configured to:
[0110] When there is no obstruction between the first position and the reference position, the reference position is determined as the target sound source position of the threat sound effect corresponding to the attack in the virtual scene.
[0111] In some implementations, the second determining submodule is further configured to:
[0112] If the comparison result is that the second distance value is greater than the preset distance value, playing the threat sound effect is prohibited.
[0113] In some embodiments, the device further comprises:
[0114] A calculation module, used for calculating a third distance value between the target sound source position and the second position;
[0115] An execution module is used to execute the step of playing the threat sound effect based on the target sound source position if the third distance value is not within the preset distance value interval.
[0116] In some embodiments, the device further comprises:
[0117] A prohibition module is used to prohibit playing the threat sound effect based on the target sound source position if the third distance value is within a preset distance value interval.
[0118] In some implementations, the playback module 303 includes:
[0119] a third determination submodule, configured to determine a target sound effect volume corresponding to the third distance value based on a mapping relationship between the distance value and the sound effect volume;
[0120] An acquisition submodule, used to acquire the target attack type when the target virtual character attacks;
[0121] A fourth determination submodule, configured to determine a target sound effect tone corresponding to the target attack type based on a mapping relationship between the attack type and the sound effect tone;
[0122] The playing submodule is used to play the threat sound effect at the target sound source position according to the target sound effect volume and the target sound effect pitch.
[0123] As can be seen from the above, in the embodiment of the present application, when the acquisition module 301 detects that there is a target virtual character attacking other virtual characters, the first position of the target virtual character, the second position of the other virtual characters, and the attack direction vector corresponding to the attack direction of the target virtual character when attacking; the determination module 302 determines the target sound source position of the threat sound effect corresponding to the attack in the virtual scene based on the first position, the second position and the attack direction vector; the playback module 303 plays the threat sound effect based on the target sound source position. In this way, the target sound source position of the threat sound effect corresponding to the attack in the virtual scene is determined through the first position, the second position and the attack direction vector, avoiding the attachment of triggers to virtual characters and the addition of physical collisions, thereby reducing the amount of calculation and the operating pressure of computer equipment.
[0124] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0125] Accordingly, the present application also provides an electronic device, such as Figure 3 As shown, Figure 3A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 2000 includes a processor 401 having one or more processing cores, a memory 402 having one or more computer-readable storage media, and a computer program stored in the memory 402 and executable on the processor. The processor 401 is electrically connected to the memory 402. It will be understood by those skilled in the art that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0126] The electronic device 2000 may include a client controlled by a user, or a background server of a game, etc. When the electronic device 2000 is a client controlled by a user, if the target virtual character attacks other virtual characters, the second position of the other virtual characters and the attack direction vector corresponding to the attack direction of the target virtual character when attacking are acquired by the client corresponding to the target virtual character, and the acquisition method may be to trigger the background server of the game to feedback the second position of the other virtual characters, and obtain the attack direction vector corresponding to the attack direction of the target virtual character when attacking according to calculation; when the electronic device 2000 is a client controlled by a user, since the position information of the virtual characters is synchronized to the server in real time, the first position of the target virtual character and the second positions of the other virtual characters can be directly obtained through synchronization.
[0127] The processor 401 is the control center of the electronic device 2000. It uses various interfaces and lines to connect the various parts of the entire electronic device 2000, executes various functions of the electronic device 2000 and processes data by running or loading software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, thereby monitoring the electronic device 2000 as a whole.
[0128] In the embodiment of the present application, the processor 401 in the electronic device 2000 will load instructions corresponding to the processes of one or more application programs into the memory 402 according to the following steps, and the processor 401 will run the application programs stored in the memory 402 to implement various functions:
[0129] When it is detected that a target virtual character attacks other virtual characters, the first position of the target virtual character, the second position of the other virtual characters, and the attack direction vector corresponding to the attack direction of the target virtual character are obtained; based on the first position, the second position and the attack direction vector, the target sound source position of the threat sound effect corresponding to the attack in the virtual scene is determined; and the threat sound effect is played based on the target sound source position.
[0130] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0131] Optional, such as Figure 3 As shown, the electronic device 2000 further includes: an input unit 403 and a power supply 404. The processor 401 is electrically connected to the input unit 403 and the power supply 404 respectively. Those skilled in the art can understand that Figure 3 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0132] The input unit 403 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0133] The power supply 404 is used to supply power to various components of the electronic device 2000. Optionally, the power supply 404 can be logically connected to the processor 401 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 404 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0134] although Figure 3 Not shown, the electronic device 2000 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0135] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0136] As can be seen from the above, the electronic device provided in this embodiment can obtain the first position of the target virtual character, the second position of the other virtual characters, and the attack direction vector corresponding to the attack direction of the target virtual character when detecting that there is a target virtual character attacking other virtual characters; determine the target sound source position of the threat sound effect corresponding to the attack in the virtual scene based on the first position, the second position and the attack direction vector; and play the threat sound effect based on the target sound source position. In this way, the target sound source position of the threat sound effect corresponding to the attack in the virtual scene is determined through the first position, the second position and the attack direction vector, avoiding the attachment of triggers to virtual characters and the addition of physical collisions, thereby reducing the amount of calculation and the operating pressure of computer equipment.
[0137] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0138] To this end, an embodiment of the present application provides a computer-readable storage medium, in which multiple computer programs are stored, and the computer program can be loaded by a processor to execute the steps in any data analysis method provided in the embodiment of the present application. For example, the computer program can execute the following steps:
[0139] When it is detected that a target virtual character attacks other virtual characters, the first position of the target virtual character, the second position of the other virtual characters, and the attack direction vector corresponding to the attack direction of the target virtual character are obtained; based on the first position, the second position, and the attack direction vector, the target sound source position of the threat sound effect corresponding to the attack in the virtual scene is determined; and the threat sound effect is played based on the target sound source position. In this way, the target sound source position of the threat sound effect corresponding to the attack in the virtual scene is determined through the first position, the second position, and the attack direction vector, avoiding the attachment of triggers to virtual characters and adding physical collisions, thereby reducing the amount of calculation and the operating pressure of computer equipment.
[0140] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0141] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0142] Since the computer program stored in the storage medium can execute the steps in any method for playing threat sound effects provided in the embodiments of the present application, the beneficial effects that can be achieved by any data analysis method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0143] The above is a detailed introduction to a method, device, storage medium and electronic device for playing a threatening sound effect provided in an embodiment of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for technicians in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for playing threatening sound effects, characterized in that: include: When it is detected that a target virtual character attacks other virtual characters, obtaining a first position of the target virtual character, a second position of the other virtual characters, and an attack direction vector corresponding to the attack direction of the target virtual character when attacking; Based on the first position and the second position, calculating a first distance value between the target virtual character and the other virtual characters; Calculate the unit vector corresponding to the attack direction vector; Determine a reference position based on the first distance value and the unit vector; Based on the reference position and the second position, calculating a second distance value between the reference position and the other virtual character, and comparing the second distance value with a preset distance value to obtain a comparison result; Based on the comparison result, determining a target sound source position of the threat sound effect corresponding to the attack in the virtual scene; The threat sound effect is played based on the target sound source position.
2. The method for playing threat sound effects according to claim 1, characterized in that: The step of determining the target sound source position of the threat sound effect corresponding to the attack in the virtual scene based on the comparison result includes: If the comparison result is that the second distance value is less than the preset distance value, detecting whether there is an obstruction between the first position and the reference position; When there is an obstruction between the first position and the reference position, determining a target obstruction away from the reference position; The target position of the target obstruction is obtained, and the target position is determined as the target sound source position of the threat sound effect corresponding to the attack in the virtual scene.
3. The method for playing threat sound effects according to claim 2, characterized in that: The method further comprises: When there is no obstruction between the first position and the reference position, the reference position is determined as the target sound source position of the threat sound effect corresponding to the attack in the virtual scene.
4. The method for playing threat sound effects according to claim 2, characterized in that: The method further comprises: If the comparison result is that the second distance value is greater than the preset distance value, playing the threat sound effect is prohibited.
5. The method for playing threat sound effects according to claim 1, characterized in that: Before the step of playing the threat sound effect based on the target sound source position, the method further includes: Calculating a third distance value between the target sound source position and the second position; If the third distance value is not within the preset distance value interval, the step of playing the threat sound effect based on the target sound source position is performed.
6. The method for playing threat sound effects according to claim 5, characterized in that: The method further comprises: If the third distance value is within a preset distance value interval, playing the threat sound effect based on the target sound source position is prohibited.
7. The method for playing threat sound effects according to claim 5, characterized in that: The step of playing the threat sound effect based on the target sound source position includes: Determining a target sound effect volume corresponding to the third distance value based on a mapping relationship between the distance value and the sound effect volume; Obtaining a target attack type when the target virtual character attacks; Determining a target sound effect tone corresponding to the target attack type based on a mapping relationship between the attack type and the sound effect tone; The threat sound effect is played at the target sound source position according to the target sound effect volume and the target sound effect pitch.
8. A device for playing threatening sound effects, characterized in that: include: An acquisition module, for acquiring, when it is detected that a target virtual character attacks other virtual characters, a first position of the target virtual character, a second position of the other virtual characters, and an attack direction vector corresponding to the attack direction of the target virtual character when attacking; A determination module, configured to calculate a first distance value between the target virtual character and the other virtual characters based on the first position and the second position; Calculate the unit vector corresponding to the attack direction vector; Determine a reference position based on the first distance value and the unit vector; Based on the reference position and the second position, calculating a second distance value between the reference position and the other virtual character, and comparing the second distance value with a preset distance value to obtain a comparison result; Based on the comparison result, determining a target sound source position of the threat sound effect corresponding to the attack in the virtual scene; A playing module is used to play the threat sound effect based on the target sound source position.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the method for playing threat sound effects according to any one of claims 1 to 7.
10. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps in the method for playing the threat sound effect as described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Information prompting method and device in game, storage medium and computer equipment
CN113082709A