Sound

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

Note

This is a Client only Class.

Note

It is not possible (yet?) to load custom sound files (.mp3, .wav…), the sounds must be pre-cooked in Unreal before used.

Usage

local MySound = Sound(
    Vector(-510, 145, 63), -- Location (if a 3D sound)
    "NanosWorld::A_VR_Confirm", -- Asset Path
    false, -- Is 2D Sound
    true, -- Auto Destroy (if to destroy after finished playing)
    0, -- Sound Type (SFX)
    1, -- Volume
    1 -- Pitch
)

Constructor Parameters

Type

Name

Default

Vector

Location (Used only if 3D sound)

Vector(0, 0, 0)

string

Asset (Sound)

boolean

Is2DSound

false

boolean

AutoDestroy (if to destroy after finished playing)

true

number

Volume (0 - 1)

1

number

Sound Type (0 - SFX, 1 - Music) - Used to apply user’s volume settings

0

number

Pitch

1

Functions

Returns

Name

Description

client-only-label

FadeIn(number FadeInDuration, number FadeVolumeLevel, number StartTime)

Plays the sound with a fade effect

client-only-label

FadeOut(number FadeOutDuration, number FadeVolumeLevel)

Stops the sound with a fade effect

client-only-label

Play()

Starts the sound

client-only-label

SetFalloffDistance(number FalloffDistance)

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

client-only-label

SetLowPassFilter(number Frequency)

Sets lowpass filter frequency. Sets 0 to disable it.

client-only-label

SetPaused(boolean Pause)

Pauses the sound

client-only-label

SetPitch(number NewPitch)

Sets the Sound’s pitch

client-only-label

SetVolume(number NewVolume)

Sets the Sound’s volume (0 - 1)

client-only-label

Stop()

Stops the sound

client-only-label

StopDelayed(number Delay)

Stops the sound after the provided delay

client-only-label

boolean

IsPlaying()

Returns if the sound is playing

Functions (Inherited from Actor)

Returns

Name

Description

server-only-label

AddImpulse(Vector Force)

Applies a Force in world coordinate on this Actor (the force is applied on Client side, by the (in most of cases) the closest player of this object)

server-only-label

AttachTo(Actor Other, string BoneName, Vector RelativeLocation, Rotator RelativeRotation)

Attaches this Actor to any other Actor with a Relative Offset/Rotation

server-only-label

Destroy()

Destroys this Actor

server-only-label

SetCollision(number CollisionType)

Sets the actor’s collision (0 - Normal, 1 - Static Only, 2 - No Collision)

server-only-label

SetGravityEnabled(boolean NewGravity)

Sets the actor’s gravity enabled

server-only-label

SetInitialLocation(Vector NewInitialLocation)

Sets the initial location

server-only-label

SetLocation(Vector NewLocation)

Sets the actor’s location in the game world

server-only-label

SetRotation(Rotator NewRotation)

Sets the actor’s rotation in the game world

server-only-label

SetScale(Vector Scale)

Sets the actor’s scale

server-only-label

SetTintColor(Color NewTintColor)

Sets the tint color, for completely paint an object, multiply the color by 10 or 100

SetValue(string Key, any Value)

Sets a value in this entity, which can be accessed by any package (local only)

boolean

IsGravityEnabled()

Gets the actor’s gravity enabled

boolean

IsValid()

Returns if this is Valid

number

GetCollision()

Gets the current actor’s collision

Vector

GetLocation()

Get the actor’s position in the game world

server-only-label

Vector

GetInitialLocation()

Gets the initial location

Rotator

GetRotation()

Gets the actor’s rotation in the game world

Color

GetTintColor()

Gets the Tint Color

string

GetType()

Returns the type of this Actor

any

GetValue(string Key)

Gets a value given a key

Events

Events (Inherited from Actor)

Name

Arguments

Description

Destroy

Entity actor

Triggered when an Entity is Destroyed

Spawn

Entity actor

Triggered when an Entity is Spawned/Created