Passer au contenu principal
Version: latest - a1.73.x βš–οΈ

πŸ”Š Sound

Class for playing in-game 2D and 3D sounds.


πŸ’‚Authority
This class can only be spawned on 🟧 Client side.
πŸ‘ͺInheritance
This class shares methods and events from , .
πŸ§‘β€πŸ’»API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

tip

You can also load raw .ogg files from disk! Please check SpecialPath.

πŸŽ’ Examples​

local my_sound = Sound(
Vector(-510, 145, 63), -- Location (if a 3D sound)
"nanos-world::A_VR_Confirm", -- Asset Path
false, -- Is 2D Sound
true, -- Auto Destroy (if to destroy after finished playing)
SoundType.SFX,
1, -- Volume
1 -- Pitch
)
-- Spawning a ogg sound located in a Package
local ogg_sound = Sound(Vector(), "package://my-package/Client/awesome_beep.ogg", true)

πŸ›  Constructors​

Default Constructor

No description provided

local my_sound = Sound(location, asset, is_2D_sound?, auto_destroy?, sound_type?, volume?, pitch?, inner_radius?, falloff_distance?, attenuation_function?, keep_playig_when_silent?, loop_mode?)
TypeNameDefaultDescription
Vectorlocation Required parameter Only used if 3D sound
asset Required parameter The Sound Asset to load
is_2D_soundfalseWhether to spawn it as 2D or 3D
auto_destroytrueWhether to destroy after finished playing
sound_typeSoundType.SFXUsed to apply user's volume settings
volume1No description provided
pitch1No description provided
inner_radius400Only used if 3D sound
falloff_distance3600Only used if 3D sound
attenuation_functionLinearOnly used if 3D sound
keep_playig_when_silentfalseOnly used if 3D sound - Use with caution, it may cause performance issues!
loop_modeDefaultWhether should force sound to loop
Note

auto_destroy means the Entity will be immediately destroyed after spawned, losing references to the Sound spawned in-game. So if the Sound itself loops indefinitely, it will keep playing until the Player reconnects.

πŸ—Ώ Static Functions​

Inherited Entity Static Functions
Sound inherits from Base Entity Class, sharing it's methods and functions:
Base Entityscripting-reference/classes/base-classes/Entity
ReturnsNameDescription
of Returns a table containing all Entities of the class this is called on
Returns a specific Entity of this class at an index
Returns how many Entities of this class exist
of Gets a list of all directly inherited classes from this Class created with the Inheriting System
Returns an iterator with all Entities of this class to be used with pairs()
or Gets the parent class if this Class was created with the Inheriting System
Inherits this class with the Inheriting System
Gets if this Class is child of another class if this Class was created with the Inheriting System
Subscribes to an Event for all entities of this Class
Subscribes to a custom event called from server
Unsubscribes all callbacks from this Event in this Class within this Package, or only the callback passed

This class doesn't have own static functions.

🦠 Functions​

Inherited Entity Functions
Sound inherits from Base Entity Class, sharing it's methods and functions:
Base Entityscripting-reference/classes/base-classes/Entity
ReturnsNameDescription
Calls a custom remote event directly on this entity to all Players
Calls a custom remote event directly on this entity to a specific Player
Calls a custom remote event directly on this entity
Destroys this Entity
of Gets a list of all values keys
Gets the class of this entity
Gets the universal network ID of this Entity (same on both client and server)
Gets a Value stored on this Entity at the given key
Recursively checks if this entity is inherited from a Class
Returns true if this Entity is valid (i.e. wasn't destroyed and points to a valid Entity)
Sets a Value in this Entity
Subscribes to an Event on this specific entity
Subscribes to a custom event called from server on this specific entity
Unsubscribes all callbacks from this Event in this Entity within this Package, or only the callback passed
Inherited Actor Functions
Sound inherits from Base Actor Class, sharing it's methods and functions:
Base Actorscripting-reference/classes/base-classes/Actor
ReturnsNameDescription
Adds an Unreal Actor Tag to this Actor
Applies a force in world world to this Actor
Attaches this Actor to any other Actor, optionally at a specific bone
Detaches this Actor from AttachedTo Actor
of Gets all Unreal Actor Tags on this Actor
of Gets all Actors attached to this Actor
or Gets the Actor this Actor is attached to
Gets this Actor's bounds
Gets this Actor's collision type
Gets this Actor's dimension
Gets the distance of this Actor from the Camera
VectorGets this Actor's force (set by SetForce())
VectorGets this Actor's location in the game world
Player or Gets this Actor's Network Authority Player
VectorGets this Actor's Relative Location if it's attached
RotatorGets this Actor's Relative Rotation if it's attached
RotatorGets this Actor's angle in the game world
VectorGets this Actor's scale
Gets the percentage of this Actor size in the screen
Gets a Socket Transform in world space given a bone or socket name
VectorGets this Actor's current velocity
Gets if this Actor was spawned by the client side
Returns true if the local Player is currently the Network Authority of this Actor
Returns true if this Actor is being destroyed
Returns true if gravity is enabled on this Actor
Returns true if this Actor is in water
Returns true if this Actor is currently network distributed
Returns true if this Actor is visible
Removes an Unreal Actor Tag from this Actor
Smoothly rotates this actor to an angle over a certain time
Sets this Actor's collision type
Sets this Actor's Dimension
Adds a permanent force to this Actor, set to Vector(0, 0, 0) to cancel
Sets whether gravity is enabled on this Actor
Sets whether the highlight is enabled on this Actor, and which highlight index to use
Sets the time (in seconds) before this Actor is destroyed. After this time has passed, the actor will be automatically destroyed.
Sets this Actor's location in the game world
Sets the Player to have network authority over this Actor
Sets if this Actor will auto distribute the network authority between players
Sets whether the outline is enabled on this Actor, and which outline index to use
Sets this Actor's relative location in local space (only if this actor is attached)
Sets this Actor's relative rotation in local space (only if this actor is attached)
Sets this Actor's rotation in the game world
Sets this Actor's scale
Sets whether the actor is visible or not
Smoothly moves this actor to a location over a certain time
Gets if this Actor was recently rendered on screen
ReturnsNameDescription
Plays the sound with a fade effect
Stops the sound with a fade effect
Gets the duration of the Sound
No description provided
No description provided
No description provided
No description provided
No description provided
No description provided
No description provided
Gets if the sound is 2D
Gets if the sound is playing
Starts the sound
If a 3D Sound, sets the distance which the sound is inaudible
If a 3D Sound, sets the distance within the volume is 100%
Sets lowpass filter frequency. Sets 0 to disable it.
Pauses the sound
Sets the Sound's pitch
Sets the Sound's volume
Stops the sound
Stops the sound after the provided delay

FadeIn

Plays the sound with a fade effect

my_sound:FadeIn(fade_in_duration, fade_volume_level?, start_time?)
TypeParameterDefaultDescription
fade_in_duration Required parameter No description provided
fade_volume_level?1.0No description provided
start_time?0.0No description provided

FadeOut

Stops the sound with a fade effect

my_sound:FadeOut(fade_out_duration, fade_volume_level?, destroy_after_fadeout?)
TypeParameterDefaultDescription
fade_out_duration Required parameter No description provided
fade_volume_level?0.0No description provided
destroy_after_fadeout?falseNo description provided

GetDuration

Gets the duration of the Sound

β€” Returns .

local ret = my_sound:GetDuration()

GetFalloffDistance

β€” Returns .

local ret = my_sound:GetFalloffDistance()

See also SetFalloffDistance.


GetInnerRadius

β€” Returns .

local ret = my_sound:GetInnerRadius()

See also SetInnerRadius.


GetLowPassFilter

β€” Returns .

local ret = my_sound:GetLowPassFilter()

See also SetLowPassFilter.


GetPath

β€” Returns .

local ret = my_sound:GetPath()

GetPitch

β€” Returns .

local ret = my_sound:GetPitch()

See also SetPitch.


GetSoundType

β€” Returns .

local ret = my_sound:GetSoundType()

GetVolume

β€” Returns .

local ret = my_sound:GetVolume()

See also SetVolume.


Is2D

Gets if the sound is 2D

β€” Returns .

local ret = my_sound:Is2D()

IsPlaying

Gets if the sound is playing

β€” Returns .

local ret = my_sound:IsPlaying()

Play

Starts the sound

my_sound:Play(start_time?)
TypeParameterDefaultDescription
start_time?0.0No description provided

SetFalloffDistance

If a 3D Sound, sets the distance which the sound is inaudible

my_sound:SetFalloffDistance(falloff_distance)
TypeParameterDefaultDescription
falloff_distance Required parameter No description provided

See also GetFalloffDistance.


SetInnerRadius

If a 3D Sound, sets the distance within the volume is 100%

my_sound:SetInnerRadius(inner_radius)
TypeParameterDefaultDescription
inner_radius Required parameter No description provided

See also GetInnerRadius.


SetLowPassFilter

Sets lowpass filter frequency. Sets 0 to disable it.

my_sound:SetLowPassFilter(frequency)
TypeParameterDefaultDescription
frequency Required parameter No description provided

See also GetLowPassFilter.


SetPaused

Pauses the sound

my_sound:SetPaused(pause?)
TypeParameterDefaultDescription
pause?trueNo description provided

SetPitch

Sets the Sound's pitch

my_sound:SetPitch(new_pitch)
TypeParameterDefaultDescription
new_pitch Required parameter No description provided

See also GetPitch.


SetVolume

Sets the Sound's volume

my_sound:SetVolume(new_volume)
TypeParameterDefaultDescription
new_volume Required parameter from 0.0 to 1.0

See also GetVolume.


Stop

Stops the sound

my_sound:Stop()

StopDelayed

Stops the sound after the provided delay

my_sound:StopDelayed(delay)
TypeParameterDefaultDescription
delay Required parameter No description provided

πŸš€ Events​

Inherited Entity Events
Sound inherits from Base Entity Class, sharing it's events:
Base Entityscripting-reference/classes/base-classes/Entity
NameDescription
Triggered when a new Class is registered with the Inheriting System
Triggered when an Entity is destroyed
Triggered when an Entity is spawned/created
Triggered when an Entity has a value changed with :SetValue()
Inherited Actor Events
Sound inherits from Base Actor Class, sharing it's events:
Base Actorscripting-reference/classes/base-classes/Actor
NameDescription
Triggered when an Actor changes it's dimension

This class doesn't have own events.

πŸ”Š Sound Attenuation​

This property defines the function that determines the rate of attenuation over distance. There are a number of different functions to choose from:

πŸ”ˆ Linear​

This is the default function. When using this function the volume will attenuate linearly and so the changes in volume are constant as the listener moves towards and away from the source. This function is good for crossfading between large background-type sounds that don't need tightly focussed 3D spatial falloff settings.

πŸ”ˆ Logarithmic​

When using this function the volume attenuates such that the changes in volume are greater at close distances, and lesser at far distances. This function is good for spot sounds that need good 3D positioning, while still being audible at reasonable distances.

πŸ”ˆ Inverse​

When using this function, the changes in volume are similar to that of the logarithmic curve, but are more exaggerated. This function is good for sounds that only need to be just audible at far distances, but that gets significantly louder as the listener gets quite close to the source.

πŸ”ˆ Log Reverse​

When using this function, the changes in volume are lesser at close distances, with more dramatic differences at far distances. This function is good for sounds that need to be loud across larger distances.

πŸ”ˆ Natural Sound​

This function attempts to model a more 'naturalistic' falloff behavior to produce behaviors that closer match reality. This function is a kind of 'middle ground' between the Logarithmic and Inverse functions.