say3D: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(note on how to stop the sound)
m (Some wiki formatting)
 
(99 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma2 |= Game name
|game1= arma2
|version1= 1.00


|1.00|= Game version
|game2= arma2oa
|version2= 1.50


|arg= global |= Arguments in MP
|game3= tkoh
|version3= 1.00


|eff= local |= Effects in MP
|game4= arma3
____________________________________________________________________________________________
|version4= 0.50


| Unit or object will say given sound in 3D Space. This allows broadcasting of positional music or sound from a source, without having to script a fade sound or music command. Compare this with [[say2D]] which will always play a sound at the location of the player after he has been in the vicinity of a broadcasting sound. Sound is defined in "CfgSounds" of the [[Description.ext]] or main config.<br><br>
|arg= global
'''NOTE''': You can stop [[say3D]] sound currently playing in 2 ways: delete the source of the sound (from) with [[deleteVehicle]] or kill the source with [[setDamage]] for example. |= Description
____________________________________________________________________________________________


| from '''say3D''' sound|= Syntax
|eff= local


|p1= from: [[Object]] - origin of the sound
|gr1= Sounds
|p2= sound: [[String]] - classname of the sound to be played. Defined in CfgSounds including [[Description.ext]]


| [[Nothing]] |= Return value
|descr= Lets an object say given sound in 3D space.
This allows broadcasting of positional music or sound from a source, without having to script a fade sound or music command.
Compare this with [[say2D]] which will always play a sound at the location of the player after he has been in the vicinity of a broadcasting sound.
Sound is defined in {{Link|Description.ext#CfgSounds|"CfgSounds"}} of the [[Description.ext]] or main config.


| s2 = from '''say3D''' [sound, maxDistance, pitch]|= Syntax
{{Feature|informative|
* an object can only "say" '''one''' sound at a time
* in order to stop a [[say3D]] sound:
** delete the returned '''sound source''' with [[deleteVehicle]], or
** kill the '''sound source''' with e.g [[setDamage]].
* prior to {{GVI|arma3|2.00}}, the '''sound source''' object was not returned by the command, so the '''from''' object had to be deleted instead (see Examples [[#Example 2|2]] and [[#Example 3|3]]).
* forcing the speed of sound simulation:
** may delay the queued sound to play right after the previous sound, even if the second sound does not simulate sound delay (e.g sound 1 plays with a 5s delay, ends, ''then'' sound 2 plays)
** if the queued sound uses speed of sound simulation, it will be delayed from the end of the first sound (they will not follow "as expected")
** makes the ''offset'' parameter ignored.
}}


|p21= from: [[Object]] - origin of the sound
{{Feature|arma3|In earlier {{arma3}} versions, the sound created was greatly attenuated if the player was in first person view inside a vehicle at the moment of execution.}}
|p22= [sound, maxDistance, pitch]: [[Array]]
|p23= sound: [[String]] - classname of the sound to be played. Defined in CfgSounds including [[Description.ext]]
|p24= maxDistance (Optional): [[Number]] - max distance at which the sound can be heard. Default: 100 m.
|p25= pitch (Optional): [[Number]] - pitch of the sound. Default: 1.


| r2= [[Nothing]] |= Return value
|s1= from [[say3D]] sound


| s3= [from, to] '''say3D''' sound|= Syntax
|p1= from: [[Object]] or [[Array]] of [[Object]]s
* [[Object]] - origin of the sound
* [[Array]] - format is [from, to] where:
** from: [[Object]] - origin of the sound
** to: [[Object]] - target


|p41= [from, to]: [[Array]]
|p2= sound: [[String]] or [[Array]]
|p42= from: [[Object]] - origin of the sound
* [[String]] - classname of the sound to be played. Defined in [[CfgSounds]] including [[Description.ext]]
|p43= to: [[Object]] - target
* [[Array]] format [sound, maxDistance, pitch, isSpeech, offset, simulateSpeedOfSound] where:
|p44= sound: [[String]] - classname of the sound to be played. Defined in CfgSounds including [[Description.ext]]
** sound: [[String]] - classname of the sound to be played. Defined in [[Description.ext#CfgSounds|CfgSounds]] including [[Description.ext]]
** maxDistance: [[Number]] - (Optional, default 100) maximum distance in meters at which the sound can be heard
** pitch: [[Number]] - (Optional, default 1) pitch of the sound
** {{GVI|arma3|1.92|size= 0.75}} isSpeech: [[Boolean]] or {{GVI|arma3|2.04|size= 0.75}} [[Number]] - (Optional, default [[false]])
*** 0/[[false]] = play as sound ([[fadeSound]] applies)
*** 1/[[true]] = play as speech ([[fadeSpeech]] applies), filters are not applied to it (i.e. house or vehicle interior one)
*** 2 = play as sound ([[fadeSound]] applies) without interior/vehicle muffling
** {{GVI|arma3|2.00|size= 0.75}} offset: [[Number]] - (Optional, default 0) offset in seconds; ignored when ''simulateSpeedOfSound'' is used
** {{GVI|arma3|2.18|size= 0.75}} simulateSpeedOfSound: [[Boolean]] - (Optional, default [[false]]) [[true]] to simulate speed of sound (see description note)


| r3= [[Nothing]] |= Return value
|r1= [[Object]] - the sound source (was [[Nothing]] before {{GVI|arma3|2.00|size= 0.75}})


| s4 = [from, to] '''say3D''' [sound, maxDistance, pitch]|= Syntax
|x1= All possible combinations:
<sqf>
helicopter1 say3D "FortunateSon";
helicopter1 say3D ["FortunateSon", 500, 1, 0, 0, true];
[helicopter1, player] say3D "FortunateSon";
[helicopter1, player] say3D ["FortunateSon", 500, 1, 0, 0, true];
</sqf>


|p61= [from, to]: [[Array]]
|x2= Workaround for dead bodies:
|p62= from: [[Object]] - origin of the sound
<sqf>
|p63= to: [[Object]] - target
private _dummy = "#particlesource" createVehicleLocal ASLToAGL getPosWorld _corpse;
|p64= [sound, maxDistance, pitch]: [[Array]]
_dummy say3D "whatever";
|p65= sound: [[String]] - classname of the sound to be played. Defined in CfgSounds including [[Description.ext]]
_dummy spawn {
|p66= maxDistance (Optional): [[Number]] - max distance at which the sound can be heard. Default: 100 m.
sleep 5; // at least the length of your sound
|p67= pitch (Optional): [[Number]] - pitch of the sound. Default: 1.
deleteVehicle _this;
};
</sqf>


| r4= [[Nothing]] |= Return value
|x3= <sqf>
____________________________________________________________________________________________
// Since {{arma3}} v2.00, the sound source is returned and can be deleted directly
_soundSrc = helicopter1 say3D "Fortunateson";
sleep 5;
deleteVehicle _soundSrc; // stop the sound after ~5 seconds
</sqf>


|x1= <code> helicopter1 [[say3D]] "Fortunateson"</code> |= Example 1
|seealso= [[say]] [[say2D]] [[playSound]] [[playSound3D]] [[createSoundSource]] [[playSoundUI]] [[setRandomLip]]
____________________________________________________________________________________________
}}


| [[say]], [[say2D]], [[playSound]], [[createSoundSource]] |= SEEALSO
{{Note
|user= Rocket
|timestamp= 20130307131700
|text= The only difference with this command and [[say]] is during cutscenes (when some [[Camera Tutorial|camera effect]] is active). In cutscenes, [[say3D]] is 3D, [[say]] is not.
}}


| |= MPBEHAVIOUR
{{Note
____________________________________________________________________________________________
|user= Benargee
|timestamp= 20150619212600
|text= In {{arma2}} 1.63, the object this command is assigned to must be alive for the sound to broadcast. If the object is killed while the sound is still playing, the sound will stop immediately. <br>
Here is {{Link|http://forums.bistudio.com/showthread.php?146122-Making-a-dead-soldier-play-a-sound-in-3d|a link to the forum}} to get around this issue.<br>
I have not tested this in {{arma3}} yet.
}}
}}


<h3 style='display:none'>Notes</h3>
{{Note
<dl class='command_description'>
|user= Killzone_Kid
<!-- Note Section BEGIN -->
|timestamp= 20170311144300
<dd class="notedate">Posted on 7 March 2013
|text= This command creates sound object "#soundonvehicle" which can be detected with [[allMissionObjects]]:
<dt class="note">[[User:Rocket|Rocket]]<dd class="note">
<sqf>
The only difference with this command and say is during cutscenes (when some camera effect is active). In cutscenes, say3D is 3D, say is not.
onEachFrame { hintSilent str allMissionObjects "#soundonvehicle" };
<!-- Note Section END -->
0 spawn { sleep 1; player say3D "Alarm" };
</dl>
</sqf>
 
}}
<h3 style='display:none'>Bottom Section</h3>
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on July 19, 2015 - 21:26 (UTC)</dd>
<dt class="note">[[User:Benargee|Benargee]]</dt>
<dd class="note">In Arma 2 1.63, the object this command is assigned to must be alive for the sound to broadcast. If the object is killed while the sound is still playing, the sound will stop immediately. <br>
Here is a link to the forum to get around this issue: [http://forums.bistudio.com/showthread.php?146122-Making-a-dead-soldier-play-a-sound-in-3d]<br>
I have not tested this in Arma 3 yet.
</dd>
</dl>
<!-- DISCONTINUE Notes -->
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on October 13, 2016 - 16:12 (UTC)</dd>
<dt class="note">[[User:Icaruk|Icaruk]]</dt>
<dd class="note">
This command is local.
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 19:36, 3 September 2024

Hover & click on the images for description

Description

Description:
Lets an object say given sound in 3D space. This allows broadcasting of positional music or sound from a source, without having to script a fade sound or music command. Compare this with say2D which will always play a sound at the location of the player after he has been in the vicinity of a broadcasting sound. Sound is defined in "CfgSounds" of the Description.ext or main config.
  • an object can only "say" one sound at a time
  • in order to stop a say3D sound:
  • prior to Arma 3 logo black.png2.00, the sound source object was not returned by the command, so the from object had to be deleted instead (see Examples 2 and 3).
  • forcing the speed of sound simulation:
    • may delay the queued sound to play right after the previous sound, even if the second sound does not simulate sound delay (e.g sound 1 plays with a 5s delay, ends, then sound 2 plays)
    • if the queued sound uses speed of sound simulation, it will be delayed from the end of the first sound (they will not follow "as expected")
    • makes the offset parameter ignored.
Arma 3
In earlier Arma 3 versions, the sound created was greatly attenuated if the player was in first person view inside a vehicle at the moment of execution.
Groups:
Sounds

Syntax

Syntax:
from say3D sound
Parameters:
from: Object or Array of Objects
  • Object - origin of the sound
  • Array - format is [from, to] where:
sound: String or Array
  • String - classname of the sound to be played. Defined in CfgSounds including Description.ext
  • Array format [sound, maxDistance, pitch, isSpeech, offset, simulateSpeedOfSound] where:
    • sound: String - classname of the sound to be played. Defined in CfgSounds including Description.ext
    • maxDistance: Number - (Optional, default 100) maximum distance in meters at which the sound can be heard
    • pitch: Number - (Optional, default 1) pitch of the sound
    • Arma 3 logo black.png1.92 isSpeech: Boolean or Arma 3 logo black.png2.04 Number - (Optional, default false)
      • 0/false = play as sound (fadeSound applies)
      • 1/true = play as speech (fadeSpeech applies), filters are not applied to it (i.e. house or vehicle interior one)
      • 2 = play as sound (fadeSound applies) without interior/vehicle muffling
    • Arma 3 logo black.png2.00 offset: Number - (Optional, default 0) offset in seconds; ignored when simulateSpeedOfSound is used
    • Arma 3 logo black.png2.18 simulateSpeedOfSound: Boolean - (Optional, default false) true to simulate speed of sound (see description note)
Return Value:
Object - the sound source (was Nothing before Arma 3 logo black.png2.00)

Examples

Example 1:
All possible combinations:
helicopter1 say3D "FortunateSon"; helicopter1 say3D ["FortunateSon", 500, 1, 0, 0, true]; [helicopter1, player] say3D "FortunateSon"; [helicopter1, player] say3D ["FortunateSon", 500, 1, 0, 0, true];
Example 2:
Workaround for dead bodies:
private _dummy = "#particlesource" createVehicleLocal ASLToAGL getPosWorld _corpse; _dummy say3D "whatever"; _dummy spawn { sleep 5; // at least the length of your sound deleteVehicle _this; };
Example 3:
// Since Arma 3 v2.00, the sound source is returned and can be deleted directly _soundSrc = helicopter1 say3D "Fortunateson"; sleep 5; deleteVehicle _soundSrc; // stop the sound after ~5 seconds

Additional Information

See also:
say say2D playSound playSound3D createSoundSource playSoundUI setRandomLip

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Rocket - c
Posted on Mar 07, 2013 - 13:17 (UTC)
The only difference with this command and say is during cutscenes (when some camera effect is active). In cutscenes, say3D is 3D, say is not.
Benargee - c
Posted on Jun 19, 2015 - 21:26 (UTC)
In Arma 2 1.63, the object this command is assigned to must be alive for the sound to broadcast. If the object is killed while the sound is still playing, the sound will stop immediately.
Here is a link to the forum to get around this issue.
I have not tested this in Arma 3 yet.
Killzone_Kid - c
Posted on Mar 11, 2017 - 14:43 (UTC)
This command creates sound object "#soundonvehicle" which can be detected with allMissionObjects:
onEachFrame { hintSilent str allMissionObjects "#soundonvehicle" }; 0 spawn { sleep 1; player say3D "Alarm" };