AudioSourceExt.PlayClipAtPointAsync Method

Asynchronously plays an AudioClip at a given position in world space.

Namespace: UltimateXR.Extensions.Unity.Audio
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0

Syntax

C#

public static Task PlayClipAtPointAsync(
	AudioClip clip,
	Vector3 point,
	float volume = 1f,
	float delay = 0f,
	float pitch = 1f,
	float spatialBlend = 0.9f,
	CancellationToken ct = default
)


Parameters

 

clip
Type: AudioClip
Reference to the sound clip file that will be played.
point
Type: Vector3
Position in world space from which sound originates.
volume (Optional)
Type: System.Single
How loud the sound is at a distance of one world unit (one meter) [0.0, 1.0].
delay (Optional)
Type: System.Single
Delay time specified in seconds.
pitch (Optional)
Type: System.Single
Amount of change in pitch due to slowdown/speed up of the Audio Clip. Value 1 is normal playback speed.
spatialBlend (Optional)
Type: System.Single
Sets how much the 3D engine has an effect on the audio source [0.0, 1.0].
ct (Optional)
Type: System.Threading.CancellationToken
CancellationToken to stop playing.

Return Value

Type: Task
An awaitable Task.

Remarks

This function creates an AudioSource but automatically disposes of it once the clip has finished playing.

See Also

Reference

AudioSourceExt Class
UltimateXR.Extensions.Unity.Audio Namespace